Show combined checkbox when all terms required

The user should need to tick only one box to agree.

We don't remember yet if someone agreed to the platform TOS and
therefore the box is always unticked to start with.

Remembering the agreement is another issue:
https://github.com/openfoodfoundation/openfoodnetwork/issues/6328
This commit is contained in:
Maikel Linke
2021-03-10 17:04:52 +11:00
parent f73c32ce4b
commit 20f11327b5
4 changed files with 11 additions and 5 deletions

View File

@@ -3,7 +3,7 @@
module TermsAndConditionsHelper
def render_terms_and_conditions
if platform_terms_required? && terms_and_conditions_activated?
render("checkout/terms_and_conditions") + render("checkout/platform_terms_of_service")
render("checkout/all_terms_and_conditions")
elsif platform_terms_required?
render "checkout/platform_terms_of_service"
elsif terms_and_conditions_activated?

View File

@@ -0,0 +1,4 @@
%p
%input{ type: 'checkbox', id: 'accept_terms', ng: { model: "terms_and_conditions_accepted", init: "terms_and_conditions_accepted=false" } }
%label.small{for: "accept_terms"}
= t('.message_html', terms_and_conditions_link: link_to( t(".terms_and_conditions"), current_order.distributor.terms_and_conditions.url, target: '_blank'), tos_link: link_to(t(".terms_of_service"), Spree::Config.footer_tos_url, target: "_blank"))

View File

@@ -1249,6 +1249,10 @@ en:
platform_terms_of_service:
message_html: "I agree to the platform %{tos_link}."
terms_of_service: "Terms of Service"
all_terms_and_conditions:
message_html: "I agree to the seller's %{terms_and_conditions_link} and the platform %{tos_link}."
terms_and_conditions: "Terms and Conditions"
terms_of_service: "Terms of Service"
failed: "The checkout failed. Please let us know so that we can process your order."
shops:
hubs:

View File

@@ -218,13 +218,11 @@ feature "As a consumer I want to check out my cart", js: true do
expect(page).to have_link("Terms of Service", href: tos_url)
expect(page).to have_button("Place order now", disabled: true)
# Both Ts&Cs and TOS appear in the one label for the one checkbox.
check "Terms and Conditions"
expect(page).to have_button("Place order now", disabled: true)
check "Terms of Service"
expect(page).to have_button("Place order now", disabled: false)
uncheck "Terms and Conditions"
uncheck "Terms of Service"
expect(page).to have_button("Place order now", disabled: true)
end
end