Skip to content

Commit

Permalink
feat(web.domain): form edit owner contact
Browse files Browse the repository at this point in the history
ref: MANAGER-15831

Signed-off-by: Guillaume Hyenne <[email protected]>
  • Loading branch information
ghyenne committed Dec 31, 2024
1 parent a48d545 commit 92f1dda
Show file tree
Hide file tree
Showing 24 changed files with 1,728 additions and 316 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,19 @@
"price_ttc_label": "{{price}} TTC",
"price_free": "Inclus",
"price_label_yearly": "/an",
"country_BV": "Norvège - Île Bouvet",
"country_HM": "Royaume-Uni - Îles Heard et MacDonald",
"country_ASIA": "Asie",
"country_EU": "Europe",
"country_LTE": "Lituanie",
"country_WE": "États-Unis",
"country_AC": "Île de l'Ascension",
"country_AQ": "Antarctique",
"country_DG": "Diego Garcia",
"country_EA": "Ceuta",
"country_IC": "Îles Canaries",
"country_TA": "Tristan da Cunha (archipel)",
"country_XK": "République du Kosovo",
"country_AD": "Andorre",
"country_AE": "Émirats Arabes Unis",
"country_AF": "Afghanistan",
Expand Down Expand Up @@ -501,6 +514,25 @@
"country_ZA": "Afrique Du Sud",
"country_ZM": "Zambie",
"country_ZW": "Zimbabwe",
"language_de_DE": "Allemand",
"language_en_GB": "Anglais",
"language_en_AU": "Anglais (Australie)",
"language_en_US": "Anglais (Etats-Unis)",
"language_en_CA": "Anglais (Canada)",
"language_es_ES": "Espagnol",
"language_fr_FR": "Français",
"language_fr_CA": "Français (Canadien)",
"language_fr_MA": "Français (Maroc)",
"language_fr_SN": "Français (Sénégal)",
"language_fr_TN": "Français (Tunisie)",
"language_pl_PL": "Polonais",
"language_cs_CZ": "Tchéque",
"language_fi_FI": "Finnois",
"language_en_IE": "Irlandais",
"language_it_IT": "Italien",
"language_lt_LT": "Lituanien",
"language_pt_PT": "Portugais",
"language_nl_NL": "Néerlandais",
"navigation_left_licenses": "Licences",
"wizard_help": "Aide",
"wizard_action_question": "Quelle action voulez-vous effectuer ?",
Expand All @@ -517,9 +549,9 @@
"ovh_account_cb_expired_alert": "Votre carte bancaire par défaut est expirée. Rendez-vous dans <a href=\"{{t0}}\">la section facturation</a> pour la mettre à jour.",
"refresh": "Actualiser",
"core_new_window": "Nouvelle fenêtre",
"core_change_owner": "Changer de propriétaire",
"core_change_owner_order": "Pour changer le propriétaire de votre domaine, Il faut que vous passiez une commande directement sur notre site.",
"core_change_owner_error": "Impossible d’obtenir les informations necessaires au changement de propriétaire",
"core_change_owner": "Changer de titulaire",
"core_change_owner_order": "Pour changer le titulaire de votre domaine, Il faut que vous passiez une commande directement sur notre site.",
"core_change_owner_error": "Impossible d’obtenir les informations necessaires au changement de titulaire",
"contacts_management": "Contacts",
"expired_date": "Expiré le <strong>{{t0}}</strong>",
"expiration_date": "À renouveler manuellement le <strong>{{t0}}</strong>",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import controller from './dashboard.controller';
import template from './dashboard.html';
import controller from './contact.controller';
import template from './contact.html';

