From 4a6865f1f4f68ff6f87a731f17ca52c8280344ea Mon Sep 17 00:00:00 2001 From: lpichler Date: Fri, 21 Jul 2017 15:25:19 +0200 Subject: [PATCH] Add new parameter to report definition --- app/controllers/report_controller/reports/editor.rb | 5 +++++ app/views/report/_form_filter_chargeback.html.haml | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/app/controllers/report_controller/reports/editor.rb b/app/controllers/report_controller/reports/editor.rb index 24febd9c7d1e..ef83dac66d0f 100644 --- a/app/controllers/report_controller/reports/editor.rb +++ b/app/controllers/report_controller/reports/editor.rb @@ -517,6 +517,7 @@ def gfv_model @edit[:new][:cb_groupby] ||= "date" # Default to Date grouping @edit[:new][:tz] = session[:user_tz] @edit[:new][:cb_include_metrics] = true if @edit[:new][:model] == 'ChargebackVm' + @edit[:new][:method_for_allocated_metrics] = DEFAULT_CHARGEBACK_ALLOCATED_METHOD end reset_report_col_fields build_edit_screen @@ -610,6 +611,8 @@ def gfv_chargeback end elsif params.key?(:cb_include_metrics) @edit[:new][:cb_include_metrics] = params[:cb_include_metrics] == 'true' + elsif params.key?(:method_for_allocated_metrics) + @edit[:new][:method_for_allocated_metrics] = params[:method_for_allocated_metrics].to_sym || DEFAULT_CHARGEBACK_ALLOCATED_METHOD elsif params.key?(:cb_owner_id) @edit[:new][:cb_owner_id] = params[:cb_owner_id].blank? ? nil : params[:cb_owner_id] elsif params.key?(:cb_tenant_id) @@ -1011,6 +1014,7 @@ def set_record_vars(rpt) options[:entity_id] = @edit[:new][:cb_entity_id] end + options[:method_for_allocated_metrics] = @edit[:new][:method_for_allocated_metrics] options[:include_metrics] = @edit[:new][:cb_include_metrics] options[:groupby] = @edit[:new][:cb_groupby] options[:groupby_tag] = @edit[:new][:cb_groupby] == 'tag' ? @edit[:new][:cb_groupby_tag] : nil @@ -1295,6 +1299,7 @@ def set_form_vars # @edit[:new][:cb_include_metrics] = nil - it means YES (YES is default value for new and legacy reports) @edit[:new][:cb_include_metrics] = options[:include_metrics].nil? || options[:include_metrics] + @edit[:new][:method_for_allocated_metrics] = options[:method_for_allocated_metrics].to_sym || DEFAULT_CHARGEBACK_ALLOCATED_METHOD @edit[:new][:cb_groupby_tag] = options[:groupby_tag] if options.key?(:groupby_tag) @edit[:new][:cb_model] = Chargeback.report_cb_model(@rpt.db) @edit[:new][:cb_interval] = options[:interval] diff --git a/app/views/report/_form_filter_chargeback.html.haml b/app/views/report/_form_filter_chargeback.html.haml index ca0dd8aa23ed..c3a505ff7502 100644 --- a/app/views/report/_form_filter_chargeback.html.haml +++ b/app/views/report/_form_filter_chargeback.html.haml @@ -12,6 +12,17 @@ :data => {:on_text => _('Yes'), :off_text => _('No')}) :javascript miqInitBootstrapSwitch('cb_include_metrics', "#{url}") + + .form-group + %label.control-label.col-md-2 + = _('Method for allocated metrics') + .col-md-8 + - opts = CHAREGEBACK_ALLOCATED_METHODS.invert.to_a + = select_tag("method_for_allocated_metrics", + options_for_select(opts, @edit[:new][:method_for_allocated_metrics]), :class => "selectpicker") + :javascript + miqInitSelectPicker(); + miqSelectPickerEvent('method_for_allocated_metrics', '#{url}', {beforeSend: true, complete: true}); %h3 = _('Chargeback Filters') .form-horizontal