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,
|
2018-03-17 18:26:18 +05:30
|
|
|
disabled: "#{!can?(current_user, :admin_list, current_board_parent)}",
|
|
|
|
issue_link_base: build_issue_link_base,
|
2017-08-17 22:00:37 +05:30
|
|
|
root_path: root_path,
|
2018-03-17 18:26:18 +05:30
|
|
|
bulk_update_path: @bulk_issues_path,
|
2017-08-17 22:00:37 +05:30
|
|
|
default_avatar: image_path(default_avatar)
|
2016-11-03 12:29:30 +05:30
|
|
|
}
|
|
|
|
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
|
|
|
|
|
|
|
|
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 board_sidebar_user_data
|
2019-07-31 22:56:46 +05:30
|
|
|
dropdown_options = assignees_dropdown_options('issue')
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
{
|
|
|
|
toggle: 'dropdown',
|
|
|
|
field_name: 'issue[assignee_ids][]',
|
|
|
|
first_user: current_user&.username,
|
|
|
|
current_user: 'true',
|
2018-03-27 19:54:05 +05:30
|
|
|
project_id: @project&.id,
|
|
|
|
group_id: @group&.id,
|
2018-03-17 18:26:18 +05:30
|
|
|
null_user: 'true',
|
|
|
|
multi_select: 'true',
|
|
|
|
'dropdown-header': dropdown_options[:data][:'dropdown-header'],
|
|
|
|
'max-select': dropdown_options[:data][:'max-select']
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def boards_link_text
|
|
|
|
s_("IssueBoards|Board")
|
|
|
|
end
|
2016-11-03 12:29:30 +05:30
|
|
|
end
|