Skip to content

Commit

Permalink
Merge pull request #323 from mild-blue/322_fix_2x_vaccinate
Browse files Browse the repository at this point in the history
Fix 2x vaccinate
  • Loading branch information
tomaskourim authored Jun 16, 2021
2 parents 01d6406 + 876dd0b commit a3c130b
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ <h3>Potrvdit správnost zadaných údajů?</h3>
</div>
<mat-dialog-actions class="buttons">
<button mat-button mat-dialog-close>Ne</button>
<button mat-raised-button color="success" mat-dialog-close (click)="confirm()">Ano</button>
<button mat-raised-button color="success" mat-dialog-close (click)="confirm()" [disabled]="confirmDisabled">Ano</button>
</mat-dialog-actions>
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ export class ConfirmPatientDataComponent implements AbstractConfirmInterface {
onConfirm: EventEmitter<string> = new EventEmitter<string>();

public note: string = '';
public confirmDisabled: boolean = false;

constructor(private _ngZone: NgZone) {
}

confirm(): void {
this.confirmDisabled = true;
this.onConfirm.emit(this.note);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ <h3>Poznámka</h3>

<mat-dialog-actions>
<button mat-button mat-dialog-close>Zrušit</button>
<button mat-raised-button color="success" mat-dialog-close (click)="confirm()">
<button mat-raised-button color="success" mat-dialog-close (click)="confirm()" [disabled]="confirmDisabled">
Potvrdit očkování do {{ bodyPart | bodyPartInflected }}
<mat-icon>check</mat-icon>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ export class ConfirmVaccinationComponent implements AbstractConfirmInterface {
public bodyParts: string[] = Object.values(BodyPart);

public note: string = '';
public confirmDisabled: boolean = false;

constructor(private _ngZone: NgZone) {
}

confirm(): void {
this.confirmDisabled = true;
this.onConfirm.emit({ bodyPart: this.bodyPart, note: this.note });
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ <h1>Editace údajů pacienta</h1>
<div class="buttons">
<button [routerLink]="['/admin/patient', patient.id]" mat-flat-button>Zrušit</button>
<button (click)="handleSave()"
[disabled]="!patientValid || !patientChanged"
[disabled]="!patientValid || !patientChanged || loading"
color="success"
mat-raised-button>
Uložit změny
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/app/pages/admin/edit/admin-edit.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,14 @@ export class AdminEditComponent extends AdminPatientAbstractComponent implements
return;
}

this.loading = true;
try {
await this._patientService.updatePatient(this.patient);
this._alertService.successDialog('Data pacienta byla úspěšně uložena.', this._routeBack.bind(this));
} catch (e) {
this._alertService.error(e.message);
} finally {
this.loading = false;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ <h1>Nalezený pacient</h1>
</app-warning>

<div *ngIf="patient" class="buttons">
<button *ngIf="!patient.verified" mat-raised-button (click)="verify()" color="success">
<button *ngIf="!patient.verified" mat-raised-button
(click)="verify()" color="success" [disabled]="loading">
Potvrdit správnost údajů
<mat-icon>check</mat-icon>
</button>

<button *ngIf="patient.verified && !patient.vaccinatedOn" mat-raised-button (click)="vaccinate()" color="accent">
<button *ngIf="patient.verified && !patient.vaccinatedOn" mat-raised-button
(click)="vaccinate()" color="accent" [disabled]="loading">
Potvrdit proběhlé očkování
<mat-icon>health_and_safety</mat-icon>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,15 @@ export class AdminPatientComponent extends AdminPatientAbstractComponent impleme
return;
}

this.loading = true;
try {
await this._patientService.verifyPatient(this.patient, note);
this._alertService.successDialog('Údaje pacienta byly ověřeny.');
this.patient.verified = true;
} catch (e) {
this._alertService.error(e.message);
} finally {
this.loading = false;
}
}

Expand All @@ -56,11 +59,14 @@ export class AdminPatientComponent extends AdminPatientAbstractComponent impleme
return;
}

this.loading = true;
try {
await this._patientService.confirmVaccination(this.patient.id, confirmation.bodyPart, confirmation.note);
this._alertService.successDialog('Očkování bylo zaznamenáno.', this.initPatient.bind(this));
} catch (e) {
this._alertService.error(e.message);
} finally {
this.loading = false;
}
}
}

0 comments on commit a3c130b

Please sign in to comment.