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
3753ace9
Commit
3753ace9
authored
Mar 13, 2016
by
Jacob Schatz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add labels as proper POST arrays using new dropdown
parent
024dc807
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
63 additions
and
49 deletions
+63
-49
app/assets/javascripts/labels_select.js.coffee
app/assets/javascripts/labels_select.js.coffee
+41
-32
app/assets/javascripts/milestone_select.js.coffee
app/assets/javascripts/milestone_select.js.coffee
+13
-13
app/controllers/projects/issues_controller.rb
app/controllers/projects/issues_controller.rb
+7
-1
app/views/shared/issuable/_filter.html.haml
app/views/shared/issuable/_filter.html.haml
+1
-2
app/views/shared/issuable/_sidebar.html.haml
app/views/shared/issuable/_sidebar.html.haml
+1
-1
No files found.
app/assets/javascripts/labels_select.js.coffee
View file @
3753ace9
...
@@ -6,8 +6,8 @@ class @LabelsSelect
...
@@ -6,8 +6,8 @@ class @LabelsSelect
labelUrl
=
$dropdown
.
data
(
'labels'
)
labelUrl
=
$dropdown
.
data
(
'labels'
)
issueUpdateURL
=
$dropdown
.
data
(
'issueUpdate'
)
issueUpdateURL
=
$dropdown
.
data
(
'issueUpdate'
)
selectedLabel
=
$dropdown
.
data
(
'selected'
)
selectedLabel
=
$dropdown
.
data
(
'selected'
)
if
selectedLabel
if
selectedLabel
?
selectedLabel
=
selectedLabel
.
toString
().
split
(
','
)
selectedLabel
=
selectedLabel
.
split
(
','
)
newLabelField
=
$
(
'#new_label_name'
)
newLabelField
=
$
(
'#new_label_name'
)
newColorField
=
$
(
'#new_label_color'
)
newColorField
=
$
(
'#new_label_color'
)
showNo
=
$dropdown
.
data
(
'show-no'
)
showNo
=
$dropdown
.
data
(
'show-no'
)
...
@@ -17,19 +17,6 @@ class @LabelsSelect
...
@@ -17,19 +17,6 @@ class @LabelsSelect
$block
=
$selectbox
.
closest
(
'.block'
)
$block
=
$selectbox
.
closest
(
'.block'
)
$value
=
$block
.
find
(
'.value'
)
$value
=
$block
.
find
(
'.value'
)
$loading
=
$block
.
find
(
'.block-loading'
).
fadeOut
()
$loading
=
$block
.
find
(
'.block-loading'
).
fadeOut
()
issueURLSplit
=
issueUpdateURL
.
split
(
'/'
)
labelHTMLTemplate
=
_
.
template
(
'<% _.each(labels, function(label){ %>'
+
'<a href="'
+
[
''
,
issueURLSplit
[
1
],
issueURLSplit
[
2
],
''
].
join
(
'/'
)
+
'issues?label_name=<%= label.title %>">'
+
'<span class="label color-label" '
+
'style="background-color: <%= label.color %>; '
+
'color: #FFFFFF">'
+
'<%= label.title %>'
+
'</span>'
+
'</a>'
+
'<% }); %>'
);
if
newLabelField
.
length
if
newLabelField
.
length
$newLabelCreateButton
=
$
(
'.js-new-label-btn'
)
$newLabelCreateButton
=
$
(
'.js-new-label-btn'
)
...
@@ -39,6 +26,24 @@ class @LabelsSelect
...
@@ -39,6 +26,24 @@ class @LabelsSelect
# Suggested colors in the dropdown to chose from pre-chosen colors
# Suggested colors in the dropdown to chose from pre-chosen colors
$
(
'.suggest-colors-dropdown a'
).
on
'click'
,
(
e
)
->
$
(
'.suggest-colors-dropdown a'
).
on
'click'
,
(
e
)
->
issueURLSplit
=
issueURL
.
split
(
'/'
)
if
issueURL
?
if
issueURL
labelHTMLTemplate
=
_
.
template
(
'<% _.each(labels, function(label){ %>'
+
'<a href="'
+
[
''
,
issueURLSplit
[
1
],
issueURLSplit
[
2
],
''
].
join
(
'/'
)
+
'issues?label_name=<%= label.title %>">'
+
'<span class="label color-label" '
+
'style="background-color: <%= label.color %>; '
+
'color: #FFFFFF">'
+
'<%= label.title %>'
+
'</span>'
+
'</a>'
+
'<% }); %>'
);
if
newLabelField
.
length
and
$dropdown
.
hasClass
'js-extra-options'
$
(
'.suggest-colors-dropdown a'
).
on
"click"
,
(
e
)
->
e
.
preventDefault
()
e
.
preventDefault
()
e
.
stopPropagation
()
e
.
stopPropagation
()
newColorField
newColorField
...
@@ -113,22 +118,23 @@ class @LabelsSelect
...
@@ -113,22 +118,23 @@ class @LabelsSelect
$
.
ajax
(
$
.
ajax
(
url
:
labelUrl
url
:
labelUrl
).
done
(
data
)
->
).
done
(
data
)
->
if
showNo
if
$dropdown
.
hasClass
'js-extra-options'
data
.
unshift
(
if
showNo
id
:
0
data
.
unshift
(
title
:
'No Label'
id
:
0
)
title
:
'No Label'
)
if
showAny
data
.
unshift
(
if
showAny
isAny
:
true
data
.
unshift
(
title
:
'Any Label'
isAny
:
true
)
title
:
'Any Label'
)
if
data
.
length
>
2
data
.
splice
2
,
0
,
'divider'
if
data
.
length
>
2
data
.
splice
2
,
0
,
'divider'
callback
data
callback
data
renderRow
:
(
label
)
->
renderRow
:
(
label
)
->
if
$
.
isArray
(
selectedLabel
)
if
$
.
isArray
(
selectedLabel
)
selected
=
''
selected
=
''
...
@@ -184,16 +190,19 @@ class @LabelsSelect
...
@@ -184,16 +190,19 @@ class @LabelsSelect
.
closest
(
'.selectbox'
)
.
closest
(
'.selectbox'
)
.
find
(
'input[type="hidden"]'
)
.
find
(
'input[type="hidden"]'
)
.
val
()
.
val
()
console
.
log
'selected'
,
selected
# need inline-block here instead of show,
# need inline-block here instead of show,
# which will default to the element's style in this case inline.
# which will default to the element's style in this case inline.
selected
=
if
selected
?
then
[
selected
]
else
[
''
]
console
.
log
'selected'
,
selected
$loading
$loading
.
fadeIn
()
.
fadeIn
()
$
.
ajax
(
$
.
ajax
(
type
:
'PUT'
type
:
'PUT'
url
:
issueU
pdateU
RL
url
:
issueURL
data
:
data
:
issue
:
issue
:
label_ids
:
[
selected
]
label_ids
:
selected
).
done
(
data
)
->
).
done
(
data
)
->
$loading
.
fadeOut
()
$loading
.
fadeOut
()
$selectbox
.
hide
()
$selectbox
.
hide
()
...
...
app/assets/javascripts/milestone_select.js.coffee
View file @
3753ace9
...
@@ -21,21 +21,21 @@ class @MilestoneSelect
...
@@ -21,21 +21,21 @@ class @MilestoneSelect
$
.
ajax
(
$
.
ajax
(
url
:
milestonesUrl
url
:
milestonesUrl
).
done
(
data
)
->
).
done
(
data
)
->
if
showNo
if
$dropdown
.
hasClass
"js-extra-options"
data
.
unshift
(
if
showNo
id
:
'0'
data
.
unshift
(
title
:
'No Milestone'
id
:
'0'
)
title
:
'No Milestone'
)
if
showAny
if
showAny
data
.
unshift
(
data
.
unshift
(
isAny
:
true
isAny
:
true
title
:
'Any Milestone'
title
:
'Any Milestone'
)
)
if
data
.
length
>
2
data
.
splice
2
,
0
,
'divider'
if
data
.
length
>
2
data
.
splice
2
,
0
,
'divider'
callback
(
data
)
callback
(
data
)
filterable
:
true
filterable
:
true
search
:
search
:
...
...
app/controllers/projects/issues_controller.rb
View file @
3753ace9
...
@@ -69,7 +69,13 @@ class Projects::IssuesController < Projects::ApplicationController
...
@@ -69,7 +69,13 @@ class Projects::IssuesController < Projects::ApplicationController
@merge_requests
=
@issue
.
referenced_merge_requests
(
current_user
)
@merge_requests
=
@issue
.
referenced_merge_requests
(
current_user
)
@related_branches
=
@issue
.
related_branches
-
@merge_requests
.
map
(
&
:source_branch
)
@related_branches
=
@issue
.
related_branches
-
@merge_requests
.
map
(
&
:source_branch
)
respond_with
(
@issue
)
respond_to
do
|
format
|
format
.
html
format
.
json
do
render
json:
@issue
.
to_json
(
include:
[
:milestone
,
:labels
])
end
end
end
end
def
create
def
create
...
...
app/views/shared/issuable/_filter.html.haml
View file @
3753ace9
...
@@ -40,8 +40,7 @@
...
@@ -40,8 +40,7 @@
=
dropdown_tag
(
"Assignee"
,
options:
{
toggle_class:
"js-user-search js-update-assignee"
,
title:
"Assign to"
,
filter:
true
,
dropdown_class:
"dropdown-menu-user dropdown-menu-selectable"
,
=
dropdown_tag
(
"Assignee"
,
options:
{
toggle_class:
"js-user-search js-update-assignee"
,
title:
"Assign to"
,
filter:
true
,
dropdown_class:
"dropdown-menu-user dropdown-menu-selectable"
,
placeholder:
"Search authors"
,
data:
{
first_user:
(
current_user
.
username
if
current_user
),
null_user:
true
,
current_user:
true
,
project_id:
@project
.
id
,
field_name:
"update[assignee_id]"
}
})
placeholder:
"Search authors"
,
data:
{
first_user:
(
current_user
.
username
if
current_user
),
null_user:
true
,
current_user:
true
,
project_id:
@project
.
id
,
field_name:
"update[assignee_id]"
}
})
.filter-item.inline
.filter-item.inline
=
dropdown_tag
(
"Milestone"
,
options:
{
title:
"Assign milestone"
,
toggle_class:
'js-milestone-select'
,
filter:
true
,
dropdown_class:
"dropdown-menu-selectable dropdown-menu-milestone"
,
=
dropdown_tag
(
"Milestone"
,
options:
{
title:
"Assign milestone"
,
toggle_class:
'js-milestone-select js-extra-options'
,
filter:
true
,
dropdown_class:
"dropdown-menu-selectable dropdown-menu-milestone"
,
placeholder:
"Search milestones"
,
data:
{
show_no:
true
,
field_name:
"update[milestone_id]"
,
project_id:
@project
.
id
,
milestones:
namespace_project_milestones_path
(
@project
.
namespace
,
@project
,
:json
),
use_id:
true
}
})
placeholder:
"Search milestones"
,
data:
{
show_no:
true
,
field_name:
"update[milestone_id]"
,
project_id:
@project
.
id
,
milestones:
namespace_project_milestones_path
(
@project
.
namespace
,
@project
,
:json
),
use_id:
true
}
})
=
hidden_field_tag
'update[issues_ids]'
,
[]
=
hidden_field_tag
'update[issues_ids]'
,
[]
=
hidden_field_tag
:state_event
,
params
[
:state_event
]
=
hidden_field_tag
:state_event
,
params
[
:state_event
]
.filter-item.inline
.filter-item.inline
...
...
app/views/shared/issuable/_sidebar.html.haml
View file @
3753ace9
...
@@ -86,7 +86,7 @@
...
@@ -86,7 +86,7 @@
.light
None
.light
None
.selectbox.hide-collapsed
.selectbox.hide-collapsed
.dropdown
.dropdown
%button
.dropdown-menu-toggle.js-label-select
{
type:
"button"
,
data:
{
toggle:
"dropdown"
,
field_name:
"label_name"
,
show_no:
"true"
,
show_any:
"true"
,
selected:
params
[
:label_name
]
,
project_id:
(
@project
.
id
if
@project
),
issue_update:
namespace_project_issue_path
(
@project
.
namespace
,
@project
,
issuable
.
id
,
:json
),
labels:
(
namespace_project_labels_path
(
@project
.
namespace
,
@project
,
:json
)
if
@project
)}}
%button
.dropdown-menu-toggle.js-label-select
.js-multiselect
{
type:
"button"
,
data:
{
toggle:
"dropdown"
,
field_name:
"label_name"
,
show_no:
"true"
,
show_any:
"true"
,
selected:
issuable
.
label_names
.
join
(
","
)
,
project_id:
(
@project
.
id
if
@project
),
issue_update:
namespace_project_issue_path
(
@project
.
namespace
,
@project
,
issuable
.
id
,
:json
),
labels:
(
namespace_project_labels_path
(
@project
.
namespace
,
@project
,
:json
)
if
@project
)}}
%span
.dropdown-toggle-text
%span
.dropdown-toggle-text
Label
Label
=
icon
(
'chevron-down'
)
=
icon
(
'chevron-down'
)
...
...
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