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
Léo-Paul Géneau
gitlab-ce
Commits
c5c4b62b
Commit
c5c4b62b
authored
5 years ago
by
Heinrich Lee Yu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove jQuery overhead in labels select rendering
parent
e76e1e80
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
11 deletions
+18
-11
app/assets/javascripts/labels_select.js
app/assets/javascripts/labels_select.js
+18
-11
No files found.
app/assets/javascripts/labels_select.js
View file @
c5c4b62b
...
@@ -199,8 +199,8 @@ export default class LabelsSelect {
...
@@ -199,8 +199,8 @@ export default class LabelsSelect {
.
catch
(()
=>
flash
(
__
(
'
Error fetching labels.
'
)));
.
catch
(()
=>
flash
(
__
(
'
Error fetching labels.
'
)));
},
},
renderRow
:
function
(
label
,
instance
)
{
renderRow
:
function
(
label
,
instance
)
{
var
$a
,
var
linkEl
,
$li
,
listItemEl
,
color
,
color
,
colorEl
,
colorEl
,
indeterminate
,
indeterminate
,
...
@@ -209,12 +209,11 @@ export default class LabelsSelect {
...
@@ -209,12 +209,11 @@ export default class LabelsSelect {
spacing
,
spacing
,
i
,
i
,
marked
,
marked
,
dropdownName
,
dropdownValue
;
dropdownValue
;
$li
=
$
(
'
<li>
'
);
$a
=
$
(
'
<a href="#">
'
);
selectedClass
=
[];
selectedClass
=
[];
removesAll
=
label
.
id
<=
0
||
label
.
id
==
null
;
removesAll
=
label
.
id
<=
0
||
label
.
id
==
null
;
if
(
$dropdown
.
hasClass
(
'
js-filter-bulk-update
'
))
{
if
(
$dropdown
.
hasClass
(
'
js-filter-bulk-update
'
))
{
indeterminate
=
$dropdown
.
data
(
'
indeterminate
'
)
||
[];
indeterminate
=
$dropdown
.
data
(
'
indeterminate
'
)
||
[];
marked
=
$dropdown
.
data
(
'
marked
'
)
||
[];
marked
=
$dropdown
.
data
(
'
marked
'
)
||
[];
...
@@ -233,7 +232,6 @@ export default class LabelsSelect {
...
@@ -233,7 +232,6 @@ export default class LabelsSelect {
}
}
}
else
{
}
else
{
if
(
this
.
id
(
label
))
{
if
(
this
.
id
(
label
))
{
dropdownName
=
$dropdown
.
data
(
'
fieldName
'
);
dropdownValue
=
this
.
id
(
label
)
dropdownValue
=
this
.
id
(
label
)
.
toString
()
.
toString
()
.
replace
(
/'/g
,
"
\\
'
"
);
.
replace
(
/'/g
,
"
\\
'
"
);
...
@@ -241,7 +239,7 @@ export default class LabelsSelect {
...
@@ -241,7 +239,7 @@ export default class LabelsSelect {
if
(
if
(
$form
.
find
(
$form
.
find
(
"
input[type='hidden'][name='
"
+
"
input[type='hidden'][name='
"
+
dropdown
Name
+
this
.
field
Name
+
"
'][value='
"
+
"
'][value='
"
+
dropdownValue
+
dropdownValue
+
"
']
"
,
"
']
"
,
...
@@ -251,25 +249,34 @@ export default class LabelsSelect {
...
@@ -251,25 +249,34 @@ export default class LabelsSelect {
}
}
}
}
if
(
$dropdown
.
hasClass
(
'
js-multiselect
'
)
&&
removesAll
)
{
if
(
this
.
multiSelect
&&
removesAll
)
{
selectedClass
.
push
(
'
dropdown-clear-active
'
);
selectedClass
.
push
(
'
dropdown-clear-active
'
);
}
}
}
}
if
(
label
.
color
)
{
if
(
label
.
color
)
{
colorEl
=
colorEl
=
"
<span class='dropdown-label-box' style='background:
"
+
label
.
color
+
"
'></span>
"
;
"
<span class='dropdown-label-box' style='background:
"
+
label
.
color
+
"
'></span>
"
;
}
else
{
}
else
{
colorEl
=
''
;
colorEl
=
''
;
}
}
linkEl
=
document
.
createElement
(
'
a
'
);
linkEl
.
href
=
'
#
'
;
// We need to identify which items are actually labels
// We need to identify which items are actually labels
if
(
label
.
id
)
{
if
(
label
.
id
)
{
selectedClass
.
push
(
'
label-item
'
);
selectedClass
.
push
(
'
label-item
'
);
$a
.
attr
(
'
data-label-id
'
,
label
.
id
)
;
linkEl
.
dataset
.
labelId
=
label
.
id
;
}
}
$a
.
addClass
(
selectedClass
.
join
(
'
'
)).
html
(
`
${
colorEl
}
${
_
.
escape
(
label
.
title
)}
`
);
linkEl
.
className
=
selectedClass
.
join
(
'
'
);
linkEl
.
innerHTML
=
`
${
colorEl
}
${
_
.
escape
(
label
.
title
)}
`
;
listItemEl
=
document
.
createElement
(
'
li
'
);
listItemEl
.
appendChild
(
linkEl
);
return
$li
.
html
(
$a
)
;
return
listItemEl
;
},
},
search
:
{
search
:
{
fields
:
[
'
title
'
],
fields
:
[
'
title
'
],
...
...
This diff is collapsed.
Click to expand it.
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