Sha256: b28202ab50e11def66f17059a862ffc5e524146c6dcde4fd83294d97efc2f5cb

Contents?: true

Size: 1.3 KB

Versions: 15

Compression:

Stored size: 1.3 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}"
                  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(:span) do
                    concat tag.i class: "#{model.icon_name}"
                  end +
                    content_tag(:span) do
                        model.model_name
                    end
                end
              end
            end
          end
        end.join.html_safe
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
cm-admin-1.5.48 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.5.47 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.5.46 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.5.45 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.5.44 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.5.43 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.5.42 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.5.41 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.5.40 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.5.39 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.5.38 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.5.37 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.5.36 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.5.35 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.5.34 lib/cm_admin/view_helpers/navigation_helper.rb