Skip to content

Commit

Permalink
Disable Download button for reports when no records are found
Browse files Browse the repository at this point in the history
https://bugzilla.redhat.com/show_bug.cgi?id=1205023

Download button should be disabled for reports when no records are found.
  • Loading branch information
ZitaNemeckova committed Apr 5, 2016
1 parent 7cfe372 commit f83a301
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/helpers/application_helper/button/basic.rb
Expand Up @@ -11,7 +11,7 @@ def initialize(view_context, view_binding, instance_data, props)
end

def calculate_properties
self[:enabled] = !disabled?
self[:enabled] = !disabled? if self[:enabled].nil?
end

def skip?
Expand Down
@@ -0,0 +1,5 @@
class ApplicationHelper::Button::ReportDownloadChoice < ApplicationHelper::Button::Basic
def disabled?
MiqReportResult.find(@report_result_id).try(:miq_report_result_details).try(:length).to_i == 0
end
end
1 change: 1 addition & 0 deletions app/helpers/application_helper/toolbar/report_view.rb
Expand Up @@ -28,6 +28,7 @@ class ApplicationHelper::Toolbar::ReportView < ApplicationHelper::Toolbar::Basic
'fa fa-download fa-lg',
N_('Download'),
nil,
:klass => ApplicationHelper::Button::ReportDownloadChoice,
:items => [
button(
:render_report_txt,
Expand Down

0 comments on commit f83a301

Please sign in to comment.