From dbc33ee11f176c141ad6b7c1fe58007952ed2527 Mon Sep 17 00:00:00 2001 From: Jacques Larique Date: Thu, 6 Jul 2023 08:54:34 +0200 Subject: [PATCH] feat(dedicated.account): add phone typeand sms consent to account edition ref: MANAGER-11435 Signed-off-by: Jacques Larique --- ...account-form-field-component.controller.js | 26 +++++- .../new-account-form-field-component.html | 26 +++++- .../new-account-form-component.constants.js | 8 ++ .../new-account-form-controller.js | 84 ++++++++++++++----- .../translations/Messages_fr_FR.json | 5 +- .../account/user/infos/user-infos.service.js | 21 +++++ 6 files changed, 144 insertions(+), 26 deletions(-) diff --git a/packages/manager/apps/dedicated/client/app/account/user/components/newAccountForm/field/new-account-form-field-component.controller.js b/packages/manager/apps/dedicated/client/app/account/user/components/newAccountForm/field/new-account-form-field-component.controller.js index 7539c548ca9f..e0fb726cbba9 100644 --- a/packages/manager/apps/dedicated/client/app/account/user/components/newAccountForm/field/new-account-form-field-component.controller.js +++ b/packages/manager/apps/dedicated/client/app/account/user/components/newAccountForm/field/new-account-form-field-component.controller.js @@ -57,6 +57,17 @@ export default class NewAccountFormFieldController { }); } + // reset sms consent value when phone type is no longer 'mobile' + if (this.rule.fieldName === 'smsConsent') { + this.$scope.$on('account.smsConsent.reset', () => { + // switch value to false only if it is true + if (this.value) { + this.onChange(); + this.value = false; + } + }); + } + // handle special phone prefix case if (this.getFieldType() === 'phone') { this.$scope.$watch( @@ -218,6 +229,9 @@ export default class NewAccountFormFieldController { if (this.rule.fieldType) { return this.rule.fieldType; } + if ((this.rule.fieldName || '') === this.FIELD_NAME_LIST.phoneType) { + return 'radio'; + } if (this.rule.in) { return 'select'; } @@ -268,8 +282,11 @@ export default class NewAccountFormFieldController { }; }); - result = this.$filter('orderBy')(result, 'translated', false, (a, b) => - String(a.value).localeCompare(String(b.value)), + result = this.$filter('orderBy')( + result, + 'translated', + this.rule.fieldName === this.FIELD_NAME_LIST.phoneType, + (a, b) => String(a.value).localeCompare(String(b.value)), ); // if there is only a single value, auto select it @@ -347,6 +364,11 @@ export default class NewAccountFormFieldController { return ['phone', 'fax'].includes(this.rule.fieldName); } + shouldDisplayLabel() { + const type = this.getFieldType(); + return type !== 'checkbox' && type !== 'radio'; + } + // callback for when model changed onChange() { let { value } = this; diff --git a/packages/manager/apps/dedicated/client/app/account/user/components/newAccountForm/field/new-account-form-field-component.html b/packages/manager/apps/dedicated/client/app/account/user/components/newAccountForm/field/new-account-form-field-component.html index a3a65ab82d0b..01cae3e52dd1 100644 --- a/packages/manager/apps/dedicated/client/app/account/user/components/newAccountForm/field/new-account-form-field-component.html +++ b/packages/manager/apps/dedicated/client/app/account/user/components/newAccountForm/field/new-account-form-field-component.html @@ -6,10 +6,7 @@ 'oui-field_error': $ctrl.isInvalid() }" > -
+