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
affed370
Commit
affed370
authored
Aug 16, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use `Issues::UpdateService` to close/reopen an issue
parent
d8fc783b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
21 deletions
+15
-21
app/services/boards/issues/move_service.rb
app/services/boards/issues/move_service.rb
+15
-21
No files found.
app/services/boards/issues/move_service.rb
View file @
affed370
...
@@ -6,36 +6,24 @@ module Boards
...
@@ -6,36 +6,24 @@ module Boards
return
false
unless
valid_move?
return
false
unless
valid_move?
update_service
.
execute
(
issue
)
update_service
.
execute
(
issue
)
reopen_service
.
execute
(
issue
)
if
moving_from
.
done?
close_service
.
execute
(
issue
)
if
moving_to
.
done?
true
end
end
private
private
def
valid_move?
def
valid_move?
moving_from
.
present?
&&
moving_to
.
present?
moving_from
_list
.
present?
&&
moving_to_list
.
present?
end
end
def
issue
def
issue
@issue
||=
project
.
issues
.
visible_to_user
(
user
).
find_by!
(
iid:
params
[
:id
])
@issue
||=
project
.
issues
.
visible_to_user
(
user
).
find_by!
(
iid:
params
[
:id
])
end
end
def
moving_from
def
moving_from_list
@moving_from
||=
board
.
lists
.
find_by
(
id:
params
[
:from_list_id
])
@moving_from_list
||=
board
.
lists
.
find_by
(
id:
params
[
:from_list_id
])
end
def
moving_to
@moving_to
||=
board
.
lists
.
find_by
(
id:
params
[
:to_list_id
])
end
end
def
close_service
def
moving_to_list
::
Issues
::
CloseService
.
new
(
project
,
user
)
@moving_to_list
||=
board
.
lists
.
find_by
(
id:
params
[
:to_list_id
])
end
def
reopen_service
::
Issues
::
ReopenService
.
new
(
project
,
user
)
end
end
def
update_service
def
update_service
...
@@ -45,18 +33,24 @@ module Boards
...
@@ -45,18 +33,24 @@ module Boards
def
issue_params
def
issue_params
{
{
add_label_ids:
add_label_ids
,
add_label_ids:
add_label_ids
,
remove_label_ids:
remove_label_ids
remove_label_ids:
remove_label_ids
,
state_event:
issue_state
}
}
end
end
def
issue_state
return
'reopen'
if
moving_from_list
.
done?
return
'close'
if
moving_to_list
.
done?
end
def
add_label_ids
def
add_label_ids
[
moving_to
.
label_id
].
compact
[
moving_to
_list
.
label_id
].
compact
end
end
def
remove_label_ids
def
remove_label_ids
label_ids
=
label_ids
=
if
moving_to
.
label?
if
moving_to
_list
.
label?
moving_from
.
label_id
moving_from
_list
.
label_id
else
else
board
.
lists
.
label
.
pluck
(
:label_id
)
board
.
lists
.
label
.
pluck
(
:label_id
)
end
end
...
...
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