2018-07-16 12:31:01 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-10-05 12:54:46 -04:00
|
|
|
module Boards
|
|
|
|
module Lists
|
2017-08-31 13:48:57 -04:00
|
|
|
class ListService < Boards::BaseService
|
2020-04-21 11:21:10 -04:00
|
|
|
def execute(board, create_default_lists: true)
|
|
|
|
if create_default_lists && !board.lists.backlog.exists?
|
|
|
|
board.lists.create(list_type: :backlog)
|
|
|
|
end
|
2017-06-06 07:59:50 -04:00
|
|
|
|
2020-07-31 14:09:37 -04:00
|
|
|
lists = board.lists.preload_associated_models
|
2021-02-18 19:11:06 -05:00
|
|
|
|
|
|
|
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)
|
2021-03-17 17:11:29 -04:00
|
|
|
[].tap do |hidden|
|
|
|
|
hidden << ::List.list_types[:backlog] if board.hide_backlog_list?
|
|
|
|
hidden << ::List.list_types[:closed] if board.hide_closed_list?
|
|
|
|
end
|
2016-10-05 12:54:46 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-09-13 09:26:31 -04:00
|
|
|
|
2021-05-11 17:10:21 -04:00
|
|
|
Boards::Lists::ListService.prepend_mod_with('Boards::Lists::ListService')
|