Skip to content

Commit

Permalink
Add new parameter to report definition
Browse files Browse the repository at this point in the history
  • Loading branch information
lpichler committed Jul 21, 2017
1 parent d15d312 commit 4a6865f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/controllers/report_controller/reports/editor.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down
11 changes: 11 additions & 0 deletions app/views/report/_form_filter_chargeback.html.haml
Expand Up @@ -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
Expand Down

0 comments on commit 4a6865f

Please sign in to comment.