Switches focus to Done button after saving and printing.

This commit is contained in:
Aaron Louie 2020-09-23 23:45:58 -04:00
parent 2fa2fab1ee
commit ee145b2b42
2 changed files with 12 additions and 3 deletions

View File

@ -22,17 +22,19 @@
#saveAndPrintButton="matButton"
mat-flat-button
class="btn-lg"
color="accent"
[color]="isSaved ? '' : 'accent'"
(click)="saveAndPrint()"
autofocus
fxFlex="33%"
><mat-icon>print</mat-icon> Print labels</button>
<button
#doneButton="matButton"
mat-flat-button
class="btn-lg"
routerLink="/"
fxFlex="33%"
><mat-icon>cancel</mat-icon> Cancel</button>
[color]="isSaved ? 'accent' : ''"
><mat-icon>done</mat-icon> Done</button>
</mat-card-actions>
</mat-card>
</div>

View File

@ -19,6 +19,8 @@ export class PrintComponent implements AfterViewInit {
dateCreated: Date;
settings: AppDefaults;
@ViewChild('saveAndPrintButton') saveAndPrintButton: MatButton;
@ViewChild('doneButton') doneButton: MatButton;
isSaved = false;
constructor(
private api: ApiService,
@ -76,6 +78,11 @@ export class PrintComponent implements AfterViewInit {
location: this.settings.locationId,
};
this.api.addSample(newSample).subscribe(() => window.print());
this.api.addSample(newSample).subscribe(() => {
this.isSaved = true;
window.print();
this.doneButton.focus();
this.changeDetector.detectChanges();
});
}
}