Skip to content

Commit

Permalink
Add checkbox to report options for report with/without rollups
Browse files Browse the repository at this point in the history
- only for chargeback for Vm
  • Loading branch information
lpichler committed Feb 16, 2017
1 parent 72e35ee commit f45b8b7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/controllers/report_controller/reports/editor.rb
Expand Up @@ -506,6 +506,7 @@ def gfv_model
@edit[:new][:cb_end_interval_offset] ||= 1
@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'
end
reset_report_col_fields
build_edit_screen
Expand Down Expand Up @@ -597,6 +598,8 @@ def gfv_chargeback
@edit[:new][:cb_tag_cat] = params[:cb_tag_cat]
@edit[:cb_tags] = entries_hash(params[:cb_tag_cat])
end
elsif params.key?(:cb_include_metrics)
@edit[:new][:cb_include_metrics] = params[:cb_include_metrics] == 'true'
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 @@ -988,6 +991,7 @@ def set_record_vars(rpt)
options[:entity_id] = @edit[:new][:cb_entity_id]
end

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 @@ -1266,6 +1270,8 @@ def set_form_vars
@edit[:new][:cb_provider_id] = options[:provider_id]
end

# @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][: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
13 changes: 13 additions & 0 deletions app/views/report/_form_filter_chargeback.html.haml
@@ -1,4 +1,17 @@
- url = url_for(:action => 'form_field_changed', :id => "#{@edit[:rpt_id] || 'new'}")
- if @edit[:new][:model] == "ChargebackVm"
%h3
= _('Chargeback Resources')
.form-horizontal
.form-group
%label.control-label.col-md-2
= _('Include Capacity & Utilization Metrics')
.col-md-8
= check_box_tag("cb_include_metrics", true, @edit[:new][:cb_include_metrics],
"data-miq_sparkle_on" => true, "data-miq_sparkle_off" => true,
:data => {:on_text => _('Yes'), :off_text => _('No')})
:javascript
miqInitBootstrapSwitch('cb_include_metrics', "#{url}")
%h3
= _('Chargeback Filters')
.form-horizontal
Expand Down

0 comments on commit f45b8b7

Please sign in to comment.