export default {
controller,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,28 @@ export const INFO_PROPERTIES = {
PHONE: 'phone',
NATIONAL_IDENTIFICATION_NUMBER: 'nationalIdentifcationNumber',
NICHANDLE: 'nichandle',
VAT: 'vat',
};

export const INFO_PROPERTIES_ARRAY = [
export const OWNER_INFO_PROPERTIES = {
ORGANISATION: 'organisation',
ORGANISATION_NAME: 'organisationName',
NAME: 'name',
LASTNAME: 'lastName',
FIRSTNAME: 'firstName',
ADDRESS: 'address',
LINE_1: 'address.line1',
ZIP: 'address.zip',
CITY: 'address.city',
EMAIL: 'email',
PHONE: 'phone',
NATIONAL_IDENTIFICATION_NUMBER: 'nationalIdentifcationNumber',
VAT: 'vat',
};

export const OWNER_NOT_FOUND = 'Not Found';

export const INFO_PROPERTIES_ORGANISATION_ARRAY = [
{
name: INFO_PROPERTIES.ORGANISATION,
values: [INFO_PROPERTIES.ORGANISATION, INFO_PROPERTIES.CORPORATION_TYPE],
Expand Down Expand Up @@ -45,8 +64,90 @@ export const INFO_PROPERTIES_ARRAY = [
values: [INFO_PROPERTIES.NATIONAL_IDENTIFICATION_NUMBER],
},
{
name: INFO_PROPERTIES.NICHANDLE,
values: [INFO_PROPERTIES.NICHANDLE],
name: INFO_PROPERTIES.VAT,
values: [INFO_PROPERTIES.VAT],
},
];

export const INFO_PROPERTIES_ARRAY = [
{
name: INFO_PROPERTIES.NAMES,
values: [INFO_PROPERTIES.FIRSTNAME, INFO_PROPERTIES.NAME],
},
{
name: INFO_PROPERTIES.ADDRESS,
values: [
INFO_PROPERTIES.ADDRESS,
INFO_PROPERTIES.COMPLEMENTARY_ADDRESS,
INFO_PROPERTIES.ZIP,
INFO_PROPERTIES.COUNTRY,
],
},
{
name: INFO_PROPERTIES.EMAIL,
values: [INFO_PROPERTIES.EMAIL],
},
{
name: INFO_PROPERTIES.PHONE,
values: [INFO_PROPERTIES.PHONE],
},
];

export const OWNER_INFO_PROPERTIES_ORGANISATION_ARRAY = [
{
name: OWNER_INFO_PROPERTIES.ORGANISATION,
values: [OWNER_INFO_PROPERTIES.ORGANISATION_NAME],
},
{
name: OWNER_INFO_PROPERTIES.NAME,
values: [OWNER_INFO_PROPERTIES.FIRSTNAME, OWNER_INFO_PROPERTIES.LASTNAME],
},
{
name: OWNER_INFO_PROPERTIES.ADDRESS,
values: [
OWNER_INFO_PROPERTIES.LINE_1,
OWNER_INFO_PROPERTIES.ZIP,
OWNER_INFO_PROPERTIES.CITY,
],
},
{
name: OWNER_INFO_PROPERTIES.EMAIL,
values: [OWNER_INFO_PROPERTIES.EMAIL],
},
{
name: OWNER_INFO_PROPERTIES.PHONE,
values: [OWNER_INFO_PROPERTIES.PHONE],
},
{
name: OWNER_INFO_PROPERTIES.NATIONAL_IDENTIFICATION_NUMBER,
values: [OWNER_INFO_PROPERTIES.NATIONAL_IDENTIFICATION_NUMBER],
},
{
name: OWNER_INFO_PROPERTIES.VAT,
values: [OWNER_INFO_PROPERTIES.VAT],
},
];

export const OWNER_INFO_PROPERTIES_ARRAY = [
{
name: OWNER_INFO_PROPERTIES.NAME,
values: [OWNER_INFO_PROPERTIES.FIRSTNAME, OWNER_INFO_PROPERTIES.LASTNAME],
},
{
name: OWNER_INFO_PROPERTIES.ADDRESS,
values: [
OWNER_INFO_PROPERTIES.LINE_1,
OWNER_INFO_PROPERTIES.ZIP,
OWNER_INFO_PROPERTIES.CITY,
],
},
{
name: INFO_PROPERTIES.EMAIL,
values: [INFO_PROPERTIES.EMAIL],
},
{
name: INFO_PROPERTIES.PHONE,
values: [INFO_PROPERTIES.PHONE],
},
];

Expand Down Expand Up @@ -93,5 +194,7 @@ export default {
INFO_PROPERTIES,
LEGAL_FORM_INDIVIDUAL,
INFO_PROPERTIES_ARRAY,
INFO_PROPERTIES_ORGANISATION_ARRAY,
OWNER_NOT_FOUND,
GUIDE_URL: GUIDE_URLS,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
import {
INFO_PROPERTIES,
INFO_PROPERTIES_ARRAY,
LEGAL_FORM_INDIVIDUAL,
GUIDE_URLS,
INFO_PROPERTIES_ORGANISATION_ARRAY,
OWNER_INFO_PROPERTIES,
OWNER_INFO_PROPERTIES_ORGANISATION_ARRAY,
OWNER_INFO_PROPERTIES_ARRAY,
} from './contact.constants';

export default class DomainContactDashboardCtrl {
/* @ngInject */
constructor(
$q,
$state,
ContactService,
coreConfig,
coreURLBuilder,
Domain,
Alerter,
$translate,
) {
this.$q = $q;
this.ContactService = ContactService;
this.DomainService = Domain;
this.$state = $state;
this.coreURLBuilder = coreURLBuilder;
this.Alerter = Alerter;
this.user = coreConfig.getUser();
this.isRegionCA = coreConfig.isRegion('CA');
this.$translate = $translate;
this.loading = true;
this.ovhSubsidiary = this.user.ovhSubsidiary;
this.GUIDE_URL = GUIDE_URLS[this.ovhSubsidiary] || GUIDE_URLS.DEFAULT;
this.USER_ACCOUNT_INFOS_LINK = this.coreURLBuilder.buildURL(
'dedicated',
'#/useraccount/infos',
);
}

$onInit() {
this.$q
.all({
domainInfos: this.DomainService.getServiceInfo(this.domainName),
ownerInfos: this.domain.whoisOwner?.id
? this.ContactService.getDomainContactInformations(
this.domain.whoisOwner.id,
)
: null,
})
.then(({ domainInfos, ownerInfos }) => {
this.domainInfos = domainInfos;
this.isNicAdmin = this.user.nichandle === this.domainInfos.contactAdmin;
this.ownerInfos = ownerInfos;
this.infoProperties =
this.user.legalform !== LEGAL_FORM_INDIVIDUAL
? INFO_PROPERTIES_ORGANISATION_ARRAY
: INFO_PROPERTIES_ARRAY;
this.ownerInfoProperties =
this.ownerInfos?.legalForm !== LEGAL_FORM_INDIVIDUAL
? OWNER_INFO_PROPERTIES_ORGANISATION_ARRAY
: OWNER_INFO_PROPERTIES_ARRAY;
})
.catch((error) => {
const errorMessage = error.data?.message || error.data;
this.Alerter.error(
[
this.$translate.instant(
'domain_tab_CONTACT_description_error_message',
),
errorMessage ? `(${errorMessage})` : '',
].join(' '),
'dashboardContact',
);
})
.finally(() => {
this.loading = false;
});
}

getDisplayedField(infoProperty) {
const handleNestedProp = (user, value) => {
return value === 'city.country'
? this.user.city.country
: this.user[value];
};
return infoProperty.values
.map((prop) => handleNestedProp(this.user, prop))
.join(' ');
}

editContact(owner = false) {
if (!owner) {
return window.open(this.USER_ACCOUNT_INFOS_LINK, '_blank');
}
return this.$state.go('app.domain.product.contact.edit', {
contactId: this.domain.whoisOwner.id,
});
}

showContactInfo(infoProperty) {
return (
(infoProperty.name === INFO_PROPERTIES.ORGANISATION &&
this.user.legalform !== LEGAL_FORM_INDIVIDUAL) ||
(!this.isRegionCA && INFO_PROPERTIES.EMAIL) ||
![INFO_PROPERTIES.ORGANISATION, INFO_PROPERTIES.EMAIL].includes(
infoProperty.name,
)
);
}

getDisplayedOwnerField(infoProperty) {
const handleNestedProp = (user, value) => {
if (value.includes('.')) {
const obj = this.ownerInfos[value.split('.')[0]];
return obj[value.split('.')[1]];
}
return this.ownerInfos[value];
};
return infoProperty.values
.map((prop) => handleNestedProp(this.ownerInfos, prop))
.join(' ');
}

showOwnerInfo(infoProperty) {
return (
(infoProperty.name === OWNER_INFO_PROPERTIES.ORGANISATION &&
this.ownerInfos.legalForm !== LEGAL_FORM_INDIVIDUAL) ||
infoProperty.name !== OWNER_INFO_PROPERTIES.ORGANISATION
);
}

openReassignContacts() {
window.open(this.contactsManagementUrl, '_blank');
}
}
Loading

0 comments on commit 92f1dda

Please sign in to comment.