2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-09-13 17:45:13 +05:30
|
|
|
module Boards
|
|
|
|
module Issues
|
2021-03-08 18:12:59 +05:30
|
|
|
class ListService < Boards::BaseItemsListService
|
2018-11-18 11:00:15 +05:30
|
|
|
include Gitlab::Utils::StrongMemoize
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
def self.valid_params
|
|
|
|
IssuesFinder.valid_params
|
|
|
|
end
|
|
|
|
|
2021-11-11 11:23:49 +05:30
|
|
|
# It is a class method because we cannot apply it
|
|
|
|
# prior to knowing how many items should be fetched for a list.
|
|
|
|
def self.initialize_relative_positions(board, current_user, issues)
|
|
|
|
if Gitlab::Database.read_write? && !board.disabled_for?(current_user)
|
|
|
|
Issue.move_nulls_to_end(issues)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-09-13 17:45:13 +05:30
|
|
|
private
|
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
def order(items)
|
2022-07-23 23:45:48 +05:30
|
|
|
return items.order_closed_at_desc if list&.closed?
|
2021-09-04 01:27:46 +05:30
|
|
|
|
2021-11-18 22:05:49 +05:30
|
|
|
items.order_by_relative_position
|
2018-11-18 11:00:15 +05:30
|
|
|
end
|
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
def finder
|
|
|
|
IssuesFinder.new(current_user, filter_params)
|
2018-11-08 19:23:39 +05:30
|
|
|
end
|
|
|
|
|
2016-11-03 12:29:30 +05:30
|
|
|
def board
|
2018-03-17 18:26:18 +05:30
|
|
|
@board ||= parent.boards.find(params[:board_id])
|
2016-11-03 12:29:30 +05:30
|
|
|
end
|
|
|
|
|
2016-09-13 17:45:13 +05:30
|
|
|
def filter_params
|
2018-05-09 12:01:36 +05:30
|
|
|
set_scope
|
2018-12-05 23:21:45 +05:30
|
|
|
set_non_archived
|
2021-01-03 14:25:43 +05:30
|
|
|
set_issue_types
|
2016-09-13 17:45:13 +05:30
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
super
|
2016-09-13 17:45:13 +05:30
|
|
|
end
|
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
def set_scope
|
|
|
|
params[:include_subgroups] = board.group_board?
|
|
|
|
end
|
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
def set_non_archived
|
|
|
|
params[:non_archived] = parent.is_a?(Group)
|
|
|
|
end
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
def set_issue_types
|
2022-11-25 23:54:43 +05:30
|
|
|
params[:issue_types] ||= Issue::TYPES_FOR_BOARD_LIST
|
2021-01-03 14:25:43 +05:30
|
|
|
end
|
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
def item_model
|
|
|
|
Issue
|
2020-03-13 15:44:24 +05:30
|
|
|
end
|
2016-09-13 17:45:13 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-12-04 20:38:33 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
Boards::Issues::ListService.prepend_mod_with('Boards::Issues::ListService')
|