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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
49bc1cd6
Commit
49bc1cd6
authored
Jul 18, 2016
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated how the label toggle gets the text
Fixed some issues based on self-review
parent
357ad44a
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
65 deletions
+21
-65
app/assets/javascripts/labels_select.js.coffee
app/assets/javascripts/labels_select.js.coffee
+15
-59
app/assets/javascripts/milestone_select.js.coffee
app/assets/javascripts/milestone_select.js.coffee
+3
-3
app/helpers/labels_helper.rb
app/helpers/labels_helper.rb
+1
-1
app/helpers/milestones_helper.rb
app/helpers/milestones_helper.rb
+1
-1
app/views/shared/issuable/_label_dropdown.html.haml
app/views/shared/issuable/_label_dropdown.html.haml
+1
-1
No files found.
app/assets/javascripts/labels_select.js.coffee
View file @
49bc1cd6
...
...
@@ -25,11 +25,9 @@ class @LabelsSelect
$newLabelError
=
$
(
'.js-label-error'
)
$colorPreview
=
$
(
'.js-dropdown-label-color-preview'
)
$newLabelCreateButton
=
$
(
'.js-new-label-btn'
)
selectedLabels
=
[]
$
(
"input[name='
#{
$dropdown
.
data
(
'field-name'
)
}
']"
).
each
->
title
=
$
(
this
).
data
(
'title'
)
selectedLabels
.
push
(
$
(
this
).
data
(
'title'
))
if
title
fieldName
=
$dropdown
.
data
(
'field-name'
)
useId
=
$dropdown
.
hasClass
(
'js-issuable-form-dropdown'
)
or
$dropdown
.
hasClass
(
'js-filter-bulk-update'
)
propertyName
=
if
useId
then
"id"
else
"title"
$newLabelError
.
hide
()
$loading
=
$block
.
find
(
'.block-loading'
).
fadeOut
()
...
...
@@ -125,7 +123,7 @@ class @LabelsSelect
saveLabelData
=
->
selected
=
$dropdown
.
closest
(
'.selectbox'
)
.
find
(
"input[name='
#{
$dropdown
.
data
(
'field-name'
)
}
']"
)
.
find
(
"input[name='
#{
fieldName
}
']"
)
.
map
(
->
@
value
).
get
()
...
...
@@ -278,63 +276,21 @@ class @LabelsSelect
fields
:
[
'title'
]
selectable
:
true
filterable
:
true
toggleLabel
:
(
selected
,
$el
,
glDropdownInstance
)
->
# When comes from a triggered event handle it VERY differently
if
selected
instanceof
jQuery
.
Event
$dropdownParent
=
$dropdown
.
closest
'.labels-filter'
$labelInputs
=
$dropdownParent
.
find
"input[name='
#{
@
fieldName
}
']"
numberSelectedLabels
=
$labelInputs
.
length
firstLabel
=
_
.
pluck
(
$labelInputs
,
'value'
)[
0
]
if
numberSelectedLabels
is
1
firstLabel
else
if
numberSelectedLabels
>
1
"
#{
firstLabel
}
+
#{
numberSelectedLabels
-
1
}
more"
else
defaultLabel
# when clicking on a dropdown option
else
# Return when clicking "No Label"
return
if
selected
.
id
is
0
return
'Any Label'
if
selected
.
isAny
is
true
toggleLabel
:
(
selected
,
el
,
glDropdown
)
->
if
glDropdown
?
selectedIds
=
$
(
"input[name='
#{
fieldName
}
']"
).
map
(
->
$
(
this
).
val
()).
get
()
if
glDropdownInstance
?
$dropdownParent
=
glDropdownInstance
.
dropdown
.
closest
'.issuable-form-select-holder, .labels-filter'
else
$dropdownParent
=
$
()
$labelInputs
=
$dropdownParent
.
find
"input[name='
#{
@
fieldName
}
']"
selected
=
_
.
filter
glDropdown
.
fullData
,
(
label
)
->
selectedIds
.
indexOf
(
"
#{
label
[
propertyName
]
}
"
)
>=
0
if
label
[
propertyName
]
?
# Find the label by its attribute according the dropdown settings
if
$dropdown
.
hasClass
(
'js-issuable-form-dropdown'
)
or
$dropdown
.
hasClass
(
'js-filter-bulk-update'
)
# When settings labels to a issuable we find the label for its ID
whereQuery
=
{
id
:
parseInt
$labelInputs
.
first
().
val
()
}
else
# When filtering issuables we find the label for its title
whereQuery
=
{
title
:
$labelInputs
.
first
().
val
()
}
firstLabel
=
_
.
findWhere
glDropdownInstance
.
fullData
,
whereQuery
# Better rely on inputs since filtering may returns invalid number of active labels
numberSelectedLabels
=
$labelInputs
.
length
# If we are adding a label
if
$el
.
is
'.is-active'
if
numberSelectedLabels
is
1
selected
.
title
else
"
#{
selected
.
title
}
+
#{
numberSelectedLabels
-
1
}
more"
# otherwise we are removing a label
else
if
numberSelectedLabels
is
1
firstLabel
.
title
else
if
numberSelectedLabels
>
1
"
#{
firstLabel
.
title
}
+
#{
numberSelectedLabels
-
1
}
more"
if
selected
.
length
is
1
selected
[
0
].
title
else
if
selected
.
length
>
1
"
#{
selected
[
0
].
title
}
+
#{
selected
.
length
-
1
}
more"
else
defaultLabel
defaultLabel
:
defaultLabel
fieldName
:
$dropdown
.
data
(
'field-name'
)
fieldName
:
fieldName
id
:
(
label
)
->
if
$dropdown
.
hasClass
(
'js-issuable-form-dropdown'
)
if
label
.
id
is
0
...
...
app/assets/javascripts/milestone_select.js.coffee
View file @
49bc1cd6
...
...
@@ -70,8 +70,8 @@ class @MilestoneSelect
search
:
fields
:
[
'title'
]
selectable
:
true
toggleLabel
:
(
selected
,
el
,
e
,
added
)
->
if
selected
and
'id'
of
selected
and
added
toggleLabel
:
(
selected
,
el
,
e
)
->
if
selected
and
'id'
of
selected
and
$
(
el
).
hasClass
(
'is-active'
)
selected
.
title
else
defaultLabel
...
...
@@ -80,7 +80,7 @@ class @MilestoneSelect
text
:
(
milestone
)
->
_
.
escape
(
milestone
.
title
)
id
:
(
milestone
)
->
if
!
useId
and
not
$dropdown
.
is
(
'.js-issuable-form-dropdown'
)
if
not
useId
and
not
$dropdown
.
is
(
'.js-issuable-form-dropdown'
)
milestone
.
name
else
milestone
.
id
...
...
app/helpers/labels_helper.rb
View file @
49bc1cd6
...
...
@@ -116,7 +116,7 @@ module LabelsHelper
def
labels_filter_path
project
=
@target_project
||
@project
if
@
project
if
project
namespace_project_labels_path
(
project
.
namespace
,
project
,
:json
)
else
dashboard_labels_path
(
:json
)
...
...
app/helpers/milestones_helper.rb
View file @
49bc1cd6
...
...
@@ -48,7 +48,7 @@ module MilestonesHelper
def
milestones_filter_dropdown_path
project
=
@target_project
||
@project
if
@
project
if
project
namespace_project_milestones_path
(
project
.
namespace
,
project
,
:json
)
else
dashboard_milestones_path
(
:json
)
...
...
app/views/shared/issuable/_label_dropdown.html.haml
View file @
49bc1cd6
...
...
@@ -22,7 +22,7 @@
-
selected
.
each
do
|
label
|
-
id
=
label
.
try
(
:id
)
||
label
-
title
=
label
.
try
(
:title
)
||
label
=
hidden_field_tag
data_options
[
:field_name
],
useId
?
id
:
title
,
id:
nil
,
data:
{
title:
title
}
=
hidden_field_tag
data_options
[
:field_name
],
useId
?
id
:
title
,
id:
nil
.dropdown
%button
.dropdown-menu-toggle.js-label-select.js-multiselect
{
class:
classes
.
join
(
' '
),
type:
"button"
,
data:
dropdown_data
}
%span
.dropdown-toggle-text
{
class:
(
"is-default"
if
selected
.
nil?
||
selected
.
to_a
.
size
==
0
)
}
...
...
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