debian-mirror-gitlab/app/services/boards/lists/list_service.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

40 lines
1 KiB
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2016-11-03 12:29:30 +05:30
module Boards
module Lists
2018-03-17 18:26:18 +05:30
class ListService < Boards::BaseService
2020-05-24 23:13:21 +05:30
def execute(board, create_default_lists: true)
if create_default_lists && !board.lists.backlog.exists?
board.lists.create(list_type: :backlog)
end
2017-09-10 17:25:29 +05:30
2020-10-24 23:57:45 +05:30
lists = board.lists.preload_associated_models
2022-11-25 23:54:43 +05:30
lists = lists.with_types(available_list_types_for(board))
2021-04-17 20:07:23 +05:30
return lists.id_in(params[:list_id]) if params[:list_id].present?
2022-11-25 23:54:43 +05:30
lists
2021-04-17 20:07:23 +05:30
end
private
2022-11-25 23:54:43 +05:30
def available_list_types_for(board)
licensed_list_types(board) + visible_lists(board)
2021-04-17 20:07:23 +05:30
end
2022-11-25 23:54:43 +05:30
def licensed_list_types(board)
[List.list_types[:label]]
end
def visible_lists(board)
[].tap do |visible|
visible << ::List.list_types[:backlog] unless board.hide_backlog_list?
visible << ::List.list_types[:closed] unless board.hide_closed_list?
2021-04-29 21:17:54 +05:30
end
2016-11-03 12:29:30 +05:30
end
end
end
end
2019-12-04 20:38:33 +05:30
2021-06-08 01:23:25 +05:30
Boards::Lists::ListService.prepend_mod_with('Boards::Lists::ListService')