Module: QueryReportEngineHelper
- Defined in:
- app/helpers/query_report_engine_helper.rb
Instance Method Summary collapse
- #export_report_url_with_format(format) ⇒ Object
- #hash_to_hidden_fields(hash) ⇒ Object
- #query_report_render_filter(filter, comparator) ⇒ Object
- #query_report_search_form(report, &block) ⇒ Object
- #render_query_report(report = nil) ⇒ Object
Instance Method Details
#export_report_url_with_format(format) ⇒ Object
34 35 36 |
# File 'app/helpers/query_report_engine_helper.rb', line 34 def export_report_url_with_format(format) url_for(params.merge(format: format)) end |
#hash_to_hidden_fields(hash) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/helpers/query_report_engine_helper.rb', line 38 def hash_to_hidden_fields(hash) cleaned_hash = hash.reject { |k, v| v.nil? } pairs = cleaned_hash.to_query.split(Rack::Utils::DEFAULT_SEP) = pairs.map do |pair| key, value = pair.split('=', 2).map { |str| Rack::Utils.unescape(str) } hidden_field_tag(key, value) end .join("\n").html_safe end |
#query_report_render_filter(filter, comparator) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/helpers/query_report_engine_helper.rb', line 8 def query_report_render_filter(filter, comparator) hint = comparator.name search_tag_name = comparator.search_tag_name value = comparator.param_value method_name = :"query_report_#{filter.type.to_s}_filter" default_method_name = :"query_report_default_#{filter.type.to_s}_filter" if respond_to? method_name send method_name, search_tag_name, value, :placeholder => hint elsif respond_to? default_method_name send default_method_name, search_tag_name, value, :placeholder => hint else raise QueryReport::FilterNotDefined, %Q{#{filter.type.to_s} filter is not defined. Please define a method as following, def #{method_name}(name, value, options={}) text_field_tag name, value, options end } end end |
#query_report_search_form(report, &block) ⇒ Object
50 51 52 53 54 55 56 |
# File 'app/helpers/query_report_engine_helper.rb', line 50 def query_report_search_form(report, &block) if report.array_record? form_tag(url_for({}), (QueryReport.config. || {}).merge({method: :get, remote: @remote}), &block) else search_form_for(report.search, url: url_for({}), remote: @remote, html: (QueryReport.config. || {}).merge(method: :get), &block) end end |
#render_query_report(report = nil) ⇒ Object
29 30 31 32 |
# File 'app/helpers/query_report_engine_helper.rb', line 29 def render_query_report(report = nil) report ||= @report render :partial => "query_report/list", locals: {report: report} end |