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
f1291b1b
Commit
f1291b1b
authored
May 05, 2016
by
Alfredo Sumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bulk assignment implementation
parent
f02ee986
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
111 additions
and
2 deletions
+111
-2
app/assets/javascripts/dispatcher.js.coffee
app/assets/javascripts/dispatcher.js.coffee
+1
-0
app/assets/javascripts/issues-bulk-assignment.js.coffee
app/assets/javascripts/issues-bulk-assignment.js.coffee
+108
-0
app/views/shared/issuable/_filter.html.haml
app/views/shared/issuable/_filter.html.haml
+2
-2
No files found.
app/assets/javascripts/dispatcher.js.coffee
View file @
f1291b1b
...
...
@@ -17,6 +17,7 @@ class Dispatcher
switch
page
when
'projects:issues:index'
Issuable
.
init
()
new
IssuableBulkActions
()
shortcut_handler
=
new
ShortcutsNavigation
()
when
'projects:issues:show'
new
Issue
()
...
...
app/assets/javascripts/issues-bulk-assignment.js.coffee
0 → 100644
View file @
f1291b1b
class
@
IssuableBulkActions
constructor
:
(
opts
=
{})
->
# Set defaults
{
@
container
=
$
(
'.content'
)
@
form
=
@
getElement
(
'.bulk-update'
)
@
issues
=
@
getElement
(
'.issues-list .issue'
)
}
=
opts
@
bindEvents
()
getElement
:
(
selector
)
->
@
container
.
find
selector
bindEvents
:
->
@
form
.
on
'submit'
,
@
onFormSubmit
.
bind
(
@
)
onFormSubmit
:
(
e
)
->
e
.
preventDefault
()
@
submit
()
submit
:
->
_this
=
@
xhr
=
$
.
ajax
url
:
@
form
.
attr
'action'
method
:
@
form
.
attr
'method'
dataType
:
'JSON'
,
data
:
@
getFormDataAsObject
()
xhr
.
done
(
response
,
status
,
xhr
)
->
Turbolinks
.
visit
(
location
.
href
)
xhr
.
fail
->
console
.
error
'fail'
xhr
.
always
->
_this
.
onFormSubmitAlways
()
onFormSubmitAlways
:
->
@
form
.
find
(
'[type="submit"]'
).
enable
()
getSelectedIssues
:
->
@
issues
.
has
(
'.selected_issue:checked'
)
getLabelsFromSelection
:
->
labels
=
[]
@
getSelectedIssues
().
map
->
_labels
=
$
(
@
).
data
(
'labels'
)
console
.
log
_labels
if
_labels
_labels
.
map
(
labelId
)
->
labels
.
push
(
labelId
)
if
labels
.
indexOf
(
labelId
)
is
-
1
labels
###*
* Will return only labels that were marked previously and the user has unmarked
* @return {Array} Label IDs
###
getUnmarkedIndeterminedLabels
:
->
result
=
[]
labelsToKeep
=
[]
for
el
in
@
getElement
(
'.labels-filter .is-indeterminate'
)
labelsToKeep
.
push
$
(
el
).
data
(
'labelId'
)
for
id
in
@
getLabelsFromSelection
()
# Only the ones that we are not going to keep
result
.
push
(
id
)
if
labelsToKeep
.
indexOf
(
id
)
is
-
1
result
###*
* Simple form serialization, it will return just what we need
* Returns key/value pairs from form data
###
getFormDataAsObject
:
->
formData
=
update
:
issues_ids
:
@
form
.
find
(
'#update_issues_ids'
).
val
()
add_label_ids
:
[]
remove_label_ids
:
[]
for
id
in
@
getLabelsToApply
()
formData
.
update
.
add_label_ids
.
push
id
for
id
in
@
getLabelsToRemove
()
formData
.
update
.
remove_label_ids
.
push
id
formData
getLabelsToApply
:
->
labelIds
=
[]
$labels
=
@
form
.
find
(
'.labels-filter input[name="update[label_ids][]"]'
)
for
label
in
$labels
labelIds
.
push
$
(
label
).
val
()
if
label
labelIds
###*
* Just an alias of @getUnmarkedIndeterminedLabels
* @return {Array} Array of labels
###
getLabelsToRemove
:
->
@
getUnmarkedIndeterminedLabels
()
app/views/shared/issuable/_filter.html.haml
View file @
f1291b1b
...
...
@@ -31,7 +31,7 @@
-
if
controller
.
controller_name
==
'issues'
.issues_bulk_update.hide
=
form_tag
bulk_update_namespace_project_issues_path
(
@project
.
namespace
,
@project
),
method: :post
do
=
form_tag
bulk_update_namespace_project_issues_path
(
@project
.
namespace
,
@project
),
method: :post
,
class:
'bulk-update'
do
.filter-item.inline
=
dropdown_tag
(
"Status"
,
options:
{
toggle_class:
"js-issue-status"
,
title:
"Change status"
,
dropdown_class:
"dropdown-menu-status dropdown-menu-selectable"
,
data:
{
field_name:
"update[state_event]"
}
}
)
do
%ul
...
...
@@ -46,7 +46,7 @@
=
dropdown_tag
(
"Milestone"
,
options:
{
title:
"Assign milestone"
,
toggle_class:
'js-milestone-select js-extra-options js-filter-submit js-filter-bulk-update'
,
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
}
})
.filter-item.inline.labels-filter
=
render
"shared/issuable/label_dropdown"
,
classes:
' js-filter-bulk-update js-multiselect '
,
extra_options:
false
,
filter_submit:
false
,
show_footer:
false
,
extra_options:
false
,
data_options:
{
field_name:
"update[label_ids][]"
,
show_no:
false
,
show_any:
false
,
use_id:
true
}
=
render
"shared/issuable/label_dropdown"
,
classes:
' js-filter-bulk-update js-multiselect '
,
show_create:
false
,
show_footer:
false
,
extra_options:
false
,
filter_submit:
false
,
show_footer:
false
,
data_options:
{
persist_when_hide:
"true"
,
field_name:
"update[label_ids][]"
,
show_no:
false
,
show_any:
false
,
use_id:
true
}
=
hidden_field_tag
'update[issues_ids]'
,
[]
=
hidden_field_tag
:state_event
,
params
[
:state_event
]
...
...
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