2016-10-12 07:50:47 -04:00
|
|
|
module BoardsHelper
|
2017-08-28 17:56:49 -04:00
|
|
|
def board
|
|
|
|
@board ||= @board || @boards.first
|
|
|
|
end
|
2016-10-12 07:50:47 -04:00
|
|
|
|
2017-08-28 17:56:49 -04:00
|
|
|
def board_data
|
2016-10-12 07:50:47 -04:00
|
|
|
{
|
2017-08-28 17:56:49 -04:00
|
|
|
boards_endpoint: @boards_endpoint,
|
2017-12-03 13:46:07 -05:00
|
|
|
lists_endpoint: board_lists_path(board),
|
2016-10-12 07:50:47 -04:00
|
|
|
board_id: board.id,
|
2017-08-28 17:56:49 -04:00
|
|
|
disabled: "#{!can?(current_user, :admin_list, current_board_parent)}",
|
|
|
|
issue_link_base: build_issue_link_base,
|
2017-01-31 05:39:44 -05:00
|
|
|
root_path: root_path,
|
2017-08-28 17:56:49 -04:00
|
|
|
bulk_update_path: @bulk_issues_path,
|
2017-04-28 06:27:52 -04:00
|
|
|
default_avatar: image_path(default_avatar)
|
2016-10-12 07:50:47 -04:00
|
|
|
}
|
|
|
|
end
|
2017-08-28 17:56:49 -04:00
|
|
|
|
|
|
|
def build_issue_link_base
|
2018-02-19 14:06:16 -05:00
|
|
|
if board.group_board?
|
|
|
|
"#{group_path(@board.group)}/:project_path/issues"
|
|
|
|
else
|
|
|
|
project_issues_path(@project)
|
|
|
|
end
|
2017-08-28 17:56:49 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def board_base_url
|
2018-02-19 14:06:16 -05:00
|
|
|
if board.group_board?
|
|
|
|
group_boards_url(@group)
|
|
|
|
else
|
|
|
|
project_boards_path(@project)
|
|
|
|
end
|
2017-08-28 17:56:49 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def multiple_boards_available?
|
2018-02-19 14:06:16 -05:00
|
|
|
current_board_parent.multiple_issue_boards_available?
|
2017-08-28 17:56:49 -04:00
|
|
|
end
|
|
|
|
|
2017-09-04 17:36:31 -04:00
|
|
|
def current_board_path(board)
|
2018-03-05 09:39:24 -05:00
|
|
|
@current_board_path ||= if board.group_board?
|
|
|
|
group_board_path(current_board_parent, board)
|
|
|
|
else
|
|
|
|
project_board_path(current_board_parent, board)
|
|
|
|
end
|
2017-08-28 17:56:49 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def current_board_parent
|
2018-02-19 14:06:16 -05:00
|
|
|
@current_board_parent ||= @group || @project
|
2017-08-28 17:56:49 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def can_admin_issue?
|
|
|
|
can?(current_user, :admin_issue, current_board_parent)
|
|
|
|
end
|
|
|
|
|
|
|
|
def board_list_data
|
|
|
|
{
|
|
|
|
toggle: "dropdown",
|
|
|
|
list_labels_path: labels_filter_path(true),
|
|
|
|
labels: labels_filter_path(true),
|
|
|
|
labels_endpoint: @labels_endpoint,
|
|
|
|
namespace_path: @namespace_path,
|
2018-02-19 14:06:16 -05:00
|
|
|
project_path: @project&.path,
|
|
|
|
group_path: @group&.path
|
2017-08-28 17:56:49 -04:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def board_sidebar_user_data
|
|
|
|
dropdown_options = issue_assignees_dropdown_options
|
|
|
|
|
|
|
|
{
|
|
|
|
toggle: 'dropdown',
|
|
|
|
field_name: 'issue[assignee_ids][]',
|
|
|
|
first_user: current_user&.username,
|
|
|
|
current_user: 'true',
|
2018-02-19 14:06:16 -05:00
|
|
|
project_id: @project&.id,
|
|
|
|
group_id: @group&.id,
|
2017-08-28 17:56:49 -04:00
|
|
|
null_user: 'true',
|
|
|
|
multi_select: 'true',
|
|
|
|
'dropdown-header': dropdown_options[:data][:'dropdown-header'],
|
|
|
|
'max-select': dropdown_options[:data][:'max-select']
|
|
|
|
}
|
|
|
|
end
|
2017-09-13 06:08:48 -04:00
|
|
|
|
|
|
|
def boards_link_text
|
2017-09-25 04:55:21 -04:00
|
|
|
s_("IssueBoards|Board")
|
2017-09-13 06:08:48 -04:00
|
|
|
end
|
2016-10-12 07:50:47 -04:00
|
|
|
end
|