Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
05a3479c
Commit
05a3479c
authored
Jan 30, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Converted labels_select.js to axios
parent
d5041184
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
85 additions
and
85 deletions
+85
-85
app/assets/javascripts/labels_select.js
app/assets/javascripts/labels_select.js
+85
-85
No files found.
app/assets/javascripts/labels_select.js
View file @
05a3479c
...
@@ -2,9 +2,12 @@
...
@@ -2,9 +2,12 @@
/* global Issuable */
/* global Issuable */
/* global ListLabel */
/* global ListLabel */
import
_
from
'
underscore
'
;
import
_
from
'
underscore
'
;
import
{
__
}
from
'
./locale
'
;
import
axios
from
'
./lib/utils/axios_utils
'
;
import
IssuableBulkUpdateActions
from
'
./issuable_bulk_update_actions
'
;
import
IssuableBulkUpdateActions
from
'
./issuable_bulk_update_actions
'
;
import
DropdownUtils
from
'
./filtered_search/dropdown_utils
'
;
import
DropdownUtils
from
'
./filtered_search/dropdown_utils
'
;
import
CreateLabelDropdown
from
'
./create_label
'
;
import
CreateLabelDropdown
from
'
./create_label
'
;
import
flash
from
'
./flash
'
;
export
default
class
LabelsSelect
{
export
default
class
LabelsSelect
{
constructor
(
els
,
options
=
{})
{
constructor
(
els
,
options
=
{})
{
...
@@ -82,99 +85,96 @@ export default class LabelsSelect {
...
@@ -82,99 +85,96 @@ export default class LabelsSelect {
}
}
$loading
.
removeClass
(
'
hidden
'
).
fadeIn
();
$loading
.
removeClass
(
'
hidden
'
).
fadeIn
();
$dropdown
.
trigger
(
'
loading.gl.dropdown
'
);
$dropdown
.
trigger
(
'
loading.gl.dropdown
'
);
return
$
.
ajax
({
axios
.
put
(
issueUpdateURL
,
data
)
type
:
'
PUT
'
,
.
then
(({
data
})
=>
{
url
:
issueUpdateURL
,
var
labelCount
,
template
,
labelTooltipTitle
,
labelTitles
;
dataType
:
'
JSON
'
,
$loading
.
fadeOut
();
data
:
data
$dropdown
.
trigger
(
'
loaded.gl.dropdown
'
);
}).
done
(
function
(
data
)
{
$selectbox
.
hide
();
var
labelCount
,
template
,
labelTooltipTitle
,
labelTitles
;
data
.
issueURLSplit
=
issueURLSplit
;
$loading
.
fadeOut
();
labelCount
=
0
;
$dropdown
.
trigger
(
'
loaded.gl.dropdown
'
);
if
(
data
.
labels
.
length
)
{
$selectbox
.
hide
();
template
=
labelHTMLTemplate
(
data
);
data
.
issueURLSplit
=
issueURLSplit
;
labelCount
=
data
.
labels
.
length
;
labelCount
=
0
;
if
(
data
.
labels
.
length
)
{
template
=
labelHTMLTemplate
(
data
);
labelCount
=
data
.
labels
.
length
;
}
else
{
template
=
labelNoneHTMLTemplate
;
}
$value
.
removeAttr
(
'
style
'
).
html
(
template
);
$sidebarCollapsedValue
.
text
(
labelCount
);
if
(
data
.
labels
.
length
)
{
labelTitles
=
data
.
labels
.
map
(
function
(
label
)
{
return
label
.
title
;
});
if
(
labelTitles
.
length
>
5
)
{
labelTitles
=
labelTitles
.
slice
(
0
,
5
);
labelTitles
.
push
(
'
and
'
+
(
data
.
labels
.
length
-
5
)
+
'
more
'
);
}
}
else
{
labelTooltipTitle
=
labelTitles
.
join
(
'
,
'
);
template
=
labelNoneHTMLTemplate
;
}
}
else
{
$value
.
removeAttr
(
'
style
'
).
html
(
template
);
labelTooltipTitle
=
''
;
$sidebarCollapsedValue
.
text
(
labelCount
);
$sidebarLabelTooltip
.
tooltip
(
'
destroy
'
);
}
if
(
data
.
labels
.
length
)
{
labelTitles
=
data
.
labels
.
map
(
function
(
label
)
{
$sidebarLabelTooltip
return
label
.
title
;
.
attr
(
'
title
'
,
labelTooltipTitle
)
});
.
tooltip
(
'
fixTitle
'
);
if
(
labelTitles
.
length
>
5
)
{
$
(
'
.has-tooltip
'
,
$value
).
tooltip
({
labelTitles
=
labelTitles
.
slice
(
0
,
5
);
container
:
'
body
'
labelTitles
.
push
(
'
and
'
+
(
data
.
labels
.
length
-
5
)
+
'
more
'
);
});
}
});
labelTooltipTitle
=
labelTitles
.
join
(
'
,
'
);
}
else
{
labelTooltipTitle
=
''
;
$sidebarLabelTooltip
.
tooltip
(
'
destroy
'
);
}
$sidebarLabelTooltip
.
attr
(
'
title
'
,
labelTooltipTitle
)
.
tooltip
(
'
fixTitle
'
);
$
(
'
.has-tooltip
'
,
$value
).
tooltip
({
container
:
'
body
'
});
})
.
catch
(()
=>
flash
(
__
(
'
Error saving label update.
'
)));
};
};
$dropdown
.
glDropdown
({
$dropdown
.
glDropdown
({
showMenuAbove
:
showMenuAbove
,
showMenuAbove
:
showMenuAbove
,
data
:
function
(
term
,
callback
)
{
data
:
function
(
term
,
callback
)
{
return
$
.
ajax
({
axios
.
get
(
labelUrl
)
url
:
labelUrl
.
then
((
res
)
=>
{
}).
done
(
function
(
data
)
{
let
data
=
_
.
chain
(
res
.
data
).
groupBy
(
function
(
label
)
{
data
=
_
.
chain
(
data
).
groupBy
(
function
(
label
)
{
return
label
.
title
;
return
label
.
title
;
}).
map
(
function
(
label
)
{
}).
map
(
function
(
label
)
{
var
color
;
var
color
;
color
=
_
.
map
(
label
,
function
(
dup
)
{
color
=
_
.
map
(
label
,
function
(
dup
)
{
return
dup
.
color
;
return
dup
.
color
;
});
return
{
id
:
label
[
0
].
id
,
title
:
label
[
0
].
title
,
color
:
color
,
duplicate
:
color
.
length
>
1
};
}).
value
();
if
(
$dropdown
.
hasClass
(
'
js-extra-options
'
))
{
var
extraData
=
[];
if
(
showNo
)
{
extraData
.
unshift
({
id
:
0
,
title
:
'
No Label
'
});
}
if
(
showAny
)
{
extraData
.
unshift
({
isAny
:
true
,
title
:
'
Any Label
'
});
});
return
{
id
:
label
[
0
].
id
,
title
:
label
[
0
].
title
,
color
:
color
,
duplicate
:
color
.
length
>
1
};
}).
value
();
if
(
$dropdown
.
hasClass
(
'
js-extra-options
'
))
{
var
extraData
=
[];
if
(
showNo
)
{
extraData
.
unshift
({
id
:
0
,
title
:
'
No Label
'
});
}
if
(
showAny
)
{
extraData
.
unshift
({
isAny
:
true
,
title
:
'
Any Label
'
});
}
if
(
extraData
.
length
)
{
extraData
.
push
(
'
divider
'
);
data
=
extraData
.
concat
(
data
);
}
}
}
if
(
extraData
.
length
)
{
extraData
.
push
(
'
divider
'
);
callback
(
data
);
data
=
extraData
.
concat
(
data
);
if
(
showMenuAbove
)
{
$dropdown
.
data
(
'
glDropdown
'
).
positionMenuAbove
();
}
}
}
})
.
catch
(()
=>
flash
(
__
(
'
Error fetching labels.
'
)));
callback
(
data
);
if
(
showMenuAbove
)
{
$dropdown
.
data
(
'
glDropdown
'
).
positionMenuAbove
();
}
});
},
},
renderRow
:
function
(
label
,
instance
)
{
renderRow
:
function
(
label
,
instance
)
{
var
$a
,
$li
,
color
,
colorEl
,
indeterminate
,
removesAll
,
selectedClass
,
spacing
,
i
,
marked
,
dropdownName
,
dropdownValue
;
var
$a
,
$li
,
color
,
colorEl
,
indeterminate
,
removesAll
,
selectedClass
,
spacing
,
i
,
marked
,
dropdownName
,
dropdownValue
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment