Sha256: 69ce9cfb23eb8f946fe8f3ae5fe002807b15583075f747ef98f4bc795b6048b3

Contents?: true

Size: 922 Bytes

Versions: 10

Compression:

Stored size: 922 Bytes

Contents

class EffectivePagesMenuDatatable < Effective::Datatable

  datatable do
    reorder :menu_position

    if attributes[:menu_parent_id].present?
      col :menu_parent
    end

    col :title do |page|
      link_to(page, effective_pages.edit_admin_page_path(page))
    end

    col :menu_url, label: 'Redirect Url'
    col :menu_position, label: 'Position', visible: false
    col :menu_children, label: 'Children'

    actions_col(new: false, destroy: false)
  end

  collection(apply_belongs_to: false) do
    scope = Effective::Page.deep.for_menu(menu)

    scope = if attributes[:menu_parent_id].present?
      scope.where(menu_parent_id: attributes[:menu_parent_id])
    else
      scope.where(menu_parent_id: nil)
    end

    scope
  end

  def menu
    menu = EffectivePages.menus.find { |menu| menu.to_s == attributes[:menu].to_s }
    menu || raise("unexpected menu: #{attributes[:menu] || 'none'}")
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
effective_pages-3.1.0 app/datatables/effective_pages_menu_datatable.rb
effective_pages-3.0.10 app/datatables/effective_pages_menu_datatable.rb
effective_pages-3.0.9 app/datatables/effective_pages_menu_datatable.rb
effective_pages-3.0.8 app/datatables/effective_pages_menu_datatable.rb
effective_pages-3.0.7 app/datatables/effective_pages_menu_datatable.rb
effective_pages-3.0.6 app/datatables/effective_pages_menu_datatable.rb
effective_pages-3.0.5 app/datatables/effective_pages_menu_datatable.rb
effective_pages-3.0.4 app/datatables/effective_pages_menu_datatable.rb
effective_pages-3.0.3 app/datatables/effective_pages_menu_datatable.rb
effective_pages-3.0.2 app/datatables/effective_pages_menu_datatable.rb