debian-mirror-gitlab/app/helpers/boards_helper.rb

131 lines
3.3 KiB
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2016-11-03 12:29:30 +05:30
module BoardsHelper
2018-03-17 18:26:18 +05:30
def board
@board ||= @board || @boards.first
end
2016-11-03 12:29:30 +05:30
2018-03-17 18:26:18 +05:30
def board_data
2016-11-03 12:29:30 +05:30
{
2018-03-17 18:26:18 +05:30
boards_endpoint: @boards_endpoint,
lists_endpoint: board_lists_path(board),
2016-11-03 12:29:30 +05:30
board_id: board.id,
2019-12-04 20:38:33 +05:30
disabled: (!can?(current_user, :create_non_backlog_issues, board)).to_s,
2017-08-17 22:00:37 +05:30
root_path: root_path,
2020-04-08 14:13:33 +05:30
full_path: full_path,
2018-03-17 18:26:18 +05:30
bulk_update_path: @bulk_issues_path,
2021-01-03 14:25:43 +05:30
can_update: (!!can?(current_user, :admin_issue, board)).to_s,
2019-09-30 21:07:59 +05:30
time_tracking_limit_to_hours: Gitlab::CurrentSettings.time_tracking_limit_to_hours.to_s,
2020-05-24 23:13:21 +05:30
recent_boards_endpoint: recent_boards_path,
2020-11-24 15:15:51 +05:30
parent: current_board_parent.model_name.param_key,
2021-04-17 20:07:23 +05:30
group_id: group_id,
2021-01-03 14:25:43 +05:30
labels_filter_base_path: build_issue_link_base,
labels_fetch_path: labels_fetch_path,
2021-03-11 19:13:27 +05:30
labels_manage_path: labels_manage_path,
board_type: board.to_type
2016-11-03 12:29:30 +05:30
}
end
2018-03-17 18:26:18 +05:30
2021-04-17 20:07:23 +05:30
def group_id
return @group.id if board.group_board?
@project&.group&.id
end
2020-04-08 14:13:33 +05:30
def full_path
if board.group_board?
@group.full_path
else
@project.full_path
end
end
2018-03-17 18:26:18 +05:30
def build_issue_link_base
2018-03-27 19:54:05 +05:30
if board.group_board?
"#{group_path(@board.group)}/:project_path/issues"
else
project_issues_path(@project)
end
2018-03-17 18:26:18 +05:30
end
2021-01-03 14:25:43 +05:30
def labels_fetch_path
if board.group_board?
group_labels_path(@group, format: :json, only_group_labels: true, include_ancestor_groups: true)
else
project_labels_path(@project, format: :json, include_ancestor_groups: true)
end
end
def labels_manage_path
if board.group_board?
group_labels_path(@group)
else
project_labels_path(@project)
end
end
2018-03-17 18:26:18 +05:30
def board_base_url
2018-03-27 19:54:05 +05:30
if board.group_board?
group_boards_url(@group)
else
project_boards_path(@project)
end
2018-03-17 18:26:18 +05:30
end
def multiple_boards_available?
2018-03-27 19:54:05 +05:30
current_board_parent.multiple_issue_boards_available?
2018-03-17 18:26:18 +05:30
end
def current_board_path(board)
2018-03-27 19:54:05 +05:30
@current_board_path ||= if board.group_board?
group_board_path(current_board_parent, board)
else
project_board_path(current_board_parent, board)
end
2018-03-17 18:26:18 +05:30
end
def current_board_parent
2018-03-27 19:54:05 +05:30
@current_board_parent ||= @group || @project
2018-03-17 18:26:18 +05:30
end
def can_admin_issue?
can?(current_user, :admin_issue, current_board_parent)
end
def board_list_data
2018-05-09 12:01:36 +05:30
include_descendant_groups = @group&.present?
2018-03-17 18:26:18 +05:30
{
toggle: "dropdown",
2018-12-05 23:21:45 +05:30
list_labels_path: labels_filter_path_with_defaults(only_group_labels: true, include_ancestor_groups: true),
labels: labels_filter_path_with_defaults(only_group_labels: true, include_descendant_groups: include_descendant_groups),
2018-03-17 18:26:18 +05:30
labels_endpoint: @labels_endpoint,
namespace_path: @namespace_path,
2018-03-27 19:54:05 +05:30
project_path: @project&.path,
group_path: @group&.path
2018-03-17 18:26:18 +05:30
}
end
def boards_link_text
2019-09-30 21:07:59 +05:30
if current_board_parent.multiple_issue_boards_available?
s_("IssueBoards|Boards")
else
s_("IssueBoards|Board")
end
end
def recent_boards_path
recent_project_boards_path(@project) if current_board_parent.is_a?(Project)
end
def serializer
CurrentBoardSerializer.new
end
def current_board_json
serializer.represent(board).as_json
2018-03-17 18:26:18 +05:30
end
2016-11-03 12:29:30 +05:30
end
2019-12-04 20:38:33 +05:30
BoardsHelper.prepend_if_ee('EE::BoardsHelper')