Commit ddc30611 authored by Hamza HRAMCHI's avatar Hamza HRAMCHI
Browse files

FIX #18428 TIME 0:52 rename uri to url + display m2m_email for contact

parent b55fa5da
......@@ -104,7 +104,7 @@
*ngIf="(field.unit === unit.id && unit.id !== 'address') || (field.unit === unit.id && unit.id === 'address' && !addressBANMode)">
<p mat-line class="contact-content" *ngIf="field.display">
<ng-container
*ngIf="field.type === 'string' && field.id !== 'uri' && field.id !== 'externalId_m2m' && field.id != 'addressCountry' && field.id != 'addressPostcode' && field.id != 'addressTown'">
*ngIf="field.type === 'string' && field.id !== 'url' && field.id !== 'externalId_m2m' && field.id != 'addressCountry' && field.id != 'addressPostcode' && field.id != 'addressTown'">
<mat-form-field>
<input matInput [formControl]="field.control" [placeholder]="field.label"
(blur)="checkCompany(field);checkFilling();" (ngModelChange)="toUpperCase(field, $event)" [required]="field.required">
......@@ -184,7 +184,7 @@
<mat-error *ngIf="field.control.status!=='VALID' && field.control.touched">
{{getErrorMsg(field.control.errors)}}</mat-error>
</ng-container>
<ng-container *ngIf="field.id === 'uri'">
<ng-container *ngIf="field.id === 'url'">
<mat-form-field *ngIf="annuaryEnabled">
<input type="text" #autoCompleteInputCommunicationMean
[placeholder]="'lang.searchCommunicationMean' | translate" matInput
......
......@@ -269,7 +269,7 @@ export class ContactsFormComponent implements OnInit {
values: []
},
{
id: 'uri',
id: 'url',
unit: 'maarch2maarch',
label: this.translate.instant('lang.communicationMean'),
desc: `${this.translate.instant('lang.communicationMeanDesc')} (${this.translate.instant('lang.see')} <a href="${this.maarch2maarchUrl}" target="_blank">MAARCH2MAARCH</a>)`,
......@@ -799,7 +799,7 @@ export class ContactsFormComponent implements OnInit {
value: item.control.value
}));
const communicationMeans = {
uri: m2mData.find((item: any) => item.id === 'uri').value,
url: m2mData.find((item: any) => item.id === 'url').value,
externalId_m2m: m2mData.find((item: any) => item.id === 'externalId_m2m').value,
login: m2mData.find((item: any) => item.id === 'login').value,
password: m2mData.find((item: any) => item.id === 'password').value,
......@@ -911,9 +911,14 @@ export class ContactsFormComponent implements OnInit {
setCommunicationMeans(communicationMeans: any) {
let indexField = -1;
Object.keys(communicationMeans).forEach(element => {
element = element === 'email' ? 'email_m2m' : element;
indexField = this.contactForm.map(field => field.id).indexOf(element);
if (!this.isEmptyValue(communicationMeans[element]) && indexField > -1 && ['uri', 'login'].indexOf(element) > -1) {
this.contactForm[indexField].control.setValue(communicationMeans[element]);
if (!this.isEmptyValue(communicationMeans[element === 'email_m2m' ? 'email' : element]) && indexField > -1 && ['url', 'login', 'email_m2m'].indexOf(element) > -1) {
if (element === 'email_m2m') {
this.contactForm[indexField].control.setValue(communicationMeans['email']);
} else {
this.contactForm[indexField].control.setValue(communicationMeans[element]);
}
this.contactForm[indexField].display = true;
}
});
......@@ -958,7 +963,7 @@ export class ContactsFormComponent implements OnInit {
removeField(field: any) {
field.display = !field.display;
field.control.reset();
if ((field.id === 'externalId_m2m' || field.id === 'uri') && !field.display) {
if ((field.id === 'externalId_m2m' || field.id === 'url') && !field.display) {
const indexFieldAnnuaryId = this.contactForm.map(item => item.id).indexOf('externalId_m2m_annuary_id');
if (indexFieldAnnuaryId > -1) {
this.contactForm.splice(indexFieldAnnuaryId, 1);
......@@ -977,7 +982,7 @@ export class ContactsFormComponent implements OnInit {
initAutocompleteCommunicationMeans() {
this.communicationMeanInfo = this.translate.instant('lang.autocompleteInfo');
this.communicationMeanResult = [];
const indexFieldCommunicationMeans = this.contactForm.map(field => field.id).indexOf('uri');
const indexFieldCommunicationMeans = this.contactForm.map(field => field.id).indexOf('url');
this.contactForm[indexFieldCommunicationMeans].control.valueChanges
.pipe(
debounceTime(300),
......@@ -1004,7 +1009,7 @@ export class ContactsFormComponent implements OnInit {
}
selectCommunicationMean(ev: any) {
const indexFieldCommunicationMeans = this.contactForm.map(field => field.id).indexOf('uri');
const indexFieldCommunicationMeans = this.contactForm.map(field => field.id).indexOf('url');
this.contactForm[indexFieldCommunicationMeans].control.setValue(ev.option.value.communicationValue);
const indexFieldExternalId = this.contactForm.map(field => field.id).indexOf('externalId_m2m');
......@@ -1018,7 +1023,7 @@ export class ContactsFormComponent implements OnInit {
initAutocompleteExternalIdM2M() {
this.externalId_m2mInfo = this.translate.instant('lang.autocompleteInfo');
this.externalId_m2mResult = [];
const indexFieldCommunicationMeans = this.contactForm.map(field => field.id).indexOf('uri');
const indexFieldCommunicationMeans = this.contactForm.map(field => field.id).indexOf('url');
const indexFieldExternalId = this.contactForm.map(field => field.id).indexOf('externalId_m2m');
this.contactForm[indexFieldExternalId].control.valueChanges
.pipe(
......
......@@ -9,7 +9,7 @@
<div style="width: 100%;">
<mat-form-field>
<mat-label>{{'lang.uri' | translate}}</mat-label>
<input matInput [formControl]="communications.uri">
<input matInput [formControl]="communications.url" [placeholder]="'lang.uriServerExample' | translate">
<mat-hint align="end" [innerHTML]="'lang.m2mUriDesc' | translate"></mat-hint>
</mat-form-field>
<mat-form-field>
......
......@@ -38,7 +38,7 @@ export class MaarchToMaarchParametersComponent implements OnInit {
attachmentTypeId: new FormControl(),
};
communications = {
uri: new FormControl('https://demo.maarchcourrier.com'),
url: new FormControl('https://demo.maarchcourrier.com'),
login: new FormControl('cchaplin'),
password: new FormControl(null),
email: new FormControl(null),
......@@ -197,68 +197,70 @@ export class MaarchToMaarchParametersComponent implements OnInit {
this.http.get('../rest/m2m/configuration').pipe(
map((data: any) => data.configuration),
tap((data: any) => {
this.passwordAlreadyExists = data.communications.passwordAlreadyExists ? true : false;
Object.keys(this.communications).forEach((elemId: any) => {
if (['uri', 'login', 'email'].indexOf(elemId) > -1) {
this.communications[elemId].setValue(data.communications[elemId]);
}
this.communications[elemId].valueChanges
.pipe(
debounceTime(1000),
tap((value: any) => {
this.saveConfiguration();
}),
).subscribe();
});
Object.keys(this.metadata).forEach(elemId => {
this.setDefaultValue(elemId, data.metadata[elemId]);
this.metadata[elemId].valueChanges
.pipe(
debounceTime(300),
tap((value: any) => {
this.saveConfiguration();
}),
).subscribe();
});
Object.keys(this.annuary).forEach(elemId => {
if (['annuaries'].indexOf(elemId) === -1) {
this.annuary[elemId].setValue(data.annuary[elemId]);
this.annuary[elemId].valueChanges
if (!this.functionsService.empty(data)) {
this.passwordAlreadyExists = data.communications.passwordAlreadyExists ? true : false;
Object.keys(this.communications).forEach((elemId: any) => {
if (['url', 'login', 'email'].indexOf(elemId) > -1) {
this.communications[elemId].setValue(data.communications[elemId]);
}
this.communications[elemId].valueChanges
.pipe(
debounceTime(1000),
tap((value: any) => {
if (elemId === 'enabled' && value === true && this.annuary.annuaries.length === 0) {
this.addAnnuary();
} else {
this.saveConfiguration();
}
this.saveConfiguration();
}),
).subscribe();
});
Object.keys(this.metadata).forEach(elemId => {
this.setDefaultValue(elemId, data.metadata[elemId]);
this.metadata[elemId].valueChanges
.pipe(
debounceTime(300),
tap((value: any) => {
this.saveConfiguration();
}),
).subscribe();
} else {
this.annuary[elemId] = [];
data.annuary[elemId].forEach((annuaryConf: any, index: number) => {
this.annuary[elemId].push({});
Object.keys(annuaryConf).forEach(annuaryItem => {
this.annuary[elemId][index][annuaryItem] = new FormControl(data.annuary[elemId][index][annuaryItem]);
this.annuary[elemId][index][annuaryItem].valueChanges
.pipe(
debounceTime(1000),
tap((value: any) => {
});
Object.keys(this.annuary).forEach(elemId => {
if (['annuaries'].indexOf(elemId) === -1) {
this.annuary[elemId].setValue(data.annuary[elemId]);
this.annuary[elemId].valueChanges
.pipe(
debounceTime(1000),
tap((value: any) => {
if (elemId === 'enabled' && value === true && this.annuary.annuaries.length === 0) {
this.addAnnuary();
} else {
this.saveConfiguration();
}),
).subscribe();
}
}),
).subscribe();
} else {
this.annuary[elemId] = [];
data.annuary[elemId].forEach((annuaryConf: any, index: number) => {
this.annuary[elemId].push({});
Object.keys(annuaryConf).forEach(annuaryItem => {
this.annuary[elemId][index][annuaryItem] = new FormControl(data.annuary[elemId][index][annuaryItem]);
this.annuary[elemId][index][annuaryItem].valueChanges
.pipe(
debounceTime(1000),
tap((value: any) => {
this.saveConfiguration();
}),
).subscribe();
});
});
});
}
});
this.setDefaultValue('basketToRedirect', data.basketToRedirect);
this.basketToRedirect.valueChanges
.pipe(
debounceTime(300),
tap((value: any) => {
this.saveConfiguration();
}),
).subscribe();
}
});
this.setDefaultValue('basketToRedirect', data.basketToRedirect);
this.basketToRedirect.valueChanges
.pipe(
debounceTime(300),
tap((value: any) => {
this.saveConfiguration();
}),
).subscribe();
}
}),
finalize(() => {
resolve(true);
......@@ -365,7 +367,7 @@ export class MaarchToMaarchParametersComponent implements OnInit {
this.http.put('../rest/m2m/configuration', { configuration: this.formatConfiguration() }).pipe(
tap(() => {
this.notify.success(this.translate.instant('lang.dataUpdated'));
this.passwordAlreadyExists = this.functionsService.empty(this.communications['password'].value) ? false : true;
// this.passwordAlreadyExists = this.functionsService.empty(this.communications['password'].value) ? false : true;
}),
catchError((err: any) => {
this.notify.handleErrors(err);
......@@ -382,7 +384,7 @@ export class MaarchToMaarchParametersComponent implements OnInit {
annuaries: []
},
communications: {
uri: this.communications.uri.value,
url: this.communications.url.value,
login: this.communications.login.value,
password: this.communications.password.value,
email: this.communications.email.value
......
......@@ -2560,6 +2560,8 @@
"userPasswordMaarch2Maarch": "User password",
"userIdMaarch2MaarchDesc": "User ID with a web service account",
"userPasswordMaarch2MaarchDesc": "User password with a web service account",
"m2mPasswordMsg": "The password for your <b>web service user</b> is not defined"
"m2mPasswordMsg": "The password for your <b>web service user</b> is not defined",
"urlUndefinedFormat": "Communications url is not a valid URL"
}
......@@ -2550,5 +2550,7 @@
"userPasswordMaarch2Maarch": "Mot de passe de l'utilisateur",
"userIdMaarch2MaarchDesc": "Identifiant de l'utilisateur avec un compte webservice",
"userPasswordMaarch2MaarchDesc": "Mot de passe de l'utilisateur avec un compte webservice",
"m2mPasswordMsg": "Le mot de passe de votre <b>utilisateur webservice</b> n'est pas défini"
"m2mPasswordMsg": "Le mot de passe de votre <b>utilisateur webservice</b> n'est pas défini",
"urlUndefinedFormat": "L'URL de communication n'est pas une URL valide",
"uriServerExample": "Exemple: https://demo.maarchcourrier.com"
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment