diff options
| author | Felipe Artur <felipefac@gmail.com> | 2017-08-28 18:56:49 -0300 |
|---|---|---|
| committer | Felipe Artur <felipefac@gmail.com> | 2017-08-28 18:56:49 -0300 |
| commit | f2a43ff5b7eec188ffc470649bf40d268cbdce2a (patch) | |
| tree | f9a59f5d83d883c482c9ebfe811580a0fc8f6be6 /app/helpers/boards_helper.rb | |
| parent | 5f88660a3f5d9f0de0109a3da46e81ea9024c677 (diff) | |
| download | gitlab-ce-f2a43ff5b7eec188ffc470649bf40d268cbdce2a.tar.gz | |
Group boards CE backport
Diffstat (limited to 'app/helpers/boards_helper.rb')
| -rw-r--r-- | app/helpers/boards_helper.rb | 78 |
1 files changed, 72 insertions, 6 deletions
diff --git a/app/helpers/boards_helper.rb b/app/helpers/boards_helper.rb index 8b33c362a9c..062c3dcf164 100644 --- a/app/helpers/boards_helper.rb +++ b/app/helpers/boards_helper.rb @@ -1,15 +1,81 @@ module BoardsHelper - def board_data - board = @board || @boards.first + def board + @board ||= @board || @boards.first + end + def board_data { - endpoint: project_boards_path(@project), + boards_endpoint: @boards_endpoint, + lists_endpoint: board_lists_url(board), board_id: board.id, - disabled: "#{!can?(current_user, :admin_list, @project)}", - issue_link_base: project_issues_path(@project), + board_milestone_title: board&.milestone&.title, + disabled: "#{!can?(current_user, :admin_list, current_board_parent)}", + issue_link_base: build_issue_link_base, root_path: root_path, - bulk_update_path: bulk_update_project_issues_path(@project), + bulk_update_path: @bulk_issues_path, default_avatar: image_path(default_avatar) } end + + def build_issue_link_base + project_issues_path(@project) + end + + def current_board_json + board = @board || @boards.first + + board.to_json( + only: [:id, :name, :milestone_id], + include: { + milestone: { only: [:title] } + } + ) + end + + def board_base_url + project_boards_path(@project) + end + + def multiple_boards_available? + current_board_parent.multiple_issue_boards_available?(current_user) + end + + def board_path(board) + @board_path ||= project_board_path(current_board_parent, board) + end + + def current_board_parent + @current_board_parent ||= @project + 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, + project_path: @project&.try(:path) + } + 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', + project_id: @project&.try(:id), + null_user: 'true', + multi_select: 'true', + 'dropdown-header': dropdown_options[:data][:'dropdown-header'], + 'max-select': dropdown_options[:data][:'max-select'] + } + end end |
