Class: Aureus::Components::DataTableRowButton

Inherits:
Renderable
  • Object
show all
Defined in:
lib/aureus/components/data_table.rb

Instance Method Summary collapse

Methods inherited from Renderable

#compact, #compact_render, #content_tag, #init

Constructor Details

#initialize(type, text, url, options) ⇒ DataTableRowButton

Returns a new instance of DataTableRowButton.



107
108
109
110
111
112
# File 'lib/aureus/components/data_table.rb', line 107

def initialize(type, text, url, options)
  init options, remote: true, confirm: 'Delete resource?'
  @type = type
  @text = text
  @url = url
end

Instance Method Details

#renderObject



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/aureus/components/data_table.rb', line 114

def render
  @text = ' ' unless @type == :text
  case @type
  when :text
    link_to @text, @url
  when :print
    link_to @text, @url, class: :print
  when :show
    link_to @text, @url, class: :show
  when :edit  
    link_to @text, @url, class: :edit
  when :destroy
    if @options[:remote]
      link_to @text, @url, class: :destroy, method: :delete, data: { confirm: @options[:confirm] }
    else
      link_to @text, @url, class: :destroy
    end
  end
end