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
611ac8e3
Commit
611ac8e3
authored
Feb 27, 2018
by
Kushal Pandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make label filter URL dynamic
parent
4371f845
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
12 deletions
+28
-12
app/assets/javascripts/labels_select.js
app/assets/javascripts/labels_select.js
+28
-12
No files found.
app/assets/javascripts/labels_select.js
View file @
611ac8e3
...
@@ -21,7 +21,7 @@ export default class LabelsSelect {
...
@@ -21,7 +21,7 @@ export default class LabelsSelect {
}
}
$els
.
each
(
function
(
i
,
dropdown
)
{
$els
.
each
(
function
(
i
,
dropdown
)
{
var
$block
,
$colorPreview
,
$dropdown
,
$form
,
$loading
,
$selectbox
,
$sidebarCollapsedValue
,
$value
,
abilityName
,
defaultLabel
,
enableLabelCreateButton
,
issueURLSplit
,
issueUpdateURL
,
label
HTMLTemplate
,
labelNoneHTMLTemplate
,
label
Url
,
namespacePath
,
projectPath
,
saveLabelData
,
selectedLabel
,
showAny
,
showNo
,
$sidebarLabelTooltip
,
initialSelected
,
$toggleText
,
fieldName
,
useId
,
propertyName
,
showMenuAbove
,
$container
,
$dropdownContainer
;
var
$block
,
$colorPreview
,
$dropdown
,
$form
,
$loading
,
$selectbox
,
$sidebarCollapsedValue
,
$value
,
abilityName
,
defaultLabel
,
enableLabelCreateButton
,
issueURLSplit
,
issueUpdateURL
,
labelUrl
,
namespacePath
,
projectPath
,
saveLabelData
,
selectedLabel
,
showAny
,
showNo
,
$sidebarLabelTooltip
,
initialSelected
,
$toggleText
,
fieldName
,
useId
,
propertyName
,
showMenuAbove
,
$container
,
$dropdownContainer
;
$dropdown
=
$
(
dropdown
);
$dropdown
=
$
(
dropdown
);
$dropdownContainer
=
$dropdown
.
closest
(
'
.labels-filter
'
);
$dropdownContainer
=
$dropdown
.
closest
(
'
.labels-filter
'
);
$toggleText
=
$dropdown
.
find
(
'
.dropdown-toggle-text
'
);
$toggleText
=
$dropdown
.
find
(
'
.dropdown-toggle-text
'
);
...
@@ -53,13 +53,6 @@ export default class LabelsSelect {
...
@@ -53,13 +53,6 @@ export default class LabelsSelect {
.
map
(
function
()
{
.
map
(
function
()
{
return
this
.
value
;
return
this
.
value
;
}).
get
();
}).
get
();
if
(
issueUpdateURL
!=
null
)
{
issueURLSplit
=
issueUpdateURL
.
split
(
'
/
'
);
}
if
(
issueUpdateURL
)
{
labelHTMLTemplate
=
_
.
template
(
'
<% _.each(labels, function(label){ %> <a href="<%- ["",issueURLSplit[1], issueURLSplit[2],""].join("/") %>issues?label_name[]=<%- encodeURIComponent(label.title) %>"> <span class="label has-tooltip color-label" title="<%- label.description %>" style="background-color: <%- label.color %>; color: <%- label.text_color %>;"> <%- label.title %> </span> </a> <% }); %>
'
);
labelNoneHTMLTemplate
=
'
<span class="no-value">None</span>
'
;
}
const
handleClick
=
options
.
handleClick
;
const
handleClick
=
options
.
handleClick
;
$sidebarLabelTooltip
.
tooltip
();
$sidebarLabelTooltip
.
tooltip
();
...
@@ -91,14 +84,17 @@ export default class LabelsSelect {
...
@@ -91,14 +84,17 @@ export default class LabelsSelect {
$loading
.
fadeOut
();
$loading
.
fadeOut
();
$dropdown
.
trigger
(
'
loaded.gl.dropdown
'
);
$dropdown
.
trigger
(
'
loaded.gl.dropdown
'
);
$selectbox
.
hide
();
$selectbox
.
hide
();
data
.
issueU
RLSplit
=
issueURLSplit
;
data
.
issueU
pdateURL
=
issueUpdateURL
;
labelCount
=
0
;
labelCount
=
0
;
if
(
data
.
labels
.
length
)
{
if
(
data
.
labels
.
length
&&
issueUpdateURL
)
{
template
=
labelHTMLTemplate
(
data
);
template
=
LabelsSelect
.
getLabelTemplate
({
labels
:
data
.
labels
,
issueUpdateURL
,
});
labelCount
=
data
.
labels
.
length
;
labelCount
=
data
.
labels
.
length
;
}
}
else
{
else
{
template
=
labelNoneHTMLTemplate
;
template
=
'
<span class="no-value">None</span>
'
;
}
}
$value
.
removeAttr
(
'
style
'
).
html
(
template
);
$value
.
removeAttr
(
'
style
'
).
html
(
template
);
$sidebarCollapsedValue
.
text
(
labelCount
);
$sidebarCollapsedValue
.
text
(
labelCount
);
...
@@ -418,6 +414,26 @@ export default class LabelsSelect {
...
@@ -418,6 +414,26 @@ export default class LabelsSelect {
this
.
bindEvents
();
this
.
bindEvents
();
}
}
static
getLabelTemplate
(
tplData
)
{
// We could use ES6 template string here
// and properly indent markup for readability
// but that also introduces unintended white-space
// so best approach is to use traditional way of
// concatenation
// see: http://2ality.com/2016/05/template-literal-whitespace.html#joining-arrays
const
tpl
=
_
.
template
([
'
<% _.each(labels, function(label){ %>
'
,
'
<a href="<%- issueUpdateURL.slice(0, issueUpdateURL.lastIndexOf("/")) %>?label_name[]=<%- encodeURIComponent(label.title) %>">
'
,
'
<span class="label has-tooltip color-label" title="<%- label.description %>" style="background-color: <%- label.color %>; color: <%- label.text_color %>;">
'
,
'
<%- label.title %>
'
,
'
</span>
'
,
'
</a>
'
,
'
<% }); %>
'
,
].
join
(
''
));
return
tpl
(
tplData
);
}
bindEvents
()
{
bindEvents
()
{
return
$
(
'
body
'
).
on
(
'
change
'
,
'
.selected_issue
'
,
this
.
onSelectCheckboxIssue
);
return
$
(
'
body
'
).
on
(
'
change
'
,
'
.selected_issue
'
,
this
.
onSelectCheckboxIssue
);
}
}
...
...
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