Skip to content

Commit

Permalink
sync: master to develop
Browse files Browse the repository at this point in the history
Sync develop & master
  • Loading branch information
anooparveti authored Oct 24, 2024
2 parents 01b5665 + a588912 commit 06a2d4a
Show file tree
Hide file tree
Showing 214 changed files with 7,534 additions and 162 deletions.
4 changes: 3 additions & 1 deletion packages/components/ng-ovh-contact/src/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ export default /* @ngInject */ function($q, $timeout, ovhContact, OvhContact) {

self.startContactCreation = function startContactCreation() {
tmpContact = self.contact;
self.contact = new OvhContact();
const { customContactObject } = self.choiceOptions.options;
self.contact = customContactObject || new OvhContact();

return self.contact;
};

Expand Down
4 changes: 4 additions & 0 deletions packages/components/ng-ovh-contact/src/edit/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ export default {
},
template,
controller,
bindings: {
options: '=?ovhContactChoiceOptions',
customList: '=?ovhContactChoiceCustomList',
},
};
219 changes: 121 additions & 98 deletions packages/components/ng-ovh-contact/src/edit/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import moment from 'moment';
export default /* @ngInject */ function(
$timeout,
$anchorScroll,
$http,
ovhContact,
OvhContact,
CONTACT_EDITION,
) {
const self = this;
Expand Down Expand Up @@ -46,8 +48,17 @@ export default /* @ngInject */ function(
const savePromise = self.ovhContactCtrl.contact.id
? self.ovhContactCtrl.contact.save()
: self.ovhContactCtrl.contact
.create()
.then(() => ovhContact.addContact(self.ovhContactCtrl.contact));
.create(
$http,
OvhContact,
this.customList,
self.ovhContactCtrl.contact,
)
.then(() =>
!self.options.customFieldForm
? ovhContact.addContact(self.ovhContactCtrl.contact)
: null,
);

return savePromise
.then(
Expand All @@ -68,12 +79,16 @@ export default /* @ngInject */ function(
self.saveError = null;

self.sortedFieldsByCountry =
self.options.customSortFieldForm ||
CONTACT_EDITION[`SORTED_FIELDS_${self.ovhContactCtrl.contact.country}`] ||
CONTACT_EDITION.SORTED_FIELDS_DEFAULT;

alwaysVisibleFieldsByCountry =
self.options.customFieldForm ||
CONTACT_EDITION[
`ALWAYS_VISIBLE_FIELDS_${self.ovhContactCtrl.contact.country}`
] || CONTACT_EDITION.ALWAYS_VISIBLE_FIELDS_DEFAULT;
] ||
CONTACT_EDITION.ALWAYS_VISIBLE_FIELDS_DEFAULT;
}

function formatPhoneNumbers(phoneNumber) {
Expand All @@ -87,7 +102,7 @@ export default /* @ngInject */ function(
self.creationRules[field].canBeNull === 0
);

if (!isVisible && alwaysVisibleFieldsByCountry.indexOf(field) !== -1) {
if (!isVisible && alwaysVisibleFieldsByCountry.includes(field)) {
isVisible = true;
}

Expand Down Expand Up @@ -137,100 +152,104 @@ export default /* @ngInject */ function(
options = {},
) {
const inputToInitialize = document.getElementById(inputId);
const telInput = intlTelInput(inputToInitialize, {
initialCountry: self.ovhContactCtrl.contact.address.country,
nationalMode: false,
preferredCountries: [''],
utilsScript: 'build/js/utils.js',
...options,
});

inputToInitialize.addEventListener(
'blur',
(() =>
function forcePhoneFormat() {
// use timeout to force phone number to be undefined if only country dial code or to be
// prefixed by "+"(international format) if phone number value starts with country dialcode
$timeout(() => {
const countryData = telInput.getSelectedCountryData();
if (
self.ovhContactCtrl.contact[inputToInitialize.id] ===
countryData.dialCode ||
self.ovhContactCtrl.contact[inputToInitialize.id] ===
`+${countryData.dialCode}` ||
self.ovhContactCtrl.contact[inputToInitialize.id] === `+`
) {
self.ovhContactCtrl.contact[inputToInitialize.id] = undefined;
} else if (
startsWith(
self.ovhContactCtrl.contact[inputToInitialize.id],
countryData.dialCode,
)
) {
self.ovhContactCtrl.contact[inputToInitialize.id] = `+${
self.ovhContactCtrl.contact[inputToInitialize.id]
}`;
}
}, 100);
})(),
);

inputToInitialize.addEventListener(
'keyup',
(() =>
function forcePlusChar() {
$timeout(() => {
if (
!startsWith(
self.ovhContactCtrl.contact[inputToInitialize.id],
'+',
)
) {
self.ovhContactCtrl.contact[inputToInitialize.id] = `+${self
.ovhContactCtrl.contact[inputToInitialize.id] || ''}`;
}
}, 100);
})(),
);
if (inputToInitialize) {
const telInput = intlTelInput(inputToInitialize, {
initialCountry: self.ovhContactCtrl.contact.address.country,
nationalMode: false,
preferredCountries: [''],
utilsScript: 'build/js/utils.js',
...options,
});

inputToInitialize.addEventListener(
'focus',
(() =>
function setCountryOnFocus() {
inputToInitialize.addEventListener(
'blur',
(() =>
function forcePhoneFormat() {
// use timeout to force phone number to be undefined if only country dial code or to be
// prefixed by "+"(international format) if phone number value starts with country dialcode
$timeout(() => {
const countryData = telInput.getSelectedCountryData();
if (
self.ovhContactCtrl.contact[inputToInitialize.id] ===
countryData.dialCode ||
self.ovhContactCtrl.contact[inputToInitialize.id] ===
`+${countryData.dialCode}` ||
self.ovhContactCtrl.contact[inputToInitialize.id] === `+`
) {
self.ovhContactCtrl.contact[inputToInitialize.id] = undefined;
} else if (
startsWith(
self.ovhContactCtrl.contact[inputToInitialize.id],
countryData.dialCode,
)
) {
self.ovhContactCtrl.contact[inputToInitialize.id] = `+${
self.ovhContactCtrl.contact[inputToInitialize.id]
}`;
}
}, 100);
})(),
);

inputToInitialize.addEventListener(
'keyup',
(() =>
function forcePlusChar() {
$timeout(() => {
if (
!startsWith(
self.ovhContactCtrl.contact[inputToInitialize.id],
'+',
)
) {
self.ovhContactCtrl.contact[inputToInitialize.id] = `+${self
.ovhContactCtrl.contact[inputToInitialize.id] || ''}`;
}
}, 100);
})(),
);

inputToInitialize.addEventListener(
'focus',
(() =>
function setCountryOnFocus() {
$timeout(() => {
const countryData = telInput.getSelectedCountryData();
if (!self.ovhContactCtrl.contact[inputToInitialize.id]) {
self.ovhContactCtrl.contact[
inputToInitialize.id
] = `+${countryData.dialCode}`;
}
}, 100);
})(),
);

const getSetValidityFunction = () =>
function setValidity() {
$timeout(() => {
const countryData = telInput.getSelectedCountryData();
if (!self.ovhContactCtrl.contact[inputToInitialize.id]) {
self.ovhContactCtrl.contact[
inputToInitialize.id
] = `+${countryData.dialCode}`;
}
}, 100);
})(),
);
self.ovhContactEdit[inputToInitialize.id].$setValidity(
'internationalPhoneNumber',
telInput.isValidNumber(),
);
}, 100); // Setting validity on blur, right after the forcePhoneFormat has been done
};

inputToInitialize.addEventListener('blur', getSetValidityFunction());
inputToInitialize.addEventListener('keydown', getSetValidityFunction());
inputToInitialize.addEventListener(
'keypress',
function blockNonNumericKeys(event) {
if (event.charCode < 48 || event.charCode > 57) {
event.preventDefault();
event.stopPropagation();
}
},
);

const getSetValidityFunction = () =>
function setValidity() {
$timeout(() => {
self.ovhContactEdit[inputToInitialize.id].$setValidity(
'internationalPhoneNumber',
telInput.isValidNumber(),
);
}, 100); // Setting validity on blur, right after the forcePhoneFormat has been done
};

inputToInitialize.addEventListener('blur', getSetValidityFunction());
inputToInitialize.addEventListener('keydown', getSetValidityFunction());
inputToInitialize.addEventListener('keypress', function blockNonNumericKeys(
event,
) {
if (event.charCode < 48 || event.charCode > 57) {
event.preventDefault();
event.stopPropagation();
}
});

telInput.setNumber(initialValue);
return telInput;
telInput.setNumber(initialValue);
return telInput;
}
return null;
};

self.$onInit = function $onInit() {
Expand All @@ -242,7 +261,7 @@ export default /* @ngInject */ function(
return ovhContact
.getCreationRules()
.then((rules) => {
self.creationRules = rules;
self.creationRules = self.options.customFieldRules || rules;
self.ovhContactCtrl.manageOnInit();
})
.finally(() => {
Expand All @@ -260,7 +279,11 @@ export default /* @ngInject */ function(
};

self.$onDestroy = function $onDestroy() {
self.itiPhone.destroy();
self.itiCellPhone.destroy();
if (self.itiPhone) {
self.itiPhone.destroy();
}
if (self.itiCellPhone) {
self.itiCellPhone.destroy();
}
};
}
2 changes: 1 addition & 1 deletion packages/components/ng-ovh-contact/src/edit/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@
>
<div
data-ng-switch-when="true"
data-ng-switch="field.indexOf('address') > -1"
data-ng-switch="field.indexOf('address') > -1 && !$ctrl.options.customFieldForm"
>
<!-- SPECIAL FOR ADDRESS FIELD BECAUSE NGMODEL CAN'T ACCESS TO contact['address.city'] -->
<div
Expand Down
2 changes: 2 additions & 0 deletions packages/components/ng-ovh-contact/src/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

<ovh-contact-edit
data-ng-if="$ctrl.onlyCreate || $ctrl.contact.inEdition"
data-ovh-contact-choice-options="$ctrl.choiceOptions.options"
data-ovh-contact-choice-custom-list="$ctrl.choiceOptions.customList"
>
</ovh-contact-edit>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,7 @@
"ovh_contact_edit_mandatory_fields": "Die mit * gekennzeichneten Felder sind Pflichtfelder.",
"ovh_contact_edit_mandatory_field": "Dieses Feld ist ein Pflichtfeld.",
"ovh_contact_edit_invalid_email": "Der Wert muss eine gültige E-Mail-Adresse sein.",
"ovh_contact_edit_invalid_phone": "Bitte überprüfen Sie das Format der Telefonnummer."
"ovh_contact_edit_invalid_phone": "Bitte überprüfen Sie das Format der Telefonnummer.",
"ovh_contact_edit_label_address_cityName": "Stadt",
"ovh_contact_edit_label_address_zipCode": "Postleitzahl"
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,7 @@
"ovh_contact_edit_mandatory_fields": "Fields marked with a &#42; are mandatory.",
"ovh_contact_edit_mandatory_field": "This field is mandatory.",
"ovh_contact_edit_invalid_email": "This field must contain a valid email address.",
"ovh_contact_edit_invalid_phone": "Please check the telephone number format."
"ovh_contact_edit_invalid_phone": "Please check the telephone number format.",
"ovh_contact_edit_label_address_cityName": "City",
"ovh_contact_edit_label_address_zipCode": "Postcode"
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,7 @@
"ovh_contact_edit_mandatory_fields": "Los campos marcados con &#42; son obligatorios.",
"ovh_contact_edit_mandatory_field": "Este campo es obligatorio.",
"ovh_contact_edit_invalid_email": "El campo debe contener una dirección de correo electrónico válida.",
"ovh_contact_edit_invalid_phone": "Por favor, compruebe el formato del número de teléfono."
"ovh_contact_edit_invalid_phone": "Por favor, compruebe el formato del número de teléfono.",
"ovh_contact_edit_label_address_cityName": "Localidad",
"ovh_contact_edit_label_address_zipCode": "Código postal"
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@
"ovh_contact_edit_fieldset_profile": "Profil",
"ovh_contact_edit_fieldset_contacts": "Contacts",
"ovh_contact_edit_fieldset_legal": "Données juridiques",
"ovh_contact_edit_label_gender": "Sexe",
"ovh_contact_edit_label_nationality": "Nationalité",
"ovh_contact_edit_label_language": "Langue d'échange",
"ovh_contact_edit_label_country": "Pays",
"ovh_contact_edit_label_address_country": "Pays",
"ovh_contact_edit_label_address_province": "Province",
"ovh_contact_edit_label_legal_form": "Civilité",
"ovh_contact_edit_label_email_confirmation": "Confirmation email",
"ovh_contact_edit_label_organisation": "Organisation",
"ovh_contact_edit_label_spare_email": "Email de secours",
"ovh_contact_edit_label_password": "Mot de passe",
"ovh_contact_edit_label_password_confirmation": "Confirmation du mot de passe",
Expand All @@ -29,6 +26,8 @@
"ovh_contact_edit_label_address_line_3": "Adresse (complément 2)",
"ovh_contact_edit_label_address_other_details": "Adresse (autre)",
"ovh_contact_edit_label_address_zip": "Code postal",
"ovh_contact_edit_label_address_cityName": "Ville",
"ovh_contact_edit_label_address_zipCode": "Code postal",
"ovh_contact_edit_label_address_city": "Ville",
"ovh_contact_edit_label_birth_day": "Date d'anniversaire",
"ovh_contact_edit_label_phone": "Téléphone",
Expand All @@ -45,9 +44,6 @@
"ovh_contact_edit_label_birth_country": "Pays de naissance",
"ovh_contact_edit_label_national_identification_number": "Code fiscal",
"ovh_contact_edit_label_cell_phone": "Téléphone mobile",
"ovh_contact_edit_label_nationality": "Nationalité",
"ovh_contact_edit_label_legal_form": "Civilité",
"ovh_contact_edit_label_country": "Pays",
"ovh_contact_edit_legalform_individual": "Individuel",
"ovh_contact_edit_legalform_association": "Association",
"ovh_contact_edit_legalform_corporation": "Entreprise",
Expand Down
Loading

0 comments on commit 06a2d4a

Please sign in to comment.