BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
81a21c94
Commit
81a21c94
authored
Apr 29, 2016
by
Sean McGivern
Committed by
Alfredo Sumaran
Jun 03, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: allow adding and removing labels in bulk
parent
e42f88ca
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
8 deletions
+37
-8
issues_controller.rb
app/controllers/projects/issues_controller.rb
+3
-1
issuable_base_service.rb
app/services/issuable_base_service.rb
+31
-4
bulk_update_service.rb
app/services/issues/bulk_update_service.rb
+3
-3
No files found.
app/controllers/projects/issues_controller.rb
View file @
81a21c94
...
...
@@ -217,7 +217,9 @@ class Projects::IssuesController < Projects::ApplicationController
:assignee_id
,
:milestone_id
,
:state_event
,
label_ids:
[]
label_ids:
[],
add_label_ids:
[],
remove_label_ids:
[]
)
end
end
app/services/issuable_base_service.rb
View file @
81a21c94
...
...
@@ -45,6 +45,8 @@ class IssuableBaseService < BaseService
unless
can?
(
current_user
,
ability
,
project
)
params
.
delete
(
:milestone_id
)
params
.
delete
(
:add_label_ids
)
params
.
delete
(
:remove_label_ids
)
params
.
delete
(
:label_ids
)
params
.
delete
(
:assignee_id
)
end
...
...
@@ -67,10 +69,35 @@ class IssuableBaseService < BaseService
end
def
filter_labels
return
if
params
[
:label_ids
].
to_a
.
empty?
if
params
[
:add_label_ids
].
present?
||
params
[
:remove_label_ids
].
present?
params
.
delete
(
:label_ids
)
filter_labels_by_name
([
:add_label_ids
,
:remove_label_ids
])
else
filter_labels_by_name
([
:label_ids
])
end
end
def
filter_labels_by_name
(
keys
)
keys
.
each
do
|
key
|
return
if
params
[
key
].
to_a
.
empty?
params
[
key
]
=
project
.
labels
.
where
(
id:
params
[
key
]).
pluck
(
:id
)
end
end
def
update_issuable
(
issuable
,
attributes
)
issuable
.
with_transaction_returning_status
do
add_label_ids
=
attributes
.
delete
(
:add_label_ids
)
remove_label_ids
=
attributes
.
delete
(
:remove_label_ids
)
params
[
:label_ids
]
=
project
.
labels
.
where
(
id:
params
[
:label_ids
]).
pluck
(
:id
)
issuable
.
label_ids
|=
add_label_ids
if
add_label_ids
issuable
.
label_ids
-=
remove_label_ids
if
remove_label_ids
issuable
.
assign_attributes
(
attributes
)
issuable
.
save
end
end
def
update
(
issuable
)
...
...
@@ -78,7 +105,7 @@ class IssuableBaseService < BaseService
filter_params
old_labels
=
issuable
.
labels
.
to_a
if
params
.
present?
&&
issuable
.
update_attributes
(
params
.
merge
(
updated_by:
current_user
))
if
params
.
present?
&&
update_issuable
(
issuable
,
params
.
merge
(
updated_by:
current_user
))
issuable
.
reset_events_cache
handle_common_system_notes
(
issuable
,
old_labels:
old_labels
)
handle_changes
(
issuable
,
old_labels:
old_labels
)
...
...
app/services/issues/bulk_update_service.rb
View file @
81a21c94
...
...
@@ -4,9 +4,9 @@ module Issues
issues_ids
=
params
.
delete
(
:issues_ids
).
split
(
","
)
issue_params
=
params
issue_params
.
delete
(
:state_event
)
unless
issue_params
[
:state_event
].
present?
issue_params
.
delete
(
:milestone_id
)
unless
issue_params
[
:milestone_id
].
present?
issue_params
.
delete
(
:assignee_id
)
unless
issue_params
[
:assignee_id
].
present?
[
:state_event
,
:milestone_id
,
:assignee_id
,
:label_ids
,
:add_label_ids
,
:remove_label_ids
].
each
do
|
key
|
issue_params
.
delete
(
key
)
unless
issue_params
[
key
].
present?
end
issues
=
Issue
.
where
(
id:
issues_ids
)
issues
.
each
do
|
issue
|
...
...
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