Skip to content
Snippets Groups Projects
Commit 3c6738b9 authored by Alex ORLUC's avatar Alex ORLUC
Browse files

FEAT #15443 TIME 1 add AC contact in recipient registered mail input

parent 7de00818
No related branches found
No related tags found
No related merge requests found
<mat-form-field *ngIf="this.control.status !== 'DISABLED'" appearance='outline' class="smallInput">
<button mat-button matSuffix [matMenuTriggerFor]="menuDep" (click)="$event.stopPropagation();"
[title]="'lang.targetDepartment' | translate">
{{addressBANCurrentDepartment}}&nbsp;<i class="fa fa-chevron-down"></i>
</button>
<mat-menu #menuDep="matMenu">
<button mat-menu-item *ngFor="let dep of departmentList"
(click)="addressBANCurrentDepartment = dep">{{dep}}</button>
</mat-menu>
<mat-icon color="primary" class="fa fa-search" matPrefix style="font-size: 15px;">
</mat-icon>
<input type="text" #autoCompleteInput [placeholder]="'lang.searchAddressBan' | translate" matInput
[formControl]="addressBANControl" [matAutocomplete]="auto" (click)="$event.stopPropagation()"
(focus)="resetAutocompleteAddressBan()" maxlength="128">
<mat-autocomplete #auto="matAutocomplete" (optionSelected)="selectAddressBan($event)">
<ng-container *ngIf="addressBANResult.length > 0 && !addressBANLoading">
<mat-option *ngFor="let addressBANResult of addressBANFilteredResult | async" [value]="addressBANResult"
[title]="addressBANResult.address">
{{addressBANResult.address}}
</mat-option>
</ng-container>
<mat-option class="autoCompleteInfoResult smallInputInfo"
*ngIf="addressBANResult.length === 0 && !addressBANLoading" disabled [innerHTML]="addressBANInfo">
</mat-option>
<mat-option *ngIf="addressBANLoading" disabled>
<mat-spinner diameter="20"></mat-spinner>
</mat-option>
</mat-autocomplete>
</mat-form-field>
<app-contact-autocomplete *ngIf="this.control.status !== 'DISABLED'"
[exclusion]="'?noUsers=true&noEntities=true&noContactsGroups=true'"
[inputMode]="true"
style="width:100%;" (afterSelected)="getContact($event)"></app-contact-autocomplete>
<a *ngIf="!manualAddress && emptyAddress()" (click)="manualAddress=!manualAddress" style="cursor: pointer;">{{'lang.switchManualAddress' | translate}}</a>
<mat-card color="primary" *ngIf="manualAddress">
<mat-form-field *ngIf="this.control.status !== 'DISABLED'" appearance='outline' class="smallInput">
<button mat-button matSuffix [matMenuTriggerFor]="menuDep" (click)="$event.stopPropagation();"
[title]="'lang.targetDepartment' | translate">
{{addressBANCurrentDepartment}}&nbsp;<i class="fa fa-chevron-down"></i>
</button>
<mat-menu #menuDep="matMenu">
<button mat-menu-item *ngFor="let dep of departmentList"
(click)="addressBANCurrentDepartment = dep">{{dep}}</button>
</mat-menu>
<mat-icon color="primary" class="fa fa-search" matPrefix style="font-size: 15px;">
</mat-icon>
<input type="text" #autoCompleteInput [placeholder]="'lang.searchAddressBan' | translate" matInput
[formControl]="addressBANControl" [matAutocomplete]="auto" (click)="$event.stopPropagation()"
(focus)="resetAutocompleteAddressBan()" maxlength="128">
<mat-autocomplete #auto="matAutocomplete" (optionSelected)="selectAddressBan($event)">
<ng-container *ngIf="addressBANResult.length > 0 && !addressBANLoading">
<mat-option *ngFor="let addressBANResult of addressBANFilteredResult | async" [value]="addressBANResult"
[title]="addressBANResult.address">
{{addressBANResult.address}}
</mat-option>
</ng-container>
<mat-option class="autoCompleteInfoResult smallInputInfo"
*ngIf="addressBANResult.length === 0 && !addressBANLoading" disabled [innerHTML]="addressBANInfo">
</mat-option>
<mat-option *ngIf="addressBANLoading" disabled>
<mat-spinner diameter="20"></mat-spinner>
</mat-option>
</mat-autocomplete>
</mat-form-field>
<button mat-icon-button class="address-icon" (click)="manualAddress=!manualAddress"
[title]="'lang.showAddress' | translate">
<mat-icon class="fa fa-eye"></mat-icon>
......
......@@ -202,4 +202,28 @@ export class RegisteredMailRecipientInputComponent implements OnInit {
goTo() {
window.open(`https://www.google.com/maps/search/${this.control.value.addressNumber}+${this.control.value.addressStreet},+${this.control.value.addressPostcode}+${this.control.value.addressTown},+${this.control.value.addressCountry}`, '_blank');
}
getContact(contact: any) {
this.http.get('../rest/contacts/' + contact.id).pipe(
tap((data: any) => {
this.control.value.firstname = data.firstname;
this.control.value.lastname = data.lastname;
this.control.value.addressStreet = data.addressStreet;
this.control.value.addressPostcode = data.addressPostcode;
this.control.value.addressTown = data.addressTown;
this.control.value.addressCountry = data.addressCountry;
this.control.value.addressNumber = data.addressNumber;
this.control.value.company = data.company;
this.control.value.civility = data.civility.label.toUpperCase();
this.control.value.addressAdditional1 = data.addressAdditional1;
this.control.value.addressAdditional2 = data.addressAdditional2;
this.countryControl.setValue(data.addressCountry);
this.control.markAsTouched();
}),
catchError((err: any) => {
this.notify.error(err.error.errors);
return of(false);
})
).subscribe();
}
}
......@@ -108,10 +108,10 @@
</div>
</mat-autocomplete>
</mat-form-field>
<div style="text-align: right;" *ngIf="controlAutocomplete.value.length >= 2 && !controlAutocomplete.disabled">
<div style="text-align: right;" *ngIf="controlAutocomplete.value.length >= 2 && !controlAutocomplete.disabled && !inputMode">
<button mat-button color="warn" (click)="resetAll()" style="font-size: 10px;">{{'lang.deleteAll' | translate}}</button>
</div>
<div class="itemList">
<div class="itemList" *ngIf="!inputMode">
<mat-chip-list *ngIf="controlAutocomplete.value.length > 0" class="mat-chip-list-stacked itemChip"
color="default">
<ng-container *ngIf="!loadingValues">
......
......@@ -51,14 +51,16 @@ export class ContactAutocompleteComponent implements OnInit {
/**
* FormControl used when autocomplete is used in form and must be catched in a form control.
*/
@Input('control') controlAutocomplete: FormControl;
@Input('control') controlAutocomplete: FormControl = new FormControl();
@Input() id: string = 'contact-autocomplete';
@Input() exclusion: string = '';
@Input() singleMode: boolean = false;
@Input() inputMode: boolean = false;
@Output() retrieveDocumentEvent = new EventEmitter<string>();
@Output() afterSelected = new EventEmitter<any>();
@ViewChild('autoCompleteInput', { static: true }) autoCompleteInput: ElementRef;
......@@ -160,6 +162,7 @@ export class ContactAutocompleteComponent implements OnInit {
selectOpt(ev: any) {
this.setFormValue(ev.option.value);
this.afterSelected.emit(ev.option.value);
this.myControl.setValue('');
}
......
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