diff --git a/app/models/miq_report.rb b/app/models/miq_report.rb index ab03217f1759..79caf84230fe 100644 --- a/app/models/miq_report.rb +++ b/app/models/miq_report.rb @@ -181,6 +181,16 @@ def sort_col sortby ? col_order.index(sortby.first) : 0 end + def column_is_hidden?(col) + return false unless col_options + + @hidden_cols ||= col_options.keys.each_with_object([]) do |c, a| + a << c if col_options[c][:hidden] + end + + @hidden_cols.include?(col.to_s) + end + def self.from_hash(h) new(h) end diff --git a/app/models/miq_report/generator/html.rb b/app/models/miq_report/generator/html.rb index 93e99798b503..605ca7a2b4de 100644 --- a/app/models/miq_report/generator/html.rb +++ b/app/models/miq_report/generator/html.rb @@ -45,7 +45,7 @@ def build_html_rows(clickable_rows = false) row = 1 - row col_order.each_with_index do |c, c_idx| - next if col_options[c].try(:has_key?, :hidden) && col_options[c][:hidden] + next if column_is_hidden?(c) build_html_col(output, c, self.col_formats[c_idx], d.data) end diff --git a/lib/vmdb/global_methods.rb b/lib/vmdb/global_methods.rb index a198cd2b1a8d..af66c0e46de3 100644 --- a/lib/vmdb/global_methods.rb +++ b/lib/vmdb/global_methods.rb @@ -94,7 +94,7 @@ def report_build_html_table(report, table_body) unless report.headers.nil? report.headers.each_with_index do |h, i| col = report.col_order[i] - next if report.col_options[col].try(:has_key?, :hidden) && report.col_options[col][:hidden] + next if report.column_is_hidden?(col) html << "