summaryrefslogtreecommitdiff
path: root/app/services/boards
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-08-16 00:15:30 -0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-08-17 12:58:59 -0300
commitaffed37065974991f4c578993d34ec1608560ad9 (patch)
treed1062f7309ff3fdd1fdacdfaf462c3469185b264 /app/services/boards
parentd8fc783bb9438434d157ca07b9dc033e7c4115df (diff)
downloadgitlab-ce-affed37065974991f4c578993d34ec1608560ad9.tar.gz
Use `Issues::UpdateService` to close/reopen an issue
Diffstat (limited to 'app/services/boards')
-rw-r--r--app/services/boards/issues/move_service.rb36
1 files changed, 15 insertions, 21 deletions
diff --git a/app/services/boards/issues/move_service.rb b/app/services/boards/issues/move_service.rb
index 7455314450b..97fe099ccb5 100644
--- a/app/services/boards/issues/move_service.rb
+++ b/app/services/boards/issues/move_service.rb
@@ -6,36 +6,24 @@ module Boards
return false unless valid_move?
update_service.execute(issue)
- reopen_service.execute(issue) if moving_from.done?
- close_service.execute(issue) if moving_to.done?
-
- true
end
private
def valid_move?
- moving_from.present? && moving_to.present?
+ moving_from_list.present? && moving_to_list.present?
end
def issue
@issue ||= project.issues.visible_to_user(user).find_by!(iid: params[:id])
end
- def moving_from
- @moving_from ||= board.lists.find_by(id: params[:from_list_id])
- end
-
- def moving_to
- @moving_to ||= board.lists.find_by(id: params[:to_list_id])
+ def moving_from_list
+ @moving_from_list ||= board.lists.find_by(id: params[:from_list_id])
end
- def close_service
- ::Issues::CloseService.new(project, user)
- end
-
- def reopen_service
- ::Issues::ReopenService.new(project, user)
+ def moving_to_list
+ @moving_to_list ||= board.lists.find_by(id: params[:to_list_id])
end
def update_service
@@ -45,18 +33,24 @@ module Boards
def issue_params
{
add_label_ids: add_label_ids,
- remove_label_ids: remove_label_ids
+ remove_label_ids: remove_label_ids,
+ state_event: issue_state
}
end
+ def issue_state
+ return 'reopen' if moving_from_list.done?
+ return 'close' if moving_to_list.done?
+ end
+
def add_label_ids
- [moving_to.label_id].compact
+ [moving_to_list.label_id].compact
end
def remove_label_ids
label_ids =
- if moving_to.label?
- moving_from.label_id
+ if moving_to_list.label?
+ moving_from_list.label_id
else
board.lists.label.pluck(:label_id)
end