diff --git a/src/frontend/app/administration/contact/page/form/contacts-form.component.html b/src/frontend/app/administration/contact/page/form/contacts-form.component.html index 2084ca8ba364532d0ba5d76ab883089a4d235454..bfe986aebe041d787e24e3d92d0a4c542da3dd28 100644 --- a/src/frontend/app/administration/contact/page/form/contacts-form.component.html +++ b/src/frontend/app/administration/contact/page/form/contacts-form.component.html @@ -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 diff --git a/src/frontend/app/administration/contact/page/form/contacts-form.component.ts b/src/frontend/app/administration/contact/page/form/contacts-form.component.ts index a5b429066862b9baf015bc47723803bd199d3fb3..f812d0298d08e0b5af9ddb9380d4912738b1be83 100644 --- a/src/frontend/app/administration/contact/page/form/contacts-form.component.ts +++ b/src/frontend/app/administration/contact/page/form/contacts-form.component.ts @@ -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( diff --git a/src/frontend/app/administration/parameter/maarchToMaarch/maarch-to-maarch-parameters.component.html b/src/frontend/app/administration/parameter/maarchToMaarch/maarch-to-maarch-parameters.component.html index 13e79e8b3e3fd50d2f4f363040113c95cd8770b6..3dd88e9df931fb23877711d075c7e4293df94821 100644 --- a/src/frontend/app/administration/parameter/maarchToMaarch/maarch-to-maarch-parameters.component.html +++ b/src/frontend/app/administration/parameter/maarchToMaarch/maarch-to-maarch-parameters.component.html @@ -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"> diff --git a/src/frontend/app/administration/parameter/maarchToMaarch/maarch-to-maarch-parameters.component.ts b/src/frontend/app/administration/parameter/maarchToMaarch/maarch-to-maarch-parameters.component.ts index 410f009dcd1bea28bb50a0426a2cf8376c5e02e6..41a9953000f6af2849e86586059b89b8623cc6d0 100644 --- a/src/frontend/app/administration/parameter/maarchToMaarch/maarch-to-maarch-parameters.component.ts +++ b/src/frontend/app/administration/parameter/maarchToMaarch/maarch-to-maarch-parameters.component.ts @@ -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 }, }; diff --git a/src/lang/lang-en.json b/src/lang/lang-en.json index db9551531cfea6d9f5a4fdffd1d79e8a85624355..818133efb6e0460dae298a0c91a9157796454e23 100644 --- a/src/lang/lang-en.json +++ b/src/lang/lang-en.json @@ -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" } diff --git a/src/lang/lang-fr.json b/src/lang/lang-fr.json index ac56f853423a4236257323214c7f6b7d3fbc2c6e..e4f18b274c49e698c9f66250d9094f3046470abe 100644 --- a/src/lang/lang-fr.json +++ b/src/lang/lang-fr.json @@ -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" }