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
Tatuya Kamada
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
...
@@ -25,11 +25,9 @@ class @LabelsSelect
$newLabelError
=
$
(
'.js-label-error'
)
$newLabelError
=
$
(
'.js-label-error'
)
$colorPreview
=
$
(
'.js-dropdown-label-color-preview'
)
$colorPreview
=
$
(
'.js-dropdown-label-color-preview'
)
$newLabelCreateButton
=
$
(
'.js-new-label-btn'
)
$newLabelCreateButton
=
$
(
'.js-new-label-btn'
)
selectedLabels
=
[]
fieldName
=
$dropdown
.
data
(
'field-name'
)
useId
=
$dropdown
.
hasClass
(
'js-issuable-form-dropdown'
)
or
$dropdown
.
hasClass
(
'js-filter-bulk-update'
)
$
(
"input[name='
#{
$dropdown
.
data
(
'field-name'
)
}
']"
).
each
->
propertyName
=
if
useId
then
"id"
else
"title"
title
=
$
(
this
).
data
(
'title'
)
selectedLabels
.
push
(
$
(
this
).
data
(
'title'
))
if
title
$newLabelError
.
hide
()
$newLabelError
.
hide
()
$loading
=
$block
.
find
(
'.block-loading'
).
fadeOut
()
$loading
=
$block
.
find
(
'.block-loading'
).
fadeOut
()
...
@@ -125,7 +123,7 @@ class @LabelsSelect
...
@@ -125,7 +123,7 @@ class @LabelsSelect
saveLabelData
=
->
saveLabelData
=
->
selected
=
$dropdown
selected
=
$dropdown
.
closest
(
'.selectbox'
)
.
closest
(
'.selectbox'
)
.
find
(
"input[name='
#{
$dropdown
.
data
(
'field-name'
)
}
']"
)
.
find
(
"input[name='
#{
fieldName
}
']"
)
.
map
(
->
.
map
(
->
@
value
@
value
).
get
()
).
get
()
...
@@ -278,63 +276,21 @@ class @LabelsSelect
...
@@ -278,63 +276,21 @@ class @LabelsSelect
fields
:
[
'title'
]
fields
:
[
'title'
]
selectable
:
true
selectable
:
true
filterable
:
true
filterable
:
true
toggleLabel
:
(
selected
,
$el
,
glDropdownInstance
)
->
toggleLabel
:
(
selected
,
el
,
glDropdown
)
->
# When comes from a triggered event handle it VERY differently
if
glDropdown
?
if
selected
instanceof
jQuery
.
Event
selectedIds
=
$
(
"input[name='
#{
fieldName
}
']"
).
map
(
->
$
(
this
).
val
()).
get
()
$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
if
glDropdownInstance
?
selected
=
_
.
filter
glDropdown
.
fullData
,
(
label
)
->
$dropdownParent
=
glDropdownInstance
.
dropdown
.
closest
'.issuable-form-select-holder, .labels-filter'
selectedIds
.
indexOf
(
"
#{
label
[
propertyName
]
}
"
)
>=
0
if
label
[
propertyName
]
?
else
$dropdownParent
=
$
()
$labelInputs
=
$dropdownParent
.
find
"input[name='
#{
@
fieldName
}
']"
# Find the label by its attribute according the dropdown settings
if
selected
.
length
is
1
if
$dropdown
.
hasClass
(
'js-issuable-form-dropdown'
)
or
$dropdown
.
hasClass
(
'js-filter-bulk-update'
)
selected
[
0
].
title
# When settings labels to a issuable we find the label for its ID
else
if
selected
.
length
>
1
whereQuery
=
{
id
:
parseInt
$labelInputs
.
first
().
val
()
}
"
#{
selected
[
0
].
title
}
+
#{
selected
.
length
-
1
}
more"
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"
else
else
defaultLabel
defaultLabel
defaultLabel
:
defaultLabel
defaultLabel
:
defaultLabel
fieldName
:
$dropdown
.
data
(
'field-name'
)
fieldName
:
fieldName
id
:
(
label
)
->
id
:
(
label
)
->
if
$dropdown
.
hasClass
(
'js-issuable-form-dropdown'
)
if
$dropdown
.
hasClass
(
'js-issuable-form-dropdown'
)
if
label
.
id
is
0
if
label
.
id
is
0
...
...
app/assets/javascripts/milestone_select.js.coffee
View file @
49bc1cd6
...
@@ -70,8 +70,8 @@ class @MilestoneSelect
...
@@ -70,8 +70,8 @@ class @MilestoneSelect
search
:
search
:
fields
:
[
'title'
]
fields
:
[
'title'
]
selectable
:
true
selectable
:
true
toggleLabel
:
(
selected
,
el
,
e
,
added
)
->
toggleLabel
:
(
selected
,
el
,
e
)
->
if
selected
and
'id'
of
selected
and
added
if
selected
and
'id'
of
selected
and
$
(
el
).
hasClass
(
'is-active'
)
selected
.
title
selected
.
title
else
else
defaultLabel
defaultLabel
...
@@ -80,7 +80,7 @@ class @MilestoneSelect
...
@@ -80,7 +80,7 @@ class @MilestoneSelect
text
:
(
milestone
)
->
text
:
(
milestone
)
->
_
.
escape
(
milestone
.
title
)
_
.
escape
(
milestone
.
title
)
id
:
(
milestone
)
->
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
milestone
.
name
else
else
milestone
.
id
milestone
.
id
...
...
app/helpers/labels_helper.rb
View file @
49bc1cd6
...
@@ -116,7 +116,7 @@ module LabelsHelper
...
@@ -116,7 +116,7 @@ module LabelsHelper
def
labels_filter_path
def
labels_filter_path
project
=
@target_project
||
@project
project
=
@target_project
||
@project
if
@
project
if
project
namespace_project_labels_path
(
project
.
namespace
,
project
,
:json
)
namespace_project_labels_path
(
project
.
namespace
,
project
,
:json
)
else
else
dashboard_labels_path
(
:json
)
dashboard_labels_path
(
:json
)
...
...
app/helpers/milestones_helper.rb
View file @
49bc1cd6
...
@@ -48,7 +48,7 @@ module MilestonesHelper
...
@@ -48,7 +48,7 @@ module MilestonesHelper
def
milestones_filter_dropdown_path
def
milestones_filter_dropdown_path
project
=
@target_project
||
@project
project
=
@target_project
||
@project
if
@
project
if
project
namespace_project_milestones_path
(
project
.
namespace
,
project
,
:json
)
namespace_project_milestones_path
(
project
.
namespace
,
project
,
:json
)
else
else
dashboard_milestones_path
(
:json
)
dashboard_milestones_path
(
:json
)
...
...
app/views/shared/issuable/_label_dropdown.html.haml
View file @
49bc1cd6
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
-
selected
.
each
do
|
label
|
-
selected
.
each
do
|
label
|
-
id
=
label
.
try
(
:id
)
||
label
-
id
=
label
.
try
(
:id
)
||
label
-
title
=
label
.
try
(
:title
)
||
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
.dropdown
%button
.dropdown-menu-toggle.js-label-select.js-multiselect
{
class:
classes
.
join
(
' '
),
type:
"button"
,
data:
dropdown_data
}
%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
)
}
%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