Skip to content

Commit

Permalink
Add ability to mark badge as distributed
Browse files Browse the repository at this point in the history
  • Loading branch information
hengkysanjaya123 committed Jan 9, 2024
1 parent 5da2fe8 commit a9d9cb9
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/app/person/person.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ <h5 class="card-title">{{'preview_badge' | translate | titlecase}}
<button type="button" class="btn btn-sm btn-primary dropdown-toggle dropdown-toggle-split"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></button>
<div class="dropdown-menu">
<button class="dropdown-item" [disabled]="!hasPrintPermission">{{'mark_as_distributed' | translate}}</button>
<button class="dropdown-item" [disabled]="(!hasEditPermission && !hasPrintPermission) || !!personAcr.distributed" (click)="markAsDistributed()">{{'mark_as_distributed' | translate}} <span class="badge badge-success" *ngIf="!!personAcr.distributed">{{'distributed' | translate}}</span></button>
<button class="dropdown-item" [disabled]="!hasEditPermission" (click)="invalidateBadge()">{{'invalidate_badge' | translate}}</button>
</div>
</div>
Expand Down
11 changes: 10 additions & 1 deletion src/app/person/person.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,21 @@ export class PersonComponent extends WsComponent implements OnInit {

invalidateBadge(): void {
if (confirm('This will generate a new random code for the QR code. Any existing badge will no longer be valid. Proceed?')) {
this.personAccreditationService.invalidateBadge(this.selectedEvent.id, this.personAcr.id).subscribe(res => {
this.personAccreditationService.invalidateBadge(this.selectedEvent.id, this.personAcr.id).subscribe(_ => {
this.toastService.success('New random code for QR code generated, existing badges are now invalid.');

// reload person accreditation
this.subscribe(this.loadPersonAccreditation(this.personAcr.id));
});
}
}

markAsDistributed(): void {
this.personAccreditationService.markAsDistributed(this.selectedEvent.id, this.personAcr.id).subscribe(_ => {
this.toastService.success('Person accreditation marked as distributed');

// reload person accreditation
this.subscribe(this.loadPersonAccreditation(this.personAcr.id));
});
}
}
1 change: 1 addition & 0 deletions src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"code": "Code",
"color": "Color",
"delegate_type": "Delegate Type",
"distributed": "Distributed",
"edit_accreditations": "Edit Accreditations",
"editing": "Editing",
"empty_hint": "(empty)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ export class PersonAccreditationService extends WsService<any> {
return this.http.delete(`${this.url(eventId)}/${personAccreditationId}/randomHash`).pipe(share());
}

markAsDistributed(eventId: number, personAccreditationId: number): Observable<any> {
return this.http.put(`${this.url(eventId)}/${personAccreditationId}/distributed`, null).pipe(share());
}

initialiseFetchParams(): PersonAccreditationSummaryReqParams {
return {
name: null,
Expand Down
1 change: 1 addition & 0 deletions src/types/person-accreditation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ export interface PersonAccreditation {
zones_remove: Zone[];
summary: PersonAccreditationSummary;
deleted: boolean;
distributed: Date;
}

0 comments on commit a9d9cb9

Please sign in to comment.