Sha256: f3b56e165a51fe0e77b49d69b60c63a1298fb5aa080b65e7e08d42c383412e19

Contents?: true

Size: 1.7 KB

Versions: 63

Compression:

Stored size: 1.7 KB

Contents

class TableSettings
  class Action
    attr_accessor :action_hash, :name

    def initialize(table_settings)
      @table_settings = table_settings
      @action_hash = {}

      add_defaults
    end

    def label(label)
      @action_hash[:name] = label
      self
    end

    def title(title)
      @action_hash[:title] = title
      self
    end

    def add_defaults
      @action_hash[:symlink_remote] = true
      self
    end

    def controller(name)
      @action_hash[:symlink_controller] = name
      self
    end

    def action(name)
      @action_hash[:symlink_action] = name
      self
    end
    def outer_controller(name)
      @action_hash[:symlink_outer_controller] = name
      self
    end
    def outer_id(name)
      @action_hash[:symlink_outer_id] = name
      self
    end

    def remote(bool)
      @action_hash[:symlink_remote] = bool
      self
    end

    # @param [Symbol|String] - :get|:put|:post|:delete
    def http_method(name)
      @action_hash[:method] = name
      self
    end

    def css_class(name)
      @action_hash[:class] = name
      self
    end

    def confirm(text)
      @action_hash[:confirm] = text
      self
    end

    def onclick(text)
      @action_hash[:js_code] = text
      self
    end

    def css_class_type(type)
      css=case type
            when :show then "btn btn-success"
            when :edit then "btn btn-warning"
            when :delete then "btn btn-danger"
            when :destroy then "btn btn-danger"
            else "btn"
          end
      @action_hash[:class] = css
      self
    end

    ##
    # Position of button
    # @param [Symbol] pos - :left | :right
    def position(pos)
      @action_hash[:position] = pos
      self
    end

  end
end

Version data entries

63 entries across 63 versions & 1 rubygems

Version Path
it-logica-application-backbone-1.5.3 lib/table_settings/table_action.rb
it-logica-application-backbone-1.5.2 lib/table_settings/table_action.rb
it-logica-application-backbone-1.5.1 lib/table_settings/table_action.rb
it-logica-application-backbone-1.5.0 lib/table_settings/table_action.rb
it-logica-application-backbone-1.4.12 lib/table_settings/table_action.rb
it-logica-application-backbone-1.4.11 lib/table_settings/table_action.rb
it-logica-application-backbone-1.4.10 lib/table_settings/table_action.rb
it-logica-application-backbone-1.4.9 lib/table_settings/table_action.rb
it-logica-application-backbone-1.4.8 lib/table_settings/table_action.rb
it-logica-application-backbone-1.4.7 lib/table_settings/table_action.rb
it-logica-application-backbone-1.4.6 lib/table_settings/table_action.rb
it-logica-application-backbone-1.4.5 lib/table_settings/table_action.rb
it-logica-application-backbone-1.4.4 lib/table_settings/table_action.rb
it-logica-application-backbone-1.4.3 lib/table_settings/table_action.rb
it-logica-application-backbone-1.4.2 lib/table_settings/table_action.rb
it-logica-application-backbone-1.3.24 lib/table_settings/table_action.rb
it-logica-application-backbone-1.3.23 lib/table_settings/table_action.rb
it-logica-application-backbone-1.3.22 lib/table_settings/table_action.rb
it-logica-application-backbone-1.3.20 lib/table_settings/table_action.rb
it-logica-application-backbone-1.3.19 lib/table_settings/table_action.rb