Skip to content

Commit

Permalink
Display info about unavailable fields while editing report
Browse files Browse the repository at this point in the history
  • Loading branch information
hstastna committed Apr 9, 2019
1 parent 27d3f8d commit 01d2a9a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
13 changes: 13 additions & 0 deletions app/controllers/report_controller/reports/editor.rb
Expand Up @@ -131,11 +131,24 @@ def miq_report_add_edit
replace_right_cell
end

# Get string with unavailable fields while adding/editing report
def unavailable_fields_for_model(model)
case model
when 'ChargebackVm'
_('* Caution: CPU Cores Allocated Metric, CPU Cores Used Metric are not supported for Chargeback for Vms.')
when 'ChargebackContainerImage'
_('* Caution: CPU Allocated Metric, CPU Used Metric, Disk I/O Used Metric, Fixed Storage Metric, Storage Allocated Metric, Storage Used Metric are not supported for Chargeback for Images.')
when 'ChargebackContainerProject'
_('* Caution: CPU Allocated Metric, CPU Used Metric, CPU Cores Allocated Metric, Disk I/O Used Metric, Memory Allocated Metric, Fixed Storage Metric, Storage Allocated Metric, Storage Used Metric are not supported for Chargeback for Projects.')
end
end

# AJAX driven routine to check for changes in ANY field on the form
def form_field_changed
return unless load_edit("report_edit__#{params[:id]}", "replace_cell__explorer")
get_form_vars
build_edit_screen
@unavailable_fields = unavailable_fields_for_model(@edit[:new][:model])
@changed = (@edit[:new] != @edit[:current])
render :update do |page|
page << javascript_prologue
Expand Down
6 changes: 6 additions & 0 deletions app/views/report/_form_columns.html.haml
Expand Up @@ -26,6 +26,12 @@
= render :partial => "column_lists"
%strong
= _('* Caution: Changing these fields will clear all selected values below them!')
- if @unavailable_fields
%br
%p{:style => "max-width: 850px;"}
%strong
= @unavailable_fields

%hr
%h3
= _('Report Creation Timeout')
Expand Down

0 comments on commit 01d2a9a

Please sign in to comment.