diff options
Diffstat (limited to 'app/services/boards')
-rw-r--r-- | app/services/boards/issues/list_service.rb | 20 | ||||
-rw-r--r-- | app/services/boards/issues/move_service.rb | 2 | ||||
-rw-r--r-- | app/services/boards/lists/create_service.rb | 41 | ||||
-rw-r--r-- | app/services/boards/lists/list_service.rb | 3 |
4 files changed, 47 insertions, 19 deletions
diff --git a/app/services/boards/issues/list_service.rb b/app/services/boards/issues/list_service.rb index e08509b84db..140420a32bd 100644 --- a/app/services/boards/issues/list_service.rb +++ b/app/services/boards/issues/list_service.rb @@ -45,6 +45,12 @@ module Boards # rubocop: enable CodeReuse/ActiveRecord def filter(issues) + # when grouping board issues by epics (used in board swimlanes) + # we need to get all issues in the board + # TODO: ignore hidden columns - + # https://gitlab.com/gitlab-org/gitlab/-/issues/233870 + return issues if params[:all_lists] + issues = without_board_labels(issues) unless list&.movable? || list&.closed? issues = with_list_label(issues) if list&.label? issues @@ -55,9 +61,17 @@ module Boards end def list - return @list if defined?(@list) + return unless params.key?(:id) + + strong_memoize(:list) do + id = params[:id] - @list = board.lists.find(params[:id]) if params.key?(:id) + if board.lists.loaded? + board.lists.find { |l| l.id == id } + else + board.lists.find(id) + end + end end def filter_params @@ -79,6 +93,8 @@ module Boards end def set_state + return if params[:all_lists] + params[:state] = list && list.closed? ? 'closed' : 'opened' end diff --git a/app/services/boards/issues/move_service.rb b/app/services/boards/issues/move_service.rb index 9e3c84d03ec..14e8683ebdf 100644 --- a/app/services/boards/issues/move_service.rb +++ b/app/services/boards/issues/move_service.rb @@ -130,7 +130,7 @@ module Boards def move_between_ids(move_params) ids = [move_params[:move_after_id], move_params[:move_before_id]] .map(&:to_i) - .map { |m| m.positive? ? m : nil } + .map { |m| m > 0 ? m : nil } ids.any? ? ids : nil end diff --git a/app/services/boards/lists/create_service.rb b/app/services/boards/lists/create_service.rb index 6f9a063cb16..9c7a165776e 100644 --- a/app/services/boards/lists/create_service.rb +++ b/app/services/boards/lists/create_service.rb @@ -7,34 +7,39 @@ module Boards def execute(board) List.transaction do - target = target(board) - position = next_position(board) - create_list(board, type, target, position) + case type + when :backlog + create_backlog(board) + else + target = target(board) + position = next_position(board) + + create_list(board, type, target, position) + end end end private def type - :label + # We don't ever expect to have more than one list + # type param at once. + if params.key?('backlog') + :backlog + else + :label + end end def target(board) strong_memoize(:target) do - available_labels_for(board).find(params[:label_id]) + available_labels.find(params[:label_id]) end end - def available_labels_for(board) - options = { include_ancestor_groups: true } - - if board.group_board? - options.merge!(group_id: parent.id, only_group_labels: true) - else - options[:project_id] = parent.id - end - - LabelsFinder.new(current_user, options).execute + def available_labels + ::Labels::AvailableLabelsService.new(current_user, parent, {}) + .available_labels end def next_position(board) @@ -49,6 +54,12 @@ module Boards def create_list_attributes(type, target, position) { type => target, list_type: type, position: position } end + + def create_backlog(board) + return board.lists.backlog.first if board.lists.backlog.exists? + + board.lists.create(list_type: :backlog, position: nil) + end end end end diff --git a/app/services/boards/lists/list_service.rb b/app/services/boards/lists/list_service.rb index 07ce58b6851..e4c789c4597 100644 --- a/app/services/boards/lists/list_service.rb +++ b/app/services/boards/lists/list_service.rb @@ -8,7 +8,8 @@ module Boards board.lists.create(list_type: :backlog) end - board.lists.preload_associated_models + lists = board.lists.preload_associated_models + params[:list_id].present? ? lists.where(id: params[:list_id]) : lists # rubocop: disable CodeReuse/ActiveRecord end end end |