Sha256: a10544e6af6b1f75827c71594d2ce05706c1a115129c2f2b26d7db97d50c5b75

Contents?: true

Size: 1.31 KB

Versions: 43

Compression:

Stored size: 1.31 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.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

43 entries across 43 versions & 1 rubygems

Version Path
cm-admin-1.1.1 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.1.0 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.0.9 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.0.8 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.0.7 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.0.6 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.0.5 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.0.3 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.0.2 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-1.0.0 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-0.9.1 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-0.9.0 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-0.8.9 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-0.8.8 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-0.8.7 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-0.8.6 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-0.8.5 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-0.8.4 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-0.8.3 lib/cm_admin/view_helpers/navigation_helper.rb
cm-admin-0.8.2 lib/cm_admin/view_helpers/navigation_helper.rb