Class: Symphonia::RendererHelper::QueryRender
- Defined in:
- app/helpers/symphonia/renderer_helper.rb
Constant Summary collapse
- OPTIONS =
[:without_pagination, :show_checkboxes, :show_radios, :table_css_classes]
Instance Attribute Summary collapse
-
#query ⇒ Object
readonly
Returns the value of attribute query.
-
#summarize ⇒ Object
Returns the value of attribute summarize.
Instance Method Summary collapse
- #css_classes(entity) ⇒ Object
- #default_buttons(entity) ⇒ Object
- #delete_link(entity) ⇒ Object
- #edit_link(entity) ⇒ Object
- #header_tag(column, options = {}) ⇒ Object
-
#initialize(helper, query, options = {}) ⇒ QueryRender
constructor
A new instance of QueryRender.
- #show_checkboxes? ⇒ Boolean
- #show_link(entity) ⇒ Object
- #show_radios? ⇒ Boolean
- #show_summarize? ⇒ Boolean
Constructor Details
#initialize(helper, query, options = {}) ⇒ QueryRender
Returns a new instance of QueryRender.
23 24 25 26 27 28 29 |
# File 'app/helpers/symphonia/renderer_helper.rb', line 23 def initialize(helper, query, = {}) @_c = helper @query = query OPTIONS.each do |key| send("#{key}=", [key]) end end |
Instance Attribute Details
#query ⇒ Object (readonly)
Returns the value of attribute query.
18 19 20 |
# File 'app/helpers/symphonia/renderer_helper.rb', line 18 def query @query end |
#summarize ⇒ Object
Returns the value of attribute summarize.
19 20 21 |
# File 'app/helpers/symphonia/renderer_helper.rb', line 19 def summarize @summarize end |
Instance Method Details
#css_classes(entity) ⇒ Object
77 78 79 80 81 |
# File 'app/helpers/symphonia/renderer_helper.rb', line 77 def css_classes(entity) css = [] css << "status--#{entity.status}" if entity.respond_to?(:status) css.join("__") + entity.try(:css_classes).to_s end |
#default_buttons(entity) ⇒ Object
56 57 58 |
# File 'app/helpers/symphonia/renderer_helper.rb', line 56 def (entity) edit_link(entity) + delete_link(entity) end |
#delete_link(entity) ⇒ Object
52 53 54 |
# File 'app/helpers/symphonia/renderer_helper.rb', line 52 def delete_link(entity) @_c.link_to(@_c.icon('del', t(:button_delete)), entity, method: 'DELETE', data: { remote: true, confirm: t(:text_are_you_sure) }) end |
#edit_link(entity) ⇒ Object
47 48 49 50 |
# File 'app/helpers/symphonia/renderer_helper.rb', line 47 def edit_link(entity) model = @_c.controller.try(:model) || @_c.controller_name @_c.link_to(@_c.icon('edit', t(:button_edit)), @_c.edit_polymorphic_path(entity, back_url: @_c.polymorphic_path(model, page: @_c.params[:page]))) end |
#header_tag(column, options = {}) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'app/helpers/symphonia/renderer_helper.rb', line 60 def header_tag(column, = {}) return '' unless column.header? title = column.title return title unless column.sort? current_column = query.sort_column || SortableTable::SortColumn.new(nil, nil) prefix = .delete(:prefix) is_current_column = column.sort_definition.column == current_column.column = .delete(:class) css_class = is_current_column ? "current #{current_column.direction} #{}" : direction = is_current_column && current_column.direction == 'asc' ? 'desc' : 'asc' sort_params = { "#{prefix}sort" => "#{column.sort_definition.column}:#{direction}", "#{prefix}page" => nil } @_c.link_to title, query.to_params.merge(sort_params), .merge({ class: css_class }) end |
#show_checkboxes? ⇒ Boolean
35 36 37 |
# File 'app/helpers/symphonia/renderer_helper.rb', line 35 def show_checkboxes? !!@show_checkboxes end |
#show_link(entity) ⇒ Object
43 44 45 |
# File 'app/helpers/symphonia/renderer_helper.rb', line 43 def show_link(entity) @_c.link_to(@_c.icon('info-circle', t(:button_show)), entity) end |
#show_radios? ⇒ Boolean
39 40 41 |
# File 'app/helpers/symphonia/renderer_helper.rb', line 39 def show_radios? !!@show_radios end |
#show_summarize? ⇒ Boolean
31 32 33 |
# File 'app/helpers/symphonia/renderer_helper.rb', line 31 def show_summarize? !!summarize end |