Skip to content
Snippets Groups Projects
Commit 49e9985f authored by Hamza HRAMCHI's avatar Hamza HRAMCHI
Browse files

FIX #16305 TIME 0:45 Contact creation: alert on first / last name duplicates: associate a contact

parent f44508bd
No related branches found
No related tags found
No related merge requests found
......@@ -10,7 +10,7 @@
<mat-sidenav-container>
<mat-sidenav-content>
<app-contact-form *ngIf="mode === 'update'" [creationMode]="creationMode" [contactId]="data.contactId"
(onSubmitEvent)="dialogRef.close($event)"></app-contact-form>
(onSubmitEvent)="dialogRef.close($event)" (linkContact)="linkContact($event)"></app-contact-form>
<app-contact-detail *ngIf="mode === 'read'" [contact]="contact"></app-contact-detail>
</mat-sidenav-content>
<mat-sidenav #drawer position='end' mode="side" style="overflow-x:hidden;width: 50%;" autoFocus="false">
......
import { Component, Inject, ViewChild, Renderer2, OnInit } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { MAT_DIALOG_DATA, MatDialogRef, MatDialog } from '@angular/material/dialog';
import { TranslateService } from '@ngx-translate/core';
import { HttpClient } from '@angular/common/http';
import { PrivilegeService } from '@service/privileges.service';
import { HeaderService } from '@service/header.service';
import { MatSidenav } from '@angular/material/sidenav';
import { ConfirmComponent } from '@plugins/modal/confirm.component';
import { catchError, exhaustMap, filter } from 'rxjs/operators';
import { of } from 'rxjs';
import { NotificationService } from '@service/notification/notification.service';
declare let $: any;
......@@ -29,6 +33,8 @@ export class ContactModalComponent implements OnInit{
@Inject(MAT_DIALOG_DATA) public data: any,
public dialogRef: MatDialogRef<ContactModalComponent>,
public headerService: HeaderService,
public dialog: MatDialog,
public notify: NotificationService,
private renderer: Renderer2) {
}
......@@ -70,4 +76,23 @@ export class ContactModalComponent implements OnInit{
}, 200);
}
}
linkContact(contactId: number) {
const dialogRef = this.dialog.open(ConfirmComponent,
{ panelClass: 'maarch-modal',
autoFocus: false, disableClose: true,
data: {
title: this.translate.instant('lang.linkContact'),
msg: this.translate.instant('lang.goToContact')
}
});
dialogRef.afterClosed().pipe(
filter((data: string) => data === 'ok'),
exhaustMap(async () => this.dialogRef.close(contactId)),
catchError((err: any) => {
this.notify.handleSoftErrors(err);
return of(false);
})
).subscribe();
}
}
......@@ -20,7 +20,7 @@
</div>
<div class="col-md-2" style="margin-left: auto;">
<mat-icon class="fas fa-id-card" color="primary" (click)="selectContact(contact.id)"
style="font-size: 20px; cursor: pointer;" [title]="'lang.setContactInfos' | translate">
style="font-size: 20px; cursor: pointer;" [title]="!data.fromAdministration ? ('lang.associateContactToDoc' | translate) : ('lang.setContactInfos' | translate)">
</mat-icon>
</div>
</div>
......
......@@ -25,7 +25,7 @@ export class ContactSearchModalComponentComponent implements OnInit {
) { }
ngOnInit(): void {
this.contactResult = JSON.parse(JSON.stringify(this.data));
this.contactResult = JSON.parse(JSON.stringify(this.data.contacts));
this.loading = false;
}
......
......@@ -78,11 +78,11 @@
</div>
<div style="display: flex; flex: 1; align-items:flex-start;">
<div *ngIf="autocompleteContactName.length > 0 && !contactChanged" class="alert-message alert-message-info" role="alert">
<div [ngStyle]="{'padding': autocompleteContactName.length === 1 ? '10px' : '0px'}" style="margin: 13px; width: 100% !important;">
<div [ngStyle]="{'padding': autocompleteContactName.length === 1 ? '10px' : '0px'}" style="margin: 13px; width: auto;">
<div style="margin-top: -7px; margin-bottom: 2px;">
{{'lang.contact' | translate}}
<ng-container> <b>{{contactService.formatContact(autocompleteContactName[0])}}</b></ng-container> {{'lang.find' | translate}}
<a style="cursor: pointer;font-weight:bold;font-style: italic;" (click)="setContact(autocompleteContactName[0].id)">{{'lang.click' | translate}} {{'lang.here' | translate}}</a> {{'lang.accessContact' | translate}}
<a style="cursor: pointer;font-weight:bold;font-style: italic;" (click)="setContact(autocompleteContactName[0].id)">{{'lang.click' | translate}} {{'lang.here' | translate}}</a> {{!fromAdministration ? ('lang.associateContact' | translate) : ('lang.accessContact' | translate)}}
</div>
<div *ngIf="autocompleteContactName.length > 1" style="margin-bottom: -8px;">
<mat-icon color="primary" class="fas fa-angle-right" style="font-size:16px;width:14px;"></mat-icon>
......
......@@ -2,7 +2,6 @@ import { Component, OnInit, ViewChild, EventEmitter, Input, Output } from '@angu
import { HttpClient } from '@angular/common/http';
import { TranslateService } from '@ngx-translate/core';
import { NotificationService } from '@service/notification/notification.service';
import { HeaderService } from '@service/header.service';
import { MatSidenav } from '@angular/material/sidenav';
import { AppService } from '@service/app.service';
import { MatDialog } from '@angular/material/dialog';
......@@ -51,6 +50,7 @@ export class ContactsFormComponent implements OnInit {
@Input() actionButton: boolean = true;
@Input() defaultName: string = '';
@Output() linkContact = new EventEmitter<number>();
@Output() onSubmitEvent = new EventEmitter<number>();
countries: any = [];
......@@ -344,24 +344,30 @@ export class ContactsFormComponent implements OnInit {
contactNameClone: any = null;
fromAdministration: boolean = false;
currentRoute: string = '';
constructor(
public translate: TranslateService,
public http: HttpClient,
private route: ActivatedRoute,
private router: Router,
private notify: NotificationService,
private headerService: HeaderService,
public appService: AppService,
public dialog: MatDialog,
public contactService: ContactService,
public functions: FunctionsService,
private latinisePipe: LatinisePipe
private latinisePipe: LatinisePipe,
private activatedRoute: ActivatedRoute
) { }
ngOnInit(): void {
this.loading = true;
this.currentRoute = this.activatedRoute.snapshot['_routerState'].url;
this.fromAdministration = this.currentRoute.includes('administration') ? true : false;
this.initBanSearch();
if (this.contactId === null) {
......@@ -1213,22 +1219,26 @@ export class ContactsFormComponent implements OnInit {
}
setContact(id: number) {
const dialogRef = this.dialog.open(ConfirmComponent,
{ panelClass: 'maarch-modal',
autoFocus: false, disableClose: true,
data: {
title: this.translate.instant('lang.setContactInfos'),
msg: this.translate.instant('lang.goToContact')
}
});
dialogRef.afterClosed().pipe(
filter((data: string) => data === 'ok'),
exhaustMap(() => this.router.navigate([`/administration/contacts/list/${id}`])),
catchError((err: any) => {
this.notify.handleErrors(err);
return of(false);
})
).subscribe();
if (!this.fromAdministration) {
this.linkContact.emit(id);
} else {
const dialogRef = this.dialog.open(ConfirmComponent,
{ panelClass: 'maarch-modal',
autoFocus: false, disableClose: true,
data: {
title: this.translate.instant('lang.setContactInfos'),
msg: this.translate.instant('lang.goToContact')
}
});
dialogRef.afterClosed().pipe(
filter((data: string) => data === 'ok'),
exhaustMap(() => this.router.navigate([`/administration/contacts/list/${id}`])),
catchError((err: any) => {
this.notify.handleErrors(err);
return of(false);
})
).subscribe();
}
}
showAllContact() {
......@@ -1236,7 +1246,10 @@ export class ContactsFormComponent implements OnInit {
disableClose: true,
width: '800px',
panelClass: 'maarch-modal',
data: this.autocompleteContactName
data: {
contacts: this.autocompleteContactName,
fromAdministration: this.fromAdministration
}
});
dialogRef.afterClosed().pipe(
......
......@@ -2531,5 +2531,7 @@
"find": "find.",
"showAll": "See other contacts",
"setContactInfos": "Access the contact details sheet",
"goToContact": "You will lose your current changes, are you sure you want to continue?"
"goToContact": "You will lose your current changes, are you sure you want to continue?",
"associateContact": "to associate the contact with the mail / attachment.",
"associateContactToDoc": "Associate the contact with the mail / attachment"
}
......@@ -2526,5 +2526,7 @@
"find": "trouvé.",
"showAll": "Voir les autres contacts",
"setContactInfos": "Accéder à la fiche de détails du contact",
"goToContact": "Vous allez perdre vos modifications actuelles, voulez-vous vraiment continuer ?"
"goToContact": "Vous allez perdre vos modifications actuelles, voulez-vous vraiment continuer ?",
"associateContact": "pour associer ce contact au courrier/pièce jointe.",
"associateContactToDoc": "Associer ce contact au courrier/pièce jointe"
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment