diff options
Diffstat (limited to 'app/services/boards')
-rw-r--r-- | app/services/boards/issues/list_service.rb | 2 | ||||
-rw-r--r-- | app/services/boards/lists/generate_service.rb | 39 | ||||
-rw-r--r-- | app/services/boards/lists/list_service.rb | 20 |
3 files changed, 13 insertions, 48 deletions
diff --git a/app/services/boards/issues/list_service.rb b/app/services/boards/issues/list_service.rb index 465025ef2e9..fcaa74555ca 100644 --- a/app/services/boards/issues/list_service.rb +++ b/app/services/boards/issues/list_service.rb @@ -50,7 +50,7 @@ module Boards end def set_issue_types - params[:issue_types] ||= Issue::TYPES_FOR_LIST + params[:issue_types] ||= Issue::TYPES_FOR_BOARD_LIST end def item_model diff --git a/app/services/boards/lists/generate_service.rb b/app/services/boards/lists/generate_service.rb deleted file mode 100644 index d74320e92a3..00000000000 --- a/app/services/boards/lists/generate_service.rb +++ /dev/null @@ -1,39 +0,0 @@ -# frozen_string_literal: true - -module Boards - module Lists - class GenerateService < Boards::BaseService - def execute(board) - return false unless board.lists.movable.empty? - - List.transaction do - label_params.each do |params| - response = create_list(board, params) - - raise ActiveRecord::Rollback unless response.success? - end - end - - true - end - - private - - def create_list(board, params) - label = find_or_create_label(params) - Lists::CreateService.new(parent, current_user, label_id: label.id).execute(board) - end - - def find_or_create_label(params) - ::Labels::FindOrCreateService.new(current_user, parent, params).execute - end - - def label_params - [ - { name: 'To Do', color: '#F0AD4E' }, - { name: 'Doing', color: '#5CB85C' } - ] - end - end - end -end diff --git a/app/services/boards/lists/list_service.rb b/app/services/boards/lists/list_service.rb index e81ef467a4e..cf15db4314c 100644 --- a/app/services/boards/lists/list_service.rb +++ b/app/services/boards/lists/list_service.rb @@ -9,23 +9,27 @@ module Boards end lists = board.lists.preload_associated_models + lists = lists.with_types(available_list_types_for(board)) return lists.id_in(params[:list_id]) if params[:list_id].present? - list_types = unavailable_list_types_for(board) - lists.without_types(list_types) + lists end private - def unavailable_list_types_for(board) - hidden_lists_for(board) + def available_list_types_for(board) + licensed_list_types(board) + visible_lists(board) end - def hidden_lists_for(board) - [].tap do |hidden| - hidden << ::List.list_types[:backlog] if board.hide_backlog_list? - hidden << ::List.list_types[:closed] if board.hide_closed_list? + 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? end end end |