boards_helper.rb 1.75 KB
Newer Older
1
module BoardsHelper
Felipe's avatar
Felipe committed
2 3 4
  def board
    @board ||= @board || @boards.first
  end
5

Felipe's avatar
Felipe committed
6
  def board_data
7
    {
Felipe's avatar
Felipe committed
8 9
      boards_endpoint: @boards_endpoint,
      lists_endpoint: board_lists_url(board),
10
      board_id: board.id,
Felipe's avatar
Felipe committed
11 12
      disabled: "#{!can?(current_user, :admin_list, current_board_parent)}",
      issue_link_base: build_issue_link_base,
13
      root_path: root_path,
Felipe's avatar
Felipe committed
14
      bulk_update_path: @bulk_issues_path,
15
      default_avatar: image_path(default_avatar)
16 17
    }
  end
Felipe's avatar
Felipe committed
18 19 20 21 22 23 24 25 26 27 28 29 30

  def build_issue_link_base
    project_issues_path(@project)
  end

  def board_base_url
    project_boards_path(@project)
  end

  def multiple_boards_available?
    current_board_parent.multiple_issue_boards_available?(current_user)
  end

Felipe's avatar
Felipe committed
31 32
  def current_board_path(board)
    @current_board_path ||= project_board_path(current_board_parent, board)
Felipe's avatar
Felipe committed
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
  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
69 70

  def boards_link_text
71
    s_("IssueBoards|Board")
72
  end
73
end