From 1eed8ce7f5ebb74bc628f820d644ecdedaabd47d Mon Sep 17 00:00:00 2001 From: pratishta Date: Wed, 18 Dec 2024 11:16:01 -0500 Subject: [PATCH 1/3] Disable all input when subscribing Co-authored-by: David Hochbaum --- client/app/components/subscription-form.js | 6 ++---- client/app/controllers/subscribe.js | 7 +++++++ client/app/templates/components/subscription-form.hbs | 8 ++++---- client/app/templates/subscribe.hbs | 4 ++-- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/client/app/components/subscription-form.js b/client/app/components/subscription-form.js index 0b1259a6..a3417229 100644 --- a/client/app/components/subscription-form.js +++ b/client/app/components/subscription-form.js @@ -11,8 +11,6 @@ export default class SubscriptionFormComponent extends Component { isCommunityDistrict = false; - isSubmitting = false; - showSubscriptionUpdateConfirmationModal = false; updateStatus = 'none'; @@ -93,7 +91,7 @@ export default class SubscriptionFormComponent extends Component { async subscribe() { if (!this.canBeSubmitted) { return; } - set(this, 'isSubmitting', true); + this.args.setIsSubmitting(true) const requestBody = { email: this.args.email, subscriptions: {} }; if (this.isCommunityDistrict) { @@ -143,7 +141,7 @@ export default class SubscriptionFormComponent extends Component { if (!this.args.isUpdate) window.location.pathname = '/subscribed'; - set(this, 'isSubmitting', false); + this.args.setIsSubmitting(false) if (this.args.isUpdate) { set(this, 'showSubscriptionUpdateConfirmationModal', true); diff --git a/client/app/controllers/subscribe.js b/client/app/controllers/subscribe.js index a1f195bd..f3ba8de1 100644 --- a/client/app/controllers/subscribe.js +++ b/client/app/controllers/subscribe.js @@ -5,6 +5,8 @@ import ENV from 'labs-zap-search/config/environment'; import { validateEmail } from '../helpers/validate-email'; export default class SubscribeController extends Controller { + isSubmitting = false; + lastEmailChecked = ''; emailAlreadyExists = false; @@ -20,6 +22,11 @@ export default class SubscribeController extends Controller { return (this.emailAlreadyExists || this.emailNeedsConfirmation); } + @action + setIsSubmitting(isSubmittingValue) { + this.set('isSubmitting', isSubmittingValue); + } + @action async checkExistingEmail(event) { const email = event.target.value; diff --git a/client/app/templates/components/subscription-form.hbs b/client/app/templates/components/subscription-form.hbs index 9c4df427..2c1d008a 100644 --- a/client/app/templates/components/subscription-form.hbs +++ b/client/app/templates/components/subscription-form.hbs @@ -9,7 +9,7 @@