Sha256: 8af73164c529434b99288ce86767f72f80191ac30078278c85d4a60235f8c28e

Contents?: true

Size: 811 Bytes

Versions: 3

Compression:

Stored size: 811 Bytes

Contents

# frozen_string_literal: true

class AppMenuList < ApplicationMenuList
  has_menu :navigations,
           iri_base: '/menus',
           menus: -> { navigation_links }
  has_menu :user,
           menus: -> { user_menu_items }

  def iri_template
    @iri_template ||= URITemplate.new('/menus{#fragment}')
  end

  private

  def navigation_links
    items = []
    items << menu_item(
      :home,
      label: I18n.t('menus.home'),
      href: LinkedRails.iri,
      image: 'fa-home'
    )
    items
  end

  def user_menu_items
    return [] if user_context.guest?

    [user_menu_sign_out_item]
  end

  def user_menu_sign_out_item
    menu_item(
      :signout,
      action: Vocab.libro['actions/logout'],
      label: I18n.t('menus.sign_out'),
      href: LinkedRails.iri(path: :logout)
    )
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
linked_rails-0.0.3 lib/generators/linked_rails/install/templates/app_menu_list.rb
linked_rails-0.0.2 lib/generators/linked_rails/install/templates/app_menu_list.rb
linked_rails-0.0.1 lib/generators/linked_rails/install/templates/app_menu_list.rb