Commit 2d0318e4 authored by Hamza HRAMCHI's avatar Hamza HRAMCHI
Browse files

FIX #18428 TIME 3:15 Maarch2Maarch: split login and user in administration and contact interfaces

parent 79bae90d
......@@ -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 !== 'communicationMeans' && field.id !== 'externalId_m2m' && field.id != 'addressCountry' && field.id != 'addressPostcode' && field.id != 'addressTown'">
*ngIf="field.type === 'string' && field.id !== 'uri' && 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 === 'communicationMeans'">
<ng-container *ngIf="field.id === 'uri'">
<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: 'communicationMeans',
id: 'uri',
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>)`,
......@@ -292,6 +292,42 @@ export class ContactsFormComponent implements OnInit {
filling: false,
values: []
},
{
id: 'login',
unit: 'maarch2maarch',
label: this.translate.instant('lang.userIdMaarch2Maarch'),
desc: `${this.translate.instant('lang.userIdMaarch2MaarchDesc')}`,
type: 'string',
control: new FormControl(),
required: false,
display: false,
filling: false,
values: []
},
{
id: 'password',
unit: 'maarch2maarch',
label: this.translate.instant('lang.userPasswordMaarch2Maarch'),
desc: `${this.translate.instant('lang.userPasswordMaarch2MaarchDesc')}`,
type: 'string',
control: new FormControl(),
required: false,
display: false,
filling: false,
values: []
},
{
id: 'email_m2m',
unit: 'maarch2maarch',
label: this.translate.instant('lang.email'),
desc: `${this.translate.instant('lang.m2mEmailDesc')}`,
type: 'string',
control: new FormControl(),
required: false,
display: false,
filling: false,
values: []
},
{
id: 'correspondentsGroups',
unit: 'complement',
......@@ -418,6 +454,9 @@ export class ContactsFormComponent implements OnInit {
exhaustMap(() => this.http.get('../rest/contacts/' + this.contactId)),
map((data: any) => {
// data.civility = this.contactService.formatCivilityObject(data.civility);
if (data.communicationMeans !== null) {
this.setCommunicationMeans(data.communicationMeans);
}
data.fillingRate = this.contactService.formatFillingObject(data.fillingRate);
return data;
}),
......@@ -600,7 +639,6 @@ export class ContactsFormComponent implements OnInit {
}
setContactDataExternal(data: any) {
if (data.externalId !== undefined) {
Object.keys(data.externalId).forEach(id => {
......@@ -752,11 +790,22 @@ export class ContactsFormComponent implements OnInit {
contact['customFields'][element.id.split(/_(.+)/)[1]] = element.control.value;
} else if (element.id.match(regex2) !== null) {
contact['externalId'][element.id.split(/_(.+)/)[1]] = element.control.value;
} else {
} else if (element.utit !== 'maarch2maarch') {
contact[element.id] = element.control.value;
}
});
return contact;
const m2mData: any[] = this.contactForm.filter((element: any) => element.unit === 'maarch2maarch').map((item: any) => ({
id: item.id,
value: item.control.value
}));
const communicationMeans = {
uri: m2mData.find((item: any) => item.id === 'uri').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,
email: m2mData.find((item: any) => item.id === 'email_m2m').value,
};
return { ... contact, communicationMeans};
}
isEmptyUnit(id: string) {
......@@ -859,6 +908,17 @@ export class ContactsFormComponent implements OnInit {
this.addressBANMode = disableBan ? false : true;
}
setCommunicationMeans(communicationMeans: any) {
let indexField = -1;
Object.keys(communicationMeans).forEach(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]);
this.contactForm[indexField].display = true;
}
});
}
canDelete(field: any) {
if (field.id === 'company') {
const lastname = this.contactForm.filter(contact => contact.id === 'lastname')[0];
......@@ -898,7 +958,7 @@ export class ContactsFormComponent implements OnInit {
removeField(field: any) {
field.display = !field.display;
field.control.reset();
if ((field.id === 'externalId_m2m' || field.id === 'communicationMeans') && !field.display) {
if ((field.id === 'externalId_m2m' || field.id === 'uri') && !field.display) {
const indexFieldAnnuaryId = this.contactForm.map(item => item.id).indexOf('externalId_m2m_annuary_id');
if (indexFieldAnnuaryId > -1) {
this.contactForm.splice(indexFieldAnnuaryId, 1);
......@@ -917,7 +977,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('communicationMeans');
const indexFieldCommunicationMeans = this.contactForm.map(field => field.id).indexOf('uri');
this.contactForm[indexFieldCommunicationMeans].control.valueChanges
.pipe(
debounceTime(300),
......@@ -944,7 +1004,7 @@ export class ContactsFormComponent implements OnInit {
}
selectCommunicationMean(ev: any) {
const indexFieldCommunicationMeans = this.contactForm.map(field => field.id).indexOf('communicationMeans');
const indexFieldCommunicationMeans = this.contactForm.map(field => field.id).indexOf('uri');
this.contactForm[indexFieldCommunicationMeans].control.setValue(ev.option.value.communicationValue);
const indexFieldExternalId = this.contactForm.map(field => field.id).indexOf('externalId_m2m');
......@@ -958,7 +1018,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('communicationMeans');
const indexFieldCommunicationMeans = this.contactForm.map(field => field.id).indexOf('uri');
const indexFieldExternalId = this.contactForm.map(field => field.id).indexOf('externalId_m2m');
this.contactForm[indexFieldExternalId].control.valueChanges
.pipe(
......
......@@ -11,6 +11,16 @@
<input matInput [formControl]="communications.uri">
<mat-hint align="end" [innerHTML]="'lang.m2mUriDesc' | translate"></mat-hint>
</mat-form-field>
<mat-form-field>
<mat-label>{{'lang.userIdMaarch2Maarch' | translate}}</mat-label>
<input matInput [formControl]="communications.login">
<mat-hint align="end" [innerHTML]="'lang.userIdMaarch2MaarchDesc' | translate"></mat-hint>
</mat-form-field>
<mat-form-field>
<mat-label>{{'lang.userPasswordMaarch2Maarch' | translate}}</mat-label>
<input matInput [formControl]="communications.password">
<mat-hint align="end" [innerHTML]="'lang.userPasswordMaarch2MaarchDesc' | translate"></mat-hint>
</mat-form-field>
<mat-form-field>
<mat-label>{{'lang.email' | translate}}</mat-label>
<input matInput [formControl]="communications.email">
......
......@@ -38,7 +38,9 @@ export class MaarchToMaarchParametersComponent implements OnInit {
attachmentTypeId: new FormControl(),
};
communications = {
uri: new FormControl('https://cchaplin:maarch@demo.maarchcourrier.com'),
uri: new FormControl('https://demo.maarchcourrier.com'),
login: new FormControl('cchaplin'),
password: new FormControl('maarch'),
email: new FormControl(null),
};
annuary = {
......@@ -194,7 +196,9 @@ export class MaarchToMaarchParametersComponent implements OnInit {
map((data: any) => data.configuration),
tap((data: any) => {
Object.keys(this.communications).forEach(elemId => {
this.communications[elemId].setValue(data.communications[elemId]);
if (!this.functionsService.empty(data.communications[elemId])) {
this.communications[elemId].setValue(data.communications[elemId]);
}
this.communications[elemId].valueChanges
.pipe(
debounceTime(1000),
......@@ -375,6 +379,8 @@ export class MaarchToMaarchParametersComponent implements OnInit {
},
communications: {
uri: this.communications.uri.value,
login: this.communications.login.value,
password: this.communications.password.value,
email: this.communications.email.value
},
};
......
......@@ -2555,5 +2555,9 @@
"otpVisaUser": "The user will be notified by <b> email </b> at the time of his turn in the circuit.",
"mustSign": "The signature position for external users is mandatory.",
"autoRedirectToUser": "To myself",
"applicationVersion": "Maarch courrier {{version}} Powered by {{author}}"
"applicationVersion": "Maarch courrier {{version}} Powered by {{author}}",
"userIdMaarch2Maarch": "User identifier",
"userPasswordMaarch2Maarch": "User password",
"userIdMaarch2MaarchDesc": "User ID with a web service account",
"userPasswordMaarch2MaarchDesc": "User password with a web service account"
}
......@@ -2545,5 +2545,9 @@
"requestedOpinion": "Avis demandé à la place de",
"sharePointWarning": "Fermez l'éditeur du document avant de valider l'édition",
"autoRedirectToUser": "A moi-même",
"applicationVersion": "Maarch courrier {{version}} Powered by {{author}}"
"applicationVersion": "Maarch courrier {{version}} Powered by {{author}}",
"userIdMaarch2Maarch": "Identifiant de l'utilisateur",
"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"
}
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