diff --git a/app/controllers/export_controller.rb b/app/controllers/export_controller.rb index 46808bbad..e323bed65 100644 --- a/app/controllers/export_controller.rb +++ b/app/controllers/export_controller.rb @@ -2,10 +2,16 @@ class ExportController < AuthenticatedController include ProjectScoped def index + @default_button_state = non_draft_records? ? 'published' : 'all' end private + def non_draft_records? + issue_states = current_project.issues.pluck(:state).uniq + (issue_states & ['published', 'ready_for_review']).any? + end + # In case something goes wrong with the export, fail graciously instead of # presenting the obscure Error 500 default page of Rails. def rescue_action(exception) diff --git a/app/views/export/_submit_button.html.erb b/app/views/export/_submit_button.html.erb index dff812d2d..c919037dd 100644 --- a/app/views/export/_submit_button.html.erb +++ b/app/views/export/_submit_button.html.erb @@ -1,5 +1,5 @@
- + @@ -7,19 +7,19 @@ <%= collection_radio_buttons(nil, :scope, [['published', 'published'], ['all', 'all']], :first, :first) do |b| %> <%= b.label class: 'state', for: "#{plugin_name}_scope_#{b.value}" do %> - <%= b.radio_button id: "#{plugin_name}_scope_#{b.value}", class: 'd-none', data: { behavior: 'state-radio'}, checked: b.value == 'published' %> + <%= b.radio_button id: "#{plugin_name}_scope_#{b.value}", class: 'd-none', data: { behavior: 'state-radio'}, checked: b.value == @default_button_state %>

<%= b.text.humanize %>

<% case b.value %> <% when 'published' %> - Only records that have been reviewed and published. + Only records that have been reviewed and published. <% when 'all' %> - All records, regardless if they are draft, ready for review, or published. - <% end %> -
- <% end %> -
- <% end %> -
+ All records, regardless if they are draft, ready for review, or published. + <% end %> + + <% end %> + + <% end %> +