Sha256: 526946e7b600f43cc5c36b8952f2693e458076ed3ebdb96a77cd62ef7328cca3

Contents?: true

Size: 1.93 KB

Versions: 12

Compression:

Stored size: 1.93 KB

Contents

include ActiveAdmin::AwesomeNestedSet::Helper if Gem::Specification.find_all_by_name('activeadmin').any?

ActiveAdmin.register Ecm::Cms::Navigation do
  permit_params(:locale,
                :name,
                :slug) if Rails.version >= '4.0.0'

  # Filters
  filter :locale, as: :select, collection: I18n.available_locales.map(&:to_s)
  filter :name

  # Menu
  menu parent: proc { I18n.t('ecm.cms.active_admin.menu') }.call

  form do |f|
    f.inputs do
      f.input :locale, as: :select, collection: I18n.available_locales.map(&:to_s)
      f.input :name
    end

    f.actions
  end

  index do
    selectable_column
    column :name
    column :locale
    ActiveAdmin::VERSION[0] < '1' ? default_actions : actions
  end

  show do
    panel Ecm::Cms::Navigation.human_attribute_name(:ecm_cms_navigation_items) do
      table_for ecm_cms_navigation.ecm_cms_navigation_items, i18n: Ecm::Cms::NavigationItem do
        sortable_tree_columns
        sortable_tree_indented_column :name
        column :url
        column :ecm_cms_page do |ni|
          if ni.ecm_cms_page.blank?
            link_to(I18n.t('active_admin.create_model', model: Ecm::Cms::Page.model_name.human), new_admin_ecm_cms_page_path(ecm_cms_page: ni.params_for_new_page))
          else
            link_to(ni.ecm_cms_page.title, [:admin, ni.ecm_cms_page])
          end
        end
        column :created_at
        column :updated_at

        column do |ni|
          link_to(I18n.t('active_admin.view'), [:admin, ni], class: 'member_link view_link') +
            link_to(I18n.t('active_admin.edit'), [:edit, :admin, ni], class: 'member_link edit_link')
        end
      end
    end
  end

  sidebar Ecm::Cms::Navigation.human_attribute_name(:details), only: :show do
    attributes_table_for ecm_cms_navigation do
      row :locale
      row :name
      row :slug
      row :created_at
      row :updated_at
    end
  end # sidebar
end if Gem::Specification.find_all_by_name('activeadmin').any?

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ecm_cms2-3.0.3 app/admin/ecm_cms_navigations.rb
ecm_cms2-3.0.2 app/admin/ecm_cms_navigations.rb
ecm_cms2-3.0.1 app/admin/ecm_cms_navigations.rb
ecm_cms2-3.0.0 app/admin/ecm_cms_navigations.rb
ecm_cms2-2.1.4 app/admin/ecm_cms_navigations.rb
ecm_cms2-2.1.3 app/admin/ecm_cms_navigations.rb
ecm_cms2-2.1.2 app/admin/ecm_cms_navigations.rb
ecm_cms2-2.1.1 app/admin/ecm_cms_navigations.rb
ecm_cms2-2.1.0 app/admin/ecm_cms_navigations.rb
ecm_cms2-2.0.4 app/admin/ecm_cms_navigations.rb
ecm_cms2-2.0.3 app/admin/ecm_cms_navigations.rb
ecm_cms2-2.0.2 app/admin/ecm_cms_navigations.rb