diff --git a/app/assets/javascripts/admin/enterprises/controllers/enterprise_controller.js.coffee b/app/assets/javascripts/admin/enterprises/controllers/enterprise_controller.js.coffee index 55698d9e5f..51c38d0a3f 100644 --- a/app/assets/javascripts/admin/enterprises/controllers/enterprise_controller.js.coffee +++ b/app/assets/javascripts/admin/enterprises/controllers/enterprise_controller.js.coffee @@ -90,7 +90,3 @@ angular.module("admin.enterprises") $scope.translation = (key) -> t('js.admin.enterprises.form.images.' + key) - - $scope.show_terms_and_conditions_warning = (event) -> - unless confirm("All your buyers will have to agree to the Terms and Conditions again at checkout. Are you sure?") - event.preventDefault() diff --git a/app/assets/javascripts/admin/enterprises/directives/terms_and_conditions_warning.js.coffee b/app/assets/javascripts/admin/enterprises/directives/terms_and_conditions_warning.js.coffee new file mode 100644 index 0000000000..1072839def --- /dev/null +++ b/app/assets/javascripts/admin/enterprises/directives/terms_and_conditions_warning.js.coffee @@ -0,0 +1,29 @@ +angular.module("admin.enterprises").directive 'termsAndConditionsWarning', ($compile, $templateCache, DialogDefaults, $timeout) -> + restrict: 'A' + scope: true + + link: (scope, element, attr) -> + # This file input click handler will hold the browser file input dialog and show a warning modal + scope.hold_file_input_and_show_warning_modal = (event) -> + event.preventDefault() + scope.template = $compile($templateCache.get('admin/modals/terms_and_conditions_warning.html'))(scope) + scope.template.dialog(DialogDefaults) + scope.template.dialog('open') + scope.$apply() + + element.bind 'click', scope.hold_file_input_and_show_warning_modal + + # When the user presses continue in the warning modal, we open the browser file input dialog + scope.continue = -> + scope.template.dialog('close') + + # unbind warning modal handler and click file input again to open the browser file input dialog + element.unbind('click').trigger('click') + # afterwards, bind warning modal handler again so that the warning is shown the next time + $timeout -> + element.bind 'click', scope.hold_file_input_and_show_warning_modal + return + + scope.close = -> + scope.template.dialog('close') + return diff --git a/app/assets/javascripts/templates/admin/modals/terms_and_conditions_warning.html.haml b/app/assets/javascripts/templates/admin/modals/terms_and_conditions_warning.html.haml new file mode 100644 index 0000000000..13eed6fe85 --- /dev/null +++ b/app/assets/javascripts/templates/admin/modals/terms_and_conditions_warning.html.haml @@ -0,0 +1,14 @@ +%div + .margin-bottom-30.text-center + .text-big + {{ 'js.admin.modals.terms_and_conditions_warning.title' | t }} + .margin-bottom-30 + %p + {{ 'js.admin.modals.terms_and_conditions_warning.message_1' | t }} + .margin-bottom-30 + %p + {{ 'js.admin.modals.terms_and_conditions_warning.message_2' | t }} + + .text-center + %input.button.red{ type: 'button', value: t('js.admin.modals.close'), ng: { click: 'close()' } } + %input.button.red{ type: 'button', value: t('js.admin.modals.continue'), ng: { click: 'continue()' } } diff --git a/app/views/admin/enterprises/form/_business_details.html.haml b/app/views/admin/enterprises/form/_business_details.html.haml index 7c72b1a4b2..1bade5b580 100644 --- a/app/views/admin/enterprises/form/_business_details.html.haml +++ b/app/views/admin/enterprises/form/_business_details.html.haml @@ -43,7 +43,7 @@ = t('.uploaded_on') = '{{ Enterprise.terms_and_conditions_updated_at }}' .pad-top - = f.file_field :terms_and_conditions, accept: 'application/pdf', 'ng-click' => 'show_terms_and_conditions_warning($event)' + = f.file_field :terms_and_conditions, accept: 'application/pdf', 'terms-and-conditions-warning' => 'true' .pad-top %a.button.red{ href: '', ng: {click: 'removeTermsAndConditions()', if: 'Enterprise.terms_and_conditions'} } = t('.remove_terms_and_conditions') diff --git a/config/locales/en.yml b/config/locales/en.yml index 42f6edcf2a..014cfe36f5 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2520,6 +2520,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using modals: got_it: "Got it" close: "Close" + continue: "Continue" invite: "Invite" invite_title: "Invite an unregistered user" tag_rule_help: @@ -2542,6 +2543,10 @@ See the %{link} to find out more about %{sitename}'s features and to start using title: "Uploading Terms and Conditions" message_1: "Terms and Conditions are the contract between you, the seller, and the shopper. If you upload a file here shoppers must accept your Terms and Conditions in order to complete checkout. For the shopper this will appear as a checkbox at checkout that must be checked in order to proceed with checkout. We highly recommend you upload Terms and Conditions in alignment with national legislation." message_2: "Shoppers will only be required to accept Terms and Conditions once. However if you change you Terms and Conditions shoppers will again be required to accept them before they can checkout." + terms_and_conditions_warning: + title: "Uploading Terms and Conditions" + message_1: "All your buyers will have to agree to them again at checkout." + message_2: "For buyers with subscriptions, you need to email them the changes for now, nothing will notify them about this change." panels: save: SAVE saved: SAVED