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

list_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: 3c296cde51e104909b5ac736da0974e42d5ca402 (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
26
27
28
29
30
31
32
33
34
35
36
37
# frozen_string_literal: true

module Boards
  module Lists
    class ListService < Boards::BaseService
      def execute(board, create_default_lists: true)
        if create_default_lists && !board.lists.backlog.exists?
          board.lists.create(list_type: :backlog)
        end

        lists = board.lists.preload_associated_models

        return lists.id_in(params[:list_id]) if params[:list_id].present?

        list_types = unavailable_list_types_for(board)
        lists.without_types(list_types)
      end

      private

      def unavailable_list_types_for(board)
        hidden_lists_for(board)
      end

      def hidden_lists_for(board)
        hidden = []

        hidden << ::List.list_types[:backlog] if board.hide_backlog_list
        hidden << ::List.list_types[:closed] if board.hide_closed_list

        hidden
      end
    end
  end
end

Boards::Lists::ListService.prepend_if_ee('EE::Boards::Lists::ListService')