Sha256: 1ce2c905478a285eb15f4c41545fff76f9d111fb5632d2be9cce8ed552dd836f

Contents?: true

Size: 944 Bytes

Versions: 11

Compression:

Stored size: 944 Bytes

Contents

format :html do
  def link_to_mycard text=nil
    link_to_card Auth.current.name, text,
                 id: "my-card-link", class: "nav-link #{classy('my-card')}"
  end

  def account_dropdown
    class_up "dropdown-toggle-split", "nav-link"
    split_dropdown_button account_dropdown_label do
      account_dropdown_items
    end
  end

  private

  def account_dropdown_label
    link_to_mycard
  end

  def account_dropdown_items
    [[[Auth.current, :account_settings], "Account"],
     [:signin, t("account_sign_out"), { path: { action: :delete } }]] +
      account_dropdown_roles
  end

  def account_dropdown_roles
    return [] unless special_roles?

    [dropdown_header("Roles")] + account_dropdown_role_items
  end

  def account_dropdown_role_items
    Auth.current_roles.map { |role| [role] }
  end

  def special_roles?
    Auth.current_roles.size > 1
  end

  def role_items &block
    Auth.current_roles.map(&block)
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
card-mod-layout-0.18.1 set/abstract/account_dropdown.rb
card-mod-layout-0.18.0 set/abstract/account_dropdown.rb
card-mod-layout-0.17.0 set/abstract/account_dropdown.rb
card-mod-layout-0.16.0 set/abstract/account_dropdown.rb
card-mod-layout-0.15.6 set/abstract/account_dropdown.rb
card-mod-layout-0.15.5 set/abstract/account_dropdown.rb
card-mod-layout-0.15.4 set/abstract/account_dropdown.rb
card-mod-layout-0.15.3 set/abstract/account_dropdown.rb
card-mod-layout-0.15.2.pre1 set/abstract/account_dropdown.rb
card-mod-layout-0.15.1.1 set/abstract/account_dropdown.rb
card-mod-layout-0.15.1 set/abstract/account_dropdown.rb