Skip to content

Commit

Permalink
Merge pull request #1113 from sul-dlss/1083-renew-all-form
Browse files Browse the repository at this point in the history
Set a data-turbo-submits-with message when renewing
  • Loading branch information
cbeer authored Jun 17, 2024
2 parents 90a4ca1 + a878b7e commit d653775
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
4 changes: 3 additions & 1 deletion app/views/checkouts/_checkout.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
<%= hidden_field_tag :item_id, checkout.item_id %>
<%= hidden_field_tag :title, checkout.title %>
<%= hidden_field_tag :group, params[:group] if params[:group] %>
<%= button_tag class: 'btn btn-link btn-renewable-submit btn-icon-prefix', type: 'submit' do %>
<%= button_tag class: 'btn btn-link btn-renewable-submit btn-icon-prefix',
data: { turbo_submits_with: t('mylibrary.renew_item.in_progress_html') },
type: 'submit' do %>
<%= sul_icon 'renew' %> Renew this item
<% end %>
<% end %>
Expand Down
12 changes: 9 additions & 3 deletions app/views/checkouts/_renew_all_button.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
<% if patron_or_group.checkouts.any?(&:renewable?) %>
<% if patron_or_group.can_renew? %>
<%= link_to all_eligible_renewals_path(group: params[:group]), class: 'btn btn-info mb-1', method: :post do %>
<%= sul_icon :'renew' %> Renew <%= pluralize(patron_or_group.checkouts.count(&:renewable?), 'eligible item') %>
<% end %>
<% renewable_count = patron_or_group.checkouts.count(&:renewable?) %>
<%= form_tag all_eligible_renewals_path, method: :post do %>
<%= hidden_field_tag :group, params[:group] if params[:group] %>
<%= button_tag class: 'btn btn-info mb-1',
data: { turbo_submits_with: t('mylibrary.renew_all_items.in_progress_html', count: renewable_count) },
type: 'submit' do %>
<%= sul_icon :'renew' %> Renew <%= pluralize(renewable_count, 'eligible item') %>
<% end %>
<% end %>
<% else %>
<button disabled class="btn btn-info mb-1"><%= sul_icon :'renew' %> Renewals blocked</button>
<% end %>
Expand Down
4 changes: 4 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,14 @@ en:
label: 'Library ID'
help_text: 'Last 10 digits above the barcode on your library card'
renew_item:
in_progress_html: <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> Renewing this item
success_html: <span class="font-weight-bold">Success!</span> "%{title}" was renewed.
error_html: <span class="font-weight-bold">Sorry!</span> Something went wrong and "%{title}" was not renewed.
deny_access: An unexpected error has occurred
renew_all_items:
in_progress_html:
one: <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> Renewing 1 item
other: <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> Renewing all %{count} eligible items
success_html:
one: <span class="font-weight-bold">Success!</span> 1 item was renewed.
other: <span class="font-weight-bold">Success!</span> %{count} items were renewed.
Expand Down
2 changes: 1 addition & 1 deletion spec/views/checkouts/_renew_all_button.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
it 'renders a button' do
render

expect(output).to have_link 'Renew 1 eligible item'
expect(output).to have_button 'Renew 1 eligible item'
end

context 'when the patron is e.g. blocked and unable to renew material' do
Expand Down

0 comments on commit d653775

Please sign in to comment.