Move rendering logic of terms to helper

Preparing for a third option to display.
This commit is contained in:
Maikel Linke
2021-03-10 16:44:32 +11:00
parent 4af0e61163
commit f73c32ce4b
3 changed files with 14 additions and 6 deletions

View File

@@ -1,6 +1,16 @@
# frozen_string_literal: true
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")
elsif platform_terms_required?
render "checkout/platform_terms_of_service"
elsif terms_and_conditions_activated?
render "checkout/terms_and_conditions"
end
end
def platform_terms_required?
Spree::Config.shoppers_require_tos
end

View File

@@ -15,8 +15,7 @@
= render "checkout/shipping", f: f
= render "checkout/payment", f: f
= render "checkout/already_ordered", f: f if show_bought_items?
= render "checkout/terms_and_conditions"
= render "checkout/platform_terms_of_service" if platform_terms_required?
= render_terms_and_conditions
%p
%button.button.primary{ type: :submit, ng: { disabled: "terms_and_conditions_accepted == false || platform_tos_accepted == false" } }
= t :checkout_send

View File

@@ -1,4 +1,3 @@
- if terms_and_conditions_activated?
%p
%input{ type: 'checkbox', id: 'accept_terms', ng: { model: "terms_and_conditions_accepted", init: "terms_and_conditions_accepted=#{terms_and_conditions_already_accepted?}" } }
%label.small{for: "accept_terms"}= t('.message_html', terms_and_conditions_link: link_to( t( '.link_text' ), current_order.distributor.terms_and_conditions.url, target: '_blank'))
%p
%input{ type: 'checkbox', id: 'accept_terms', ng: { model: "terms_and_conditions_accepted", init: "terms_and_conditions_accepted=#{terms_and_conditions_already_accepted?}" } }
%label.small{for: "accept_terms"}= t('.message_html', terms_and_conditions_link: link_to( t( '.link_text' ), current_order.distributor.terms_and_conditions.url, target: '_blank'))