diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-02-01 21:41:01 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-02-17 14:29:16 +0300 |
commit | ac868482a7780a332045ef270a409ff70bcf8efd (patch) | |
tree | 99ff605262028f08718f04ac0c9e42c516d38693 /app/services/boards/issues/move_service.rb | |
parent | 5d8f5328baca93b9134f10ae593e71834578a9f8 (diff) |
Allow issues in boards to be ordered
Diffstat (limited to 'app/services/boards/issues/move_service.rb')
-rw-r--r-- | app/services/boards/issues/move_service.rb | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/app/services/boards/issues/move_service.rb b/app/services/boards/issues/move_service.rb index 96554a92a02..7c0df55e9b6 100644 --- a/app/services/boards/issues/move_service.rb +++ b/app/services/boards/issues/move_service.rb @@ -3,7 +3,7 @@ module Boards class MoveService < BaseService def execute(issue) return false unless can?(current_user, :update_issue, issue) - return false unless valid_move? + return false if issue_params.empty? update_service.execute(issue) end @@ -14,7 +14,7 @@ module Boards @board ||= project.boards.find(params[:board_id]) end - def valid_move? + def move_between_lists? moving_from_list.present? && moving_to_list.present? && moving_from_list != moving_to_list end @@ -32,11 +32,19 @@ module Boards end def issue_params - { - add_label_ids: add_label_ids, - remove_label_ids: remove_label_ids, - state_event: issue_state - } + attrs = {} + + if move_between_lists? + attrs.merge!( + add_label_ids: add_label_ids, + remove_label_ids: remove_label_ids, + state_event: issue_state, + ) + end + + attrs[:move_between_iids] = move_between_iids if move_between_iids + + attrs end def issue_state @@ -58,6 +66,13 @@ module Boards Array(label_ids).compact end + + def move_between_iids + move_after_iid = params[:move_after_iid] + move_before_iid = params[:move_before_iid] + return unless move_after_iid || move_before_iid + [move_after_iid, move_before_iid] + end end end end |