Class: Redde::IndexHelper::IndexBuilder::IndexCellBuilder
- Inherits:
-
Object
- Object
- Redde::IndexHelper::IndexBuilder::IndexCellBuilder
show all
- Includes:
- ActionView::Context, ActionView::Helpers, ActionView::Helpers::UrlHelper, Haml::Helpers, Redde::IndexHelper
- Defined in:
- app/helpers/redde/index_helper.rb
Constant Summary
Redde::IndexHelper::IGNORED_COLUMNS
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#ancestry_options, #ancestry_tree, #collection, #column_names, #excluded_column_names, #form_column_names, #index_columns, #index_value_for, #list_table, #list_table_options, #model_name, #record, #render_item_column, #show_tree, #sort_priority, #sort_table_options, #title_for, #title_symbol_for
Constructor Details
Returns a new instance of IndexCellBuilder.
195
196
197
198
199
|
# File 'app/helpers/redde/index_helper.rb', line 195
def initialize(item, builder)
@item = item
@builder = builder
init_haml_helpers
end
|
Instance Attribute Details
#builder ⇒ Object
Returns the value of attribute builder.
193
194
195
|
# File 'app/helpers/redde/index_helper.rb', line 193
def builder
@builder
end
|
#item ⇒ Object
Returns the value of attribute item.
193
194
195
|
# File 'app/helpers/redde/index_helper.rb', line 193
def item
@item
end
|
Class Method Details
.content(value) ⇒ Object
201
202
203
204
205
206
207
208
|
# File 'app/helpers/redde/index_helper.rb', line 201
def self.content(value)
case value.class.name
when 'Time' then I18n.l(value, format: '%d %b %Y, %H:%M')
when 'Date' then I18n.l(value, format: '%d %b %Y')
else
value
end
end
|
Instance Method Details
#cell(field, options = {}, &block) ⇒ Object
210
211
212
213
214
215
216
217
|
# File 'app/helpers/redde/index_helper.rb', line 210
def cell(field, options = {}, &block)
if field.is_a?(Hash)
content_tag :td, capture(&block), class: ['list__cell', field[:class]]
else
content_tag :td, if block_given? then capture(&block) else raw(IndexCellBuilder.content(index_value_for(item, field))) end, class: ['list__cell', options[:class]]
end
end
|
#del ⇒ Object
234
235
236
237
238
|
# File 'app/helpers/redde/index_helper.rb', line 234
def del
content_tag :td, class: 'list__cell list__cell_del' do
link_to('', url_for(id: item, action: :destroy, controller: builder.params[:controller]), method: :delete, data: { confirm: 'Точно удалить?' }, class: 'list__del')
end
end
|
#empty(options = {}) ⇒ Object
219
220
221
|
# File 'app/helpers/redde/index_helper.rb', line 219
def empty(options = {})
content_tag(:td, "", class: ['list__cell', options[:class]])
end
|
#handle ⇒ Object
223
224
225
226
|
# File 'app/helpers/redde/index_helper.rb', line 223
def handle
return content_tag(:td, "", class: ['list__cell', '_handle'], 'data-sortable-handle' => "") if item.class.column_names.include?('position')
empty
end
|
#visible ⇒ Object
228
229
230
231
232
|
# File 'app/helpers/redde/index_helper.rb', line 228
def visible
content_tag :td, class: 'list__cell _eye' do
link_to('', url_for(id: item, controller: builder.params[:controller], action: :update, item.class.model_name.param_key => { visible: !item.visible} ), class: ['list__eye', ('_disactive' if !item.visible)], data: { method: 'put' })
end if item.class.column_names.include?('visible')
end
|