Class: ReportsKit::ReportBuilder
- Inherits:
-
Object
- Object
- ReportsKit::ReportBuilder
- Includes:
- ActionView::Helpers
- Defined in:
- lib/reports_kit/report_builder.rb
Instance Attribute Summary collapse
-
#properties ⇒ Object
Returns the value of attribute properties.
Instance Method Summary collapse
- #check_box(filter_key, options = {}) ⇒ Object
- #date_range(filter_key, options = {}) ⇒ Object
-
#initialize(properties) ⇒ ReportBuilder
constructor
A new instance of ReportBuilder.
- #multi_autocomplete(filter_key, options = {}) ⇒ Object
- #string_filter(filter_key, options = {}) ⇒ Object
Constructor Details
#initialize(properties) ⇒ ReportBuilder
Returns a new instance of ReportBuilder.
7 8 9 |
# File 'lib/reports_kit/report_builder.rb', line 7 def initialize(properties) self.properties = normalize_properties(properties) end |
Instance Attribute Details
#properties ⇒ Object
Returns the value of attribute properties.
5 6 7 |
# File 'lib/reports_kit/report_builder.rb', line 5 def properties @properties end |
Instance Method Details
#check_box(filter_key, options = {}) ⇒ Object
11 12 13 14 15 |
# File 'lib/reports_kit/report_builder.rb', line 11 def check_box(filter_key, ={}) filter = validate_filter!(filter_key) checked = filter.properties[:criteria][:operator] == 'true' check_box_tag(filter_key, '1', checked, ) end |
#date_range(filter_key, options = {}) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/reports_kit/report_builder.rb', line 17 def date_range(filter_key, ={}) filter = validate_filter!(filter_key) defaults = { class: 'form-control input-sm date_range_picker' } = defaults.deep_merge() text_field_tag(filter_key, filter.properties[:criteria][:value], ) end |
#multi_autocomplete(filter_key, options = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/reports_kit/report_builder.rb', line 24 def multi_autocomplete(filter_key, ={}) validate_filter!(filter_key) reports_kit_path = Rails.application.routes.url_helpers.reports_kit_path path = "#{reports_kit_path}reports_kit/resources/measures/#{measure.key}/filters/#{filter_key}/autocomplete" scope = .delete(:scope) params = {} params[:scope] = scope if scope.present? defaults = { class: 'form-control input-sm select2', multiple: 'multiple', data: { placeholder: [:placeholder], path: path, params: params } } = defaults.deep_merge() select_tag(filter_key, nil, ) end |
#string_filter(filter_key, options = {}) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/reports_kit/report_builder.rb', line 45 def string_filter(filter_key, ={}) filter = validate_filter!(filter_key) defaults = { class: 'form-control input-sm' } = defaults.deep_merge() text_field_tag(filter_key, filter.properties[:criteria][:value], ) end |