Sha256: 3c5d3c80096c3022fc63bd02662d42e9126b9cbf33e744d846301def8cf05d57

Contents?: true

Size: 1.56 KB

Versions: 5

Compression:

Stored size: 1.56 KB

Contents

module Typus
  module Controller
    module Headless

      def self.included(base)
        base.before_filter :set_resources_action_for_headless_on_index, :only => [:index, :trash]
        base.before_filter :set_resources_action_for_headless, :only => [:new, :create, :edit, :show]
        base.helper_method :headless_mode?
        base.layout :set_headless_layout
      end

      def set_resources_action_for_headless_on_index
        add_resources_action("Add New", {:action => "new"}, {})
      end
      private :set_resources_action_for_headless_on_index

      def set_resources_action_for_headless
        add_resources_action("All Entries", {:action => 'index', :id => nil}, {})
      end
      private :set_resources_action_for_headless

      def set_headless_layout
        params[:layout] || "admin/base"
      end
      private :set_headless_layout

      def headless_mode_with_custom_action_is_enabled?
        headless_mode? && params[:resource_action]
      end
      private :headless_mode_with_custom_action_is_enabled?

      def set_headless_resource_actions
        body = params[:resource_action].titleize
        url = { :controller => params[:resource].tableize,
                :action => params[:resource_action],
                :resource => params[:resource],
                :resource_id => params[:resource_id],
                :return_to => params[:return_to] }
        options = { :target => "_parent" }
        add_resource_action(body, url, options)
      end

      def headless_mode?
        params[:layout] == "admin/headless"
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
typus-3.1.0.rc19 lib/typus/controller/headless.rb
typus-3.1.0.rc18 lib/typus/controller/headless.rb
typus-3.1.0.rc17 lib/typus/controller/headless.rb
typus-3.1.0.rc16 lib/typus/controller/headless.rb
typus-3.1.0.rc15 lib/typus/controller/headless.rb