Welcome to mirror list, hosted at ThFree Co, Russian Federation.

destroy_service.rb « lists « boards « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 25da3bfb56dd7678af2e17dd62164be65e976e89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
module Boards
  module Lists
    class DestroyService < Boards::BaseService
      def execute(list)
        return false unless list.destroyable?

        list.with_lock do
          decrement_higher_lists(list)
          remove_list(list)
        end
      end

      private

      def decrement_higher_lists(list)
        board.lists.movable.where('position > ?',  list.position)
                   .update_all('position = position - 1')
      end

      def remove_list(list)
        list.destroy
      end
    end
  end
end