Sha256: 8796585b903cfeacb34b866c4a9aa1dcb533c56699952d91d3afad1c08c83104

Contents?: true

Size: 1.55 KB

Versions: 8

Compression:

Stored size: 1.55 KB

Contents

module Typus
  module Controller
    module Headless

      def self.included(base)
        base.before_filter :set_resources_action_for_headless_on_index, :only => [:index]
        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

8 entries across 8 versions & 1 rubygems

Version Path
typus-3.1.0.rc14 lib/typus/controller/headless.rb
typus-3.1.0.rc13 lib/typus/controller/headless.rb
typus-3.1.0.rc12 lib/typus/controller/headless.rb
typus-3.1.0.rc11 lib/typus/controller/headless.rb
typus-3.1.0.rc10 lib/typus/controller/headless.rb
typus-3.1.0.rc9 lib/typus/controller/headless.rb
typus-3.1.0.rc8 lib/typus/controller/headless.rb
typus-3.1.0.rc7 lib/typus/controller/headless.rb