Add warning when uploading a file

This commit is contained in:
Luis Ramos
2020-09-29 11:43:14 +01:00
parent be35f97622
commit 3b682bc47f
5 changed files with 49 additions and 5 deletions

View File

@@ -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()

View File

@@ -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

View File

@@ -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()' } }

View File

@@ -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')

View File

@@ -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