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

FEAT #14005 TIME 0:20 add country autocomplete issuing list

parent 2deaa284
No related branches found
No related tags found
No related merge requests found
...@@ -38,17 +38,19 @@ ...@@ -38,17 +38,19 @@
</div> </div>
<mat-form-field appearance='outline' class="smallInput"> <mat-form-field appearance='outline' class="smallInput">
<button mat-button matSuffix [matMenuTriggerFor]="menuDep" <button mat-button matSuffix [matMenuTriggerFor]="menuDep"
(click)="$event.stopPropagation();" [title]="this.translate.instant('lang.targetDepartment')"> (click)="$event.stopPropagation();"
[title]="this.translate.instant('lang.targetDepartment')">
{{addressBANCurrentDepartment}}&nbsp;<i class="fa fa-chevron-down"></i> {{addressBANCurrentDepartment}}&nbsp;<i class="fa fa-chevron-down"></i>
</button> </button>
<mat-menu #menuDep="matMenu"> <mat-menu #menuDep="matMenu">
<button mat-menu-item *ngFor="let dep of departmentList" <button mat-menu-item *ngFor="let dep of departmentList"
(click)="addressBANCurrentDepartment = dep">{{dep}}</button> (click)="addressBANCurrentDepartment = dep">{{dep}}</button>
</mat-menu> </mat-menu>
<mat-icon color="primary" class="fa fa-search" matPrefix <mat-icon color="primary" class="fa fa-search" matPrefix style="font-size: 15px;">
style="font-size: 15px;"></mat-icon> </mat-icon>
<input type="text" #autoCompleteInput [placeholder]="this.translate.instant('lang.searchAddressBan')" <input type="text" #autoCompleteInput
matInput [formControl]="addressBANControl" [matAutocomplete]="auto" [placeholder]="this.translate.instant('lang.searchAddressBan')" matInput
[formControl]="addressBANControl" [matAutocomplete]="auto"
(click)="$event.stopPropagation()" (focus)="resetAutocompleteAddressBan()" (click)="$event.stopPropagation()" (focus)="resetAutocompleteAddressBan()"
maxlength="128"> maxlength="128">
<mat-autocomplete #auto="matAutocomplete" <mat-autocomplete #auto="matAutocomplete"
...@@ -95,12 +97,21 @@ ...@@ -95,12 +97,21 @@
</mat-form-field> </mat-form-field>
<mat-form-field> <mat-form-field>
<mat-label>{{'lang.contactsParameters_addressCountry' | translate}}</mat-label> <mat-label>{{'lang.contactsParameters_addressCountry' | translate}}</mat-label>
<input matInput formControlName="addressCountry"> <input matInput #autoCompleteInput [matAutocomplete]="matAutocompleteCountries"
formControlName="addressCountry">
<mat-autocomplete #matAutocompleteCountries="matAutocomplete"
(optionSelected)="adminFormGroup.controls['addressCountry'].setValue($event.option.value)" [isOpen]="true">
<mat-option *ngFor="let country of countriesFilteredResult | async"
[value]="country">
{{country}}
</mat-option>
</mat-autocomplete>
</mat-form-field> </mat-form-field>
</div> </div>
</div> </div>
<div style="text-align:center;"> <div style="text-align:center;">
<button mat-raised-button color="primary" type="submit" [disabled]="!adminFormGroup.valid">{{'lang.save' | translate}}</button> <button mat-raised-button color="primary" type="submit"
[disabled]="!adminFormGroup.valid">{{'lang.save' | translate}}</button>
</div> </div>
</form> </form>
</mat-card> </mat-card>
...@@ -108,12 +119,12 @@ ...@@ -108,12 +119,12 @@
</div> </div>
</mat-sidenav-content> </mat-sidenav-content>
<mat-sidenav #snav2 [mode]="appService.getViewMode() ? 'over' : 'side'" [fixedInViewport]="appService.getViewMode()" <mat-sidenav #snav2 [mode]="appService.getViewMode() ? 'over' : 'side'" [fixedInViewport]="appService.getViewMode()"
fixedTopGap="56" position='end' [opened]="!appService.getViewMode()" style="overflow-x:hidden;width:400px;"> fixedTopGap="56" position='end' [opened]="!appService.getViewMode()" style="overflow-x:hidden;width:400px;">
<mat-list> <mat-list>
<h3 mat-subheader>{{'lang.chooseEntityAssociationModel' | translate}}</h3> <h3 mat-subheader>{{'lang.chooseEntityAssociationModel' | translate}}</h3>
<div style="padding:10px;"> <div style="padding:10px;">
<app-maarch-flat-tree #maarchTree></app-maarch-flat-tree> <app-maarch-flat-tree #maarchTree></app-maarch-flat-tree>
</div> </div>
</mat-list> </mat-list>
</mat-sidenav> </mat-sidenav>
</mat-sidenav-container> </mat-sidenav-container>
\ No newline at end of file
...@@ -7,9 +7,10 @@ import { NotificationService } from '../../../../service/notification/notificati ...@@ -7,9 +7,10 @@ import { NotificationService } from '../../../../service/notification/notificati
import { HeaderService } from '../../../../service/header.service'; import { HeaderService } from '../../../../service/header.service';
import { AppService } from '../../../../service/app.service'; import { AppService } from '../../../../service/app.service';
import { MaarchFlatTreeComponent } from '../../../../plugins/tree/maarch-flat-tree.component'; import { MaarchFlatTreeComponent } from '../../../../plugins/tree/maarch-flat-tree.component';
import { map, tap, catchError, debounceTime, filter, distinctUntilChanged, switchMap } from 'rxjs/operators'; import { map, tap, catchError, debounceTime, filter, distinctUntilChanged, switchMap, startWith } from 'rxjs/operators';
import { of } from 'rxjs/internal/observable/of'; import { of } from 'rxjs/internal/observable/of';
import { Observable } from 'rxjs/internal/Observable'; import { Observable } from 'rxjs/internal/Observable';
import { LatinisePipe } from 'ngx-pipes';
@Component({ @Component({
selector: 'app-issuing-site', selector: 'app-issuing-site',
...@@ -23,6 +24,10 @@ export class IssuingSiteComponent implements OnInit { ...@@ -23,6 +24,10 @@ export class IssuingSiteComponent implements OnInit {
adminFormGroup: FormGroup; adminFormGroup: FormGroup;
entities: any = []; entities: any = [];
countries: any = [];
countriesFilteredResult: Observable<string[]>;
id: number = null; id: number = null;
addressBANInfo: string = ''; addressBANInfo: string = '';
...@@ -45,6 +50,7 @@ export class IssuingSiteComponent implements OnInit { ...@@ -45,6 +50,7 @@ export class IssuingSiteComponent implements OnInit {
private headerService: HeaderService, private headerService: HeaderService,
public appService: AppService, public appService: AppService,
private _formBuilder: FormBuilder, private _formBuilder: FormBuilder,
private latinisePipe: LatinisePipe,
) { } ) { }
ngOnInit(): void { ngOnInit(): void {
...@@ -68,6 +74,8 @@ export class IssuingSiteComponent implements OnInit { ...@@ -68,6 +74,8 @@ export class IssuingSiteComponent implements OnInit {
addressTown: [''], addressTown: [''],
addressCountry: [''] addressCountry: ['']
}); });
this.getCountries();
this.initAutocompleteCountries();
this.loading = false; this.loading = false;
await this.getEntities(); await this.getEntities();
...@@ -81,6 +89,9 @@ export class IssuingSiteComponent implements OnInit { ...@@ -81,6 +89,9 @@ export class IssuingSiteComponent implements OnInit {
await this.getEntities(); await this.getEntities();
await this.getData(); await this.getData();
this.getCountries();
this.initAutocompleteCountries();
this.maarchTree.initData(this.entities); this.maarchTree.initData(this.entities);
} }
}); });
...@@ -139,6 +150,20 @@ export class IssuingSiteComponent implements OnInit { ...@@ -139,6 +150,20 @@ export class IssuingSiteComponent implements OnInit {
}) })
).subscribe(); ).subscribe();
} }
initAutocompleteCountries() {
this.countriesFilteredResult = this.adminFormGroup.controls['addressCountry'].valueChanges
.pipe(
startWith(''),
map(value => this._filter(value))
);
}
private _filter(value: string): string[] {
const filterValue = value.toLowerCase();
console.log(this.countries);
return this.countries.filter(option => option.toLowerCase().includes(filterValue));
}
initAutocompleteAddressBan() { initAutocompleteAddressBan() {
this.addressBANInfo = this.translate.instant('lang.autocompleteInfo'); this.addressBANInfo = this.translate.instant('lang.autocompleteInfo');
...@@ -206,6 +231,19 @@ export class IssuingSiteComponent implements OnInit { ...@@ -206,6 +231,19 @@ export class IssuingSiteComponent implements OnInit {
}); });
} }
getCountries() {
this.http.get(`../rest/registeredMail/countries`).pipe(
tap((data: any) => {
this.countries = data.countries.map(
(item: any) => this.latinisePipe.transform(item.toUpperCase()));
}),
catchError((err: any) => {
this.notify.handleSoftErrors(err);
return of(false);
})
).subscribe();
}
onSubmit() { onSubmit() {
const objToSubmit = {}; const objToSubmit = {};
Object.keys(this.adminFormGroup.controls).forEach(key => { Object.keys(this.adminFormGroup.controls).forEach(key => {
......
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