Sha256: 30e6ccb9e7361c113777acc65f0c9b6bb0616ec649fadf8d533a878acacc6bdc

Contents?: true

Size: 1.08 KB

Versions: 46

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

module Decidim
  # This cell renders a link in the top navbar
  # so admins can easily manage data without having to look for it at the admin
  # panel when they're at a public page.
  # example use:
  #   <%= cell("decidim/navbar_admin_link", { link_url: link_url, link_options: link_options }) %>
  #
  class NavbarAdminLinkCell < Decidim::ViewModel
    include Decidim::IconHelper

    def show
      render if link_url
    end

    private

    def link_url
      return if model[:link_url].blank?

      model[:link_url]
    end

    def link_icon_name
      return "pencil" if model[:link_options][:icon].blank?

      model[:link_options][:icon]
    end

    def link_name
      return t("layouts.decidim.edit_link.edit") if model[:link_options][:name].blank?

      model[:link_options][:name]
    end

    def link_class
      return if model[:link_options][:class].blank?

      model[:link_options][:class]
    end

    def icon_options
      options = model[:icon_options].presence || {}

      options.merge(role: "img", "aria-hidden": true)
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
decidim-core-0.27.9 app/cells/decidim/navbar_admin_link_cell.rb
decidim-core-0.27.8 app/cells/decidim/navbar_admin_link_cell.rb
decidim-core-0.27.7 app/cells/decidim/navbar_admin_link_cell.rb
decidim-core-0.27.6 app/cells/decidim/navbar_admin_link_cell.rb
decidim-core-0.26.10 app/cells/decidim/navbar_admin_link_cell.rb
decidim-core-0.26.9 app/cells/decidim/navbar_admin_link_cell.rb
decidim-core-0.27.5 app/cells/decidim/navbar_admin_link_cell.rb
decidim-core-0.26.8 app/cells/decidim/navbar_admin_link_cell.rb
decidim-core-0.27.4 app/cells/decidim/navbar_admin_link_cell.rb
decidim-core-0.27.3 app/cells/decidim/navbar_admin_link_cell.rb
decidim-core-0.26.7 app/cells/decidim/navbar_admin_link_cell.rb
decidim-core-0.26.5 app/cells/decidim/navbar_admin_link_cell.rb
decidim-core-0.27.2 app/cells/decidim/navbar_admin_link_cell.rb
decidim-core-0.27.1 app/cells/decidim/navbar_admin_link_cell.rb
decidim-core-0.26.4 app/cells/decidim/navbar_admin_link_cell.rb
decidim-core-0.27.0 app/cells/decidim/navbar_admin_link_cell.rb
decidim-core-0.26.3 app/cells/decidim/navbar_admin_link_cell.rb
decidim-core-0.27.0.rc2 app/cells/decidim/navbar_admin_link_cell.rb
decidim-core-0.27.0.rc1 app/cells/decidim/navbar_admin_link_cell.rb
decidim-core-0.26.2 app/cells/decidim/navbar_admin_link_cell.rb