Skip to content

Commit

Permalink
[#162176] Require user action for missing merge order info (#4229)
Browse files Browse the repository at this point in the history
* Rename partial

* More renaming

* Rename block parameter for clarity

* Pull table into a partial

* Use the merge order table partial in the missing info reminder modal

* Update reminder message

* Update specs
  • Loading branch information
giladshanan committed May 6, 2024
1 parent 17222a5 commit cf71620
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 75 deletions.
36 changes: 2 additions & 34 deletions app/views/facility_orders/_merge_order.html.haml
@@ -1,35 +1,3 @@
- if @merge_orders.present?
= render "merge_order_missing_form_reminder"
.well
%p.alert.alert-error
= t("facility_orders.edit.attention_html")
%table.table.table-striped.table-hover
%thead
%tr
%th= t("facility_orders.edit.actions")
%th= OrderDetail.human_attribute_name(:product)
%th.centered= OrderDetail.human_attribute_name(:quantity)
%th.currency= OrderDetail.human_attribute_name(:estimated_cost)
- if @order.has_subsidies?
%th.currency= OrderDetail.human_attribute_name(:estimated_subsidy)
%th.currency= OrderDetail.human_attribute_name(:estimated_total)

%tbody
- @merge_orders.each do |order|
- order.order_details.each do |order_detail|
%tr
%td.centered= link_to "Remove", facility_order_order_detail_path(order.facility, order, order_detail), method: :delete
%td
= render partial: "orders/#{order_detail.product.class.name.underscore}_desc", locals: { order_detail: order_detail }
%td.centered
= QuantityPresenter.new(order_detail.product, order_detail.quantity)
- if order_detail.cost_estimated?
%td.currency= show_estimated_cost(order_detail)
- if @order.has_subsidies?
%td.currency= show_estimated_subsidy(order_detail)
%td.currency= show_estimated_total(order_detail)
- else
%td.currency Unassigned
- if @order.has_subsidies?
%td.currency Unassigned
%td.currency Unassigned
= render "merge_order_missing_order_info_reminder"
= render partial: "merge_order_table"

This file was deleted.

@@ -0,0 +1,7 @@
#merge-order-missing-order-info-reminder.modal.hide.fade{ data: { backdrop: "static" } }
.modal-header
- # We're skipping the modal_close_button here to force users to read the message and take action
%h3= text("facility_orders.edit.missing_merge_order_info.header")
.modal-body
= render partial: "merge_order_table", locals: { modal: true }
= javascript_tag "$('#merge-order-missing-order-info-reminder').modal('show');"
35 changes: 35 additions & 0 deletions app/views/facility_orders/_merge_order_table.html.haml
@@ -0,0 +1,35 @@
.well
%p.alert.alert-error
= t("facility_orders.edit.missing_merge_order_info.attention_html")
%table.table.table-striped.table-hover
%thead
%tr
%th= t("facility_orders.edit.actions")
%th= OrderDetail.human_attribute_name(:product)
- unless local_assigns.has_key?(:modal)
%th.centered= OrderDetail.human_attribute_name(:quantity)
%th.currency= OrderDetail.human_attribute_name(:estimated_cost)
- if @order.has_subsidies?
%th.currency= OrderDetail.human_attribute_name(:estimated_subsidy)
%th.currency= OrderDetail.human_attribute_name(:estimated_total)

%tbody
- @merge_orders.each do |merge_order|
- merge_order.order_details.each do |order_detail|
%tr
%td.centered= link_to "Remove", facility_order_order_detail_path(merge_order.facility, merge_order, order_detail), method: :delete
%td
= render partial: "orders/#{order_detail.product.class.name.underscore}_desc", locals: { order_detail: order_detail }
- unless local_assigns.has_key?(:modal)
%td.centered
= QuantityPresenter.new(order_detail.product, order_detail.quantity)
- if order_detail.cost_estimated?
%td.currency= show_estimated_cost(order_detail)
- if @order.has_subsidies?
%td.currency= show_estimated_subsidy(order_detail)
%td.currency= show_estimated_total(order_detail)
- else
%td.currency Unassigned
- if @order.has_subsidies?
%td.currency Unassigned
%td.currency Unassigned
17 changes: 6 additions & 11 deletions config/locales/en.yml
Expand Up @@ -401,17 +401,12 @@ en:
no_new_or_inprocess_orders: There are no "New" or "In Process" orders.
edit:
actions: Actions
missing_form_modal:
header: Action Required - Missing Form
body_html: |
Your order includes order details that need your attention. <br>
Before you can add anything else to this order you need to address them. <br>
Please click the "Complete Online Order Form" button below to complete the form (required).
ok: OK
attention_html: |
Your order includes order details that need your attention. <br>
Before you can add anything else to this order you need to address them. <br>
Please click the button below to complete the form (required).
missing_merge_order_info:
header: Action Required - Missing Order Info
attention_html: |
Your order includes one or more incomplete items. <br>
Please provide the required order form or reservation info <br>
before adding additional items or completing the purchase.
head:
h1: "Summary Of Order #%{order_number}"
h2: "Order Detail #%{order_number}"
Expand Down
48 changes: 29 additions & 19 deletions spec/system/admin/adding_to_an_order_spec.rb
Expand Up @@ -116,12 +116,14 @@
end

it "requires a file to be uploaded before adding to the order" do
expect(page).to have_content("Your order includes order details that need your attention.")
expect(page).to have_content("Your order includes one or more incomplete items.")
end

describe "after uploading the file" do
before do
click_link "Upload Order Form"
within("#merge-order-missing-order-info-reminder") do
click_link "Upload Order Form"
end
attach_file "stored_file[file]", Rails.root.join("spec", "files", "template1.txt")
click_button "Upload"
end
Expand Down Expand Up @@ -151,17 +153,21 @@
end

it "requires a reservation to be set up before adding to the order" do
expect(page).to have_content("Your order includes order details that need your attention.")
expect(page).to have_content("Your order includes one or more incomplete items.")

click_link "Make a Reservation"
within("#merge-order-missing-order-info-reminder") do
click_link "Make a Reservation"
end
click_button "Create"

expect(order.reload.order_details.count).to be(2)
expect(order.order_details.last.product).to eq(instrument)
end

it "brings you back to the facility order path on 'Cancel'" do
click_link "Make a Reservation"
within("#merge-order-missing-order-info-reminder") do
click_link "Make a Reservation"
end
click_link "Cancel"

expect(current_path).to eq(facility_order_path(facility, order))
Expand All @@ -182,24 +188,24 @@
end

it "is accessible" do
click_button "OK"
expect(page).to be_axe_clean
end

it "requires a reservation to be set up before adding to the order" do
expect(page).to have_content("Your order includes order details that need your attention.")

click_button "OK"
click_link "Make a Reservation"
expect(page).to have_content("Your order includes one or more incomplete items.")
within("#merge-order-missing-order-info-reminder") do
click_link "Make a Reservation"
end
click_button "Create"

expect(order.reload.order_details.count).to be(2)
expect(order.order_details.last.product).to eq(instrument)
end

it "brings you back to the facility order path on 'Cancel'" do
click_button "OK"
click_link "Make a Reservation"
within("#merge-order-missing-order-info-reminder") do
click_link "Make a Reservation"
end
click_link "Cancel"

expect(current_path).to eq(facility_order_path(facility, order))
Expand All @@ -225,10 +231,11 @@
end

it "requires a reservation to be set up before adding to the order" do
expect(page).to have_content("Your order includes order details that need your attention.")
expect(page).to have_content("Your order includes one or more incomplete items.")

click_button "OK"
click_link "Make a Reservation"
within("#merge-order-missing-order-info-reminder") do
click_link "Make a Reservation"
end
select facility2_account.to_s, from: "Payment Source"
click_button "Create"

Expand All @@ -240,8 +247,10 @@
end

it "brings you back to the facility order path on 'Cancel'" do
click_button "OK"
click_link "Make a Reservation"

within("#merge-order-missing-order-info-reminder") do
click_link "Make a Reservation"
end
click_link "Cancel"

expect(current_path).to eq(facility_order_path(facility, order))
Expand Down Expand Up @@ -273,8 +282,9 @@
# This is the second order for this facility so it has a merge_order set
expect(project.reload.orders.last.merge_with_order_id).to eq(second_facility_order.id)

click_button "OK"
click_link "Make a Reservation"
within("#merge-order-missing-order-info-reminder") do
click_link "Make a Reservation"
end
click_button "Create"

# After the reservation is created, the merge_order is cleared
Expand Down

0 comments on commit cf71620

Please sign in to comment.