search option for branch

This commit is contained in:
sriram-at-840620226347 2020-11-07 14:06:47 +05:30
parent f437f12695
commit 8c731fd2ad
5 changed files with 26 additions and 6 deletions

View File

@ -39,10 +39,15 @@
<mat-form-field style="width: 28%">
<mat-select placeholder="Branch" formControlName="pd_branch_id" (selectionChange)="getContactPerson()">
<!-- (selectionChange)="getBillingDetails(pdMain.fk_lender_id.value)" -->
<mat-option>
<ngx-mat-select-search [formControl]="branchFilterCtrl"
[placeholderLabel]="'Search Branch...'"
[noEntriesFoundLabel]="'no matching records found'"></ngx-mat-select-search>
</mat-option>
<mat-option>
Select
</mat-option>
<mat-option *ngFor="let LB of lenderBranchList" [value]="LB.entity_lender_branch_id" >
<mat-option *ngFor="let LB of filteredBranchList | async" [value]="LB.entity_lender_branch_id" >
{{LB.branch_name}}
</mat-option>
</mat-select>

View File

@ -67,7 +67,9 @@ export class AddPdComponent implements OnInit, OnDestroy {
removedControl: any = [];
public lenderFilterCtrl:FormControl = new FormControl();
public branchFilterCtrl:FormControl = new FormControl();
public filteredLenderList:ReplaySubject<any> = new ReplaySubject<any>(1);
public filteredBranchList:ReplaySubject<any> = new ReplaySubject<any>(1);
constructor(notifier: NotifierService, private _fb: FormBuilder, private route: ActivatedRoute,
@ -186,6 +188,7 @@ export class AddPdComponent implements OnInit, OnDestroy {
selectedLender(lender) {
console.log('lender',lender);
this.lenderBranchList = lender['branches'];
this.filteredBranchList.next(this.lenderBranchList.slice());
this.lenderShortName = lender['short_name'];
// console.log(this.lenderShortName);
this._PDtriggerForm.controls.pd_branch_id.setValue(null);
@ -1114,6 +1117,10 @@ searchFun(control:any,i:number,option){
this.lenderFilterCtrl.valueChanges.pipe().subscribe(()=>{
this.applyFilter(this.lenderFilterCtrl.value,this.filteredLenderList,this.lenderList,'full_name')
})
this.branchFilterCtrl.valueChanges.pipe().subscribe(()=>{
this.applyFilter(this.branchFilterCtrl.value,this.filteredBranchList,this.lenderBranchList,'branch_name')
})
}
applyFilter(filtered_text,filter_list,raw_list,obj_name) {

View File

@ -55,9 +55,12 @@
<mat-select placeholder="Branch" formControlName="pd_branch_id" (selectionChange)="getContactPerson()">
<!-- (selectionChange)="getBillingDetails(pdMain.fk_lender_id.value)" -->
<mat-option>
Select
</mat-option>
<mat-option *ngFor="let LB of lenderBranchList" [value]="LB.entity_lender_branch_id" >
<ngx-mat-select-search [formControl]="branchFilterCtrl"
[placeholderLabel]="'Search Branch...'"
[noEntriesFoundLabel]="'no matching records found'"></ngx-mat-select-search>
</mat-option>
<mat-option>Select</mat-option>
<mat-option *ngFor="let LB of filteredBranchList | async" [value]="LB.entity_lender_branch_id" >
{{LB.branch_name}}
</mat-option>
</mat-select>

View File

@ -76,7 +76,9 @@ export class EditPdMasterComponent implements OnInit {
removedControl: any = [];
public lenderFilterCtrl:FormControl = new FormControl();
public branchFilterCtrl:FormControl = new FormControl();
public filteredLenderList:ReplaySubject<any> = new ReplaySubject<any>(1);
public filteredBranchList:ReplaySubject<any> = new ReplaySubject<any>(1);
constructor(private _fb: FormBuilder,
@ -202,6 +204,7 @@ export class EditPdMasterComponent implements OnInit {
selectedLender(lender,option?) {
// console.log('lender',lender);
this.lenderBranchList = lender['branches'];
this.filteredBranchList.next(this.lenderBranchList.slice());
this.lenderShortName = lender['short_name'];
// console.log(this.lenderShortName);
if(!option){
@ -1003,7 +1006,9 @@ searchFun(control:any,i:number,option){
this.lenderFilterCtrl.valueChanges.pipe().subscribe(()=>{
this.applyFilter(this.lenderFilterCtrl.value,this.filteredLenderList,this.lenderList,'full_name')
})
this.branchFilterCtrl.valueChanges.pipe().subscribe(()=>{
this.applyFilter(this.branchFilterCtrl.value,this.filteredBranchList,this.lenderBranchList,'branch_name')
})
}
applyFilter(filtered_text,filter_list,raw_list,obj_name) {
if (!raw_list) {

View File

@ -3,7 +3,7 @@
<div fxLayout="row">
<div fxFlex="50" class="pb-0 text-sm-left">
<mat-form-field dividerColor="primary" style="width: 50%;">
<input matInput [(ngModel)]="filterValue" placeholder="Filter">
<input matInput [(ngModel)]="filterValue" placeholder="Search">
</mat-form-field>
</div>
<div fxFlex="50" class="pb-0 text-sm-right">