Sha256: 195a50ecbae37a0563efa1ce1ac8d44879deb8e952cf135fb4b5d5189c7f824c

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

# Base menu for sections. Also used on admin/sections/new.
class Admin::Sections::Menu < Adva::View::Menu::Admin::Actions
  include do
    def main
      if collection?
        index
      else
        resource_label
        show
        edit unless page?
      end
    end

    def right
      new if collection?
      destroy if edit?
      reorder if index? # TODO should only happen if we actually have more than 1 category
    end

    protected

      def index
        item(:".sections", index_parent_path(:sections))
      end

      def reorder
        super( :'data-resource_type' => 'site', :'data-sortable_type' => 'sections')
      end

      def page?
        resource.is_a?(Page)
      end

      def edit
        item(:'.edit_section', edit_path)
      end

      def active?(url, options)
        # hmmm ...
        types = Section.types.map { |type| type.underscore.pluralize }.join('|')
        return false if url =~ %r(/admin/sites/\d+/#{types}/\d+$) && request.path != url
        super
      end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
adva-core-0.0.2 app/views/admin/sections/_menu.html.rb