Sha256: f208bf284a3696bdec5291f3eb72f8be2dd90fc2518f3a97d66ef19e76e4e8f4

Contents?: true

Size: 1.66 KB

Versions: 1

Compression:

Stored size: 1.66 KB

Contents

module Spurs
  module Modal
    module ControllerMods
      extend ActiveSupport::Concern

      def spawn_form_modal(title, partial, object, options={ })
        opts = {
            :actions => [
                { :name => :cancel, :position => :left, :action => :close_modal, :class => "btn-large" },
                { :name => :save, :position => :right, :action => :submit_form_and_close_modal, :class => "btn-primary btn-large" },
            ]
        }.merge(options)
        logger.debug("spawn_form_modal options = #{opts.to_json}")

        spawn_modal(title, partial, object, opts)
      end



      def spawn_close_modal(title, file, options={ })
        opts[:content_options] = options
        opts = {
            :actions => [
                { :name => :cancel, :position => :left, :action => :close_modal, :class => "btn-large" }
            ]
        }.merge(options)
        logger.debug("spawn_close_modal options = #{opts.to_json}")
        spawn_modal(title, file, nil, opts)
      end



      def spawn_modal(title, partial, object, options={ })
        #options[:content_options] = options.clone
        opts = {
            :header => {
                :title => title.titlecase,
                :icon  => options[:title_icon] ? options.delete(:title_icon) : nil
            },

        }.merge(options)
        logger.debug("spawn_modal options = #{opts.to_json}")
        render :file => "spurs/modals/spawn", :locals => { :modal_file_or_partial => partial,
                                                           :modal_object          => object,
                                                           :modal_options         => opts }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spurs-0.0.1 lib/spurs/modal/controller_mods.rb