Skip to content

Commit

Permalink
הוספת חיפוש לפי שם חברה
Browse files Browse the repository at this point in the history
  • Loading branch information
noam-honig committed Jul 5, 2018
1 parent 709ad40 commit 7cabd67
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 9 deletions.
22 changes: 14 additions & 8 deletions src/app/families/families.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ <h4>
<h5 *ngFor="let s of statistics">
<a (click)="filterBy(s)"> {{s.name}} - {{s.count()}}</a>
</h5>

<mat-form-field class="full-width">
<input matInput [(ngModel)]="searchString" (input)="doSearch()" placeholder="חיפוש משפחה" [ngModelOptions]="{standalone: true}">
<mat-icon matSuffix (click)="clearSearch()">clear</mat-icon>
</mat-form-field>
<br>
<div class="table-responsive" [class.hide]="!gridView">
<data-grid [settings]="families"></data-grid>
<button (click)="saveToExcel()">יצוא לאקסל</button>
Expand Down Expand Up @@ -113,10 +117,12 @@ <h5 *ngFor="let s of statistics">
<button *ngIf="families.currentRow &&families.currentRow.wasChanged()" (click)="families.currentRow.reset();families.setCurrentRow(families.items[0]);"
[disabled]="!families.currentRow.wasChanged()" class="btn btn-danger glyphicon glyphicon-ban-circle ng-star-inserted"></button>
</div>
<button (click)="families.previousRow()" [disabled]="families.currentRow&& families.currentRow.wasChanged()||!families.previousRowAllowed()"
[class.hide]="gridView" class="btn glyphicon glyphicon-chevron-left ng-star-inserted"></button>
<button (click)="families.nextRow()" [class.hide]="gridView" [disabled]="families.currentRow&&families.currentRow.wasChanged()"
class="btn glyphicon glyphicon-chevron-right"></button>
<button (click)="gridView = !gridView" [class.hide]="gridView" class="btn glyphicon glyphicon-list-alt"></button>
<button (click)="families.addNewRow()" [class.hide]="gridView" [disabled]="families.currentRow&&families.currentRow.wasChanged()"
class="btn btn-primary glyphicon glyphicon-plus"></button>
<div *ngIf="families.currentRow">
<button (click)="families.previousRow()" [disabled]="families.currentRow&& families.currentRow.wasChanged()||!families.previousRowAllowed()"
[class.hide]="gridView" class="btn glyphicon glyphicon-chevron-left ng-star-inserted"></button>
<button (click)="families.nextRow()" [class.hide]="gridView" [disabled]="families.currentRow&&families.currentRow.wasChanged()"
class="btn glyphicon glyphicon-chevron-right"></button>
<button (click)="gridView = !gridView" [class.hide]="gridView" class="btn glyphicon glyphicon-list-alt"></button>
<button (click)="families.addNewRow()" [class.hide]="gridView" [disabled]="families.currentRow&&families.currentRow.wasChanged()"
class="btn btn-primary glyphicon glyphicon-plus"></button>
</div>
13 changes: 12 additions & 1 deletion src/app/families/families.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ export class FamiliesComponent implements OnInit {
limit: this.limit
});
}
searchString = '';
async doSearch() {
if (this.families.currentRow && this.families.currentRow.wasChanged())
return;
this.dialog.donotWait(() =>
this.families.get({ where: f => f.name.isContains(this.searchString), orderBy: f => f.name }));
}
clearSearch() {
this.searchString = '';
this.doSearch();
}
limit: 10;
async saveToExcel() {

Expand Down Expand Up @@ -102,7 +113,7 @@ export class FamiliesComponent implements OnInit {
dropDown: { source: new BasketType() },
width: '100'
},

families.courier.getColumn(this.dialog),
families.deliverStatus.getColumn()
],
Expand Down
16 changes: 16 additions & 0 deletions src/app/select-popup/select-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,25 @@ export class SelectService implements SelectServiceInterface {
isScreenSmall() {
return this.mediaMatcher.matches;
}


async donotWait<t>(what: () => Promise<t>): Promise<t> {
this.disableWait = true;
try {
return (await what());
}
finally {
this.disableWait = false;
}

}
private disableWait = false;
constructor(private dialog: MatDialog, zone: NgZone) {
this.mediaMatcher.addListener(mql => zone.run(() => this.mediaMatcher = mql));

wrapFetch.wrap = () => {
if (this.disableWait)
return () => { };
if (this.numOfWaits == 0) {
this.waitRef = this.dialog.open(WaitComponent, { disableClose: true });
}
Expand Down

0 comments on commit 7cabd67

Please sign in to comment.