Sha256: 047e0d4779ca54694ebe47846bf4df6cc9efe29f135f6c12b51bd6d60b7137bf

Contents?: true

Size: 1.43 KB

Versions: 57

Compression:

Stored size: 1.43 KB

Contents

require 'pagy'
module CmAdmin
  module ViewHelpers
    module NavigationHelper
      include Pagy::Frontend
      def navigation_links(navigation_type)
        CmAdmin.config.cm_admin_models.map do |model|
          next unless 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.to_s
                  end +
                      model.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(:div, class: 'result-text') do
                    content_tag(:span, class: 'result-icon') do
                      concat tag.i class: model.icon_name.to_s
                    end +
                      content_tag(:span) do
                        model.model_name.titleize.pluralize
                      end
                  end
                end
              end
            end
          end
        end.join.html_safe
      end
    end
  end
end

Version data entries

57 entries across 57 versions & 1 rubygems

Version Path
cm-admin-4.4.1 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-4.4.0 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-4.3.0 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-4.2.1 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-4.2.0 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-4.1.2 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-4.1.1 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-4.1.0 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-4.0.0 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-3.0.16 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-3.0.15 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-3.0.14 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-3.0.13 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-3.0.12 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-3.0.11 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-3.0.10 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-3.0.9 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-3.0.8 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-3.0.7 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-3.0.6 lib/cm_admin/view_helpers/navigation_helper.rb