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
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
Show 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
labelUrl
=
$dropdown
.
data
(
'labels'
)
issueUpdateURL
=
$dropdown
.
data
(
'issueUpdate'
)
selectedLabel
=
$dropdown
.
data
(
'selected'
)
if
selectedLabel
selectedLabel
=
selectedLabel
.
toString
().
split
(
','
)
if
selectedLabel
?
selectedLabel
=
selectedLabel
.
split
(
','
)
newLabelField
=
$
(
'#new_label_name'
)
newColorField
=
$
(
'#new_label_color'
)
showNo
=
$dropdown
.
data
(
'show-no'
)
...
...
@@ -17,7 +17,18 @@ class @LabelsSelect
$block
=
$selectbox
.
closest
(
'.block'
)
$value
=
$block
.
find
(
'.value'
)
$loading
=
$block
.
find
(
'.block-loading'
).
fadeOut
()
issueURLSplit
=
issueUpdateURL
.
split
(
'/'
)
if
newLabelField
.
length
$newLabelCreateButton
=
$
(
'.js-new-label-btn'
)
$colorPreview
=
$
(
'.js-dropdown-label-color-preview'
)
$newLabelError
=
$dropdown
.
parent
().
find
(
'.js-label-error'
)
$newLabelError
.
hide
()
# Suggested colors in the dropdown to chose from pre-chosen colors
$
(
'.suggest-colors-dropdown a'
).
on
'click'
,
(
e
)
->
issueURLSplit
=
issueURL
.
split
(
'/'
)
if
issueURL
?
if
issueURL
labelHTMLTemplate
=
_
.
template
(
'<% _.each(labels, function(label){ %>'
+
'<a href="'
+
...
...
@@ -31,14 +42,8 @@ class @LabelsSelect
'</a>'
+
'<% }); %>'
);
if
newLabelField
.
length
$newLabelCreateButton
=
$
(
'.js-new-label-btn'
)
$colorPreview
=
$
(
'.js-dropdown-label-color-preview'
)
$newLabelError
=
$dropdown
.
parent
().
find
(
'.js-label-error'
)
$newLabelError
.
hide
()
# Suggested colors in the dropdown to chose from pre-chosen colors
$
(
'.suggest-colors-dropdown a'
).
on
'click'
,
(
e
)
->
if
newLabelField
.
length
and
$dropdown
.
hasClass
'js-extra-options'
$
(
'.suggest-colors-dropdown a'
).
on
"click"
,
(
e
)
->
e
.
preventDefault
()
e
.
stopPropagation
()
newColorField
...
...
@@ -113,6 +118,7 @@ class @LabelsSelect
$
.
ajax
(
url
:
labelUrl
).
done
(
data
)
->
if
$dropdown
.
hasClass
'js-extra-options'
if
showNo
data
.
unshift
(
id
:
0
...
...
@@ -127,8 +133,8 @@ class @LabelsSelect
if
data
.
length
>
2
data
.
splice
2
,
0
,
'divider'
callback
data
renderRow
:
(
label
)
->
if
$
.
isArray
(
selectedLabel
)
selected
=
''
...
...
@@ -184,16 +190,19 @@ class @LabelsSelect
.
closest
(
'.selectbox'
)
.
find
(
'input[type="hidden"]'
)
.
val
()
console
.
log
'selected'
,
selected
# need inline-block here instead of show,
# which will default to the element's style in this case inline.
selected
=
if
selected
?
then
[
selected
]
else
[
''
]
console
.
log
'selected'
,
selected
$loading
.
fadeIn
()
$
.
ajax
(
type
:
'PUT'
url
:
issueU
pdateU
RL
url
:
issueURL
data
:
issue
:
label_ids
:
[
selected
]
label_ids
:
selected
).
done
(
data
)
->
$loading
.
fadeOut
()
$selectbox
.
hide
()
...
...
app/assets/javascripts/milestone_select.js.coffee
View file @
3753ace9
...
...
@@ -21,6 +21,7 @@ class @MilestoneSelect
$
.
ajax
(
url
:
milestonesUrl
).
done
(
data
)
->
if
$dropdown
.
hasClass
"js-extra-options"
if
showNo
data
.
unshift
(
id
:
'0'
...
...
@@ -35,7 +36,6 @@ class @MilestoneSelect
if
data
.
length
>
2
data
.
splice
2
,
0
,
'divider'
callback
(
data
)
filterable
:
true
search
:
...
...
app/controllers/projects/issues_controller.rb
View file @
3753ace9
...
...
@@ -69,7 +69,13 @@ class Projects::IssuesController < Projects::ApplicationController
@merge_requests
=
@issue
.
referenced_merge_requests
(
current_user
)
@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
def
create
...
...
app/views/shared/issuable/_filter.html.haml
View file @
3753ace9
...
...
@@ -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"
,
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
=
dropdown_tag
(
"Milestone"
,
options:
{
title:
"Assign milestone"
,
toggle_class:
'js-milestone-select'
,
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
}
})
=
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
}
})
=
hidden_field_tag
'update[issues_ids]'
,
[]
=
hidden_field_tag
:state_event
,
params
[
:state_event
]
.filter-item.inline
...
...
app/views/shared/issuable/_sidebar.html.haml
View file @
3753ace9
...
...
@@ -86,7 +86,7 @@
.light
None
.selectbox.hide-collapsed
.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
Label
=
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