Sha256: f818d7e0e6a0a1d7b24fa146345005e36ac3e53d30ee2a7076987473908d6e15

Contents?: true

Size: 1.32 KB

Versions: 58

Compression:

Stored size: 1.32 KB

Contents

require 'pagy'
module CmAdmin
  module ViewHelpers
    module NavigationHelper
      include Pagy::Frontend
      def navigation_links(navigation_type)
        CmAdmin.config.cm_admin_models.map { |model|
          if model.is_visible_on_sidebar
            path = CmAdmin::Engine.mount_path + '/' + model.name.underscore.pluralize
            if policy([:cm_admin, model.name.classify.constantize]).index?
              if navigation_type == "sidebar"
                content_tag(:a, href: path) do
                  content_tag(:div, class: 'menu-item') do
                    content_tag(:span, class: 'menu-icon') do
                      concat tag.i class: "#{model.icon_name}"
                    end +
                    model.name.titleize.pluralize
                  end
                end
              elsif navigation_type == "quick_links"
                content_tag(:a, href: path, class: 'visible') do
                  content_tag(:div, class: 'result-item') do
                    content_tag(:span) do
                      concat tag.i class: "#{model.icon_name}"
                    end +
                    content_tag(:span) do
                      model.name
                    end
                  end
                end
              end
            end
          end
        }.join.html_safe
      end
    end
  end
end

Version data entries

58 entries across 58 versions & 1 rubygems

Version Path
cm-admin-1.5.33 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.5.32 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.5.31 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.5.30 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.5.29 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.5.28 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.5.10 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.5.27 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.5.26 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.5.25 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.5.23 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.5.22 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.5.21 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.5.20 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.5.11 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.5.9 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.5.8 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.5.7 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.5.6 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.5.1 lib/cm_admin/view_helpers/navigation_helper.rb