Sha256: 7583fb966213634fdfd191622cc81ab0313f5c3efcc47bb275516658508ed5a8

Contents?: true

Size: 994 Bytes

Versions: 7

Compression:

Stored size: 994 Bytes

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 are 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-line" 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 icon_options
      options = model[:icon_options].presence || {}

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
decidim-core-0.28.4 app/cells/decidim/navbar_admin_link_cell.rb
decidim-core-0.28.3 app/cells/decidim/navbar_admin_link_cell.rb
decidim-core-0.28.2 app/cells/decidim/navbar_admin_link_cell.rb
decidim-core-0.28.1 app/cells/decidim/navbar_admin_link_cell.rb
decidim-core-0.28.0 app/cells/decidim/navbar_admin_link_cell.rb
decidim-core-0.28.0.rc5 app/cells/decidim/navbar_admin_link_cell.rb
decidim-core-0.28.0.rc4 app/cells/decidim/navbar_admin_link_cell.rb