Skip to content

Commit

Permalink
feat: added save and exit button to roll call
Browse files Browse the repository at this point in the history
fixes #937
  • Loading branch information
kirtijadhav authored Sep 15, 2021
1 parent 3967279 commit d5ec37c
Show file tree
Hide file tree
Showing 5 changed files with 207 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
mode="determinate"
[value]="(currentIndex / entries.length) * 100"
></mat-progress-bar>
<app-child-block [entity]="entries[currentIndex].child"></app-child-block>
<div class="progress-label">{{ currentIndex }} / {{ entries.length }}</div>
<app-child-block [entity]="entries[currentIndex].child"></app-child-block>
<div class="progress-label">{{ currentIndex }} / {{ entries.length }}</div>
</div>

<div
Expand Down Expand Up @@ -49,6 +49,17 @@

<!-- Control Buttons -->
<div>
<button
mat-stroked-button
[disabled]="isFinished()"
(click)="save()"
class="nav-button"
fxFlex
i18n="Save-Button|Button to finish roll call early"
>
Save & Exit
</button>

<button
i18n="Back-button|Button to go to the previous child"
mat-stroked-button
Expand All @@ -72,7 +83,7 @@
</button>
</div>
<div>
<button mat-stroked-button (click)="exit.emit()" class="nav-button" fxFlex>
<button mat-stroked-button (click)="abort()" class="nav-button" fxFlex>
<span *ngIf="isFinished()" i18n="Finish entering the attendance of a child">
Finish
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import { LoggingService } from "../../../../core/logging/logging.service";
import { defaultAttendanceStatusTypes } from "../../../../core/config/default-config/default-attendance-status-types";
import { AttendanceModule } from "../../attendance.module";
import { ChildrenService } from "../../../children/children.service";
import { ConfirmationDialogService } from "../../../../core/confirmation-dialog/confirmation-dialog.service";
import { of } from "rxjs";

describe("RollCallComponent", () => {
let component: RollCallComponent;
Expand Down Expand Up @@ -177,4 +179,58 @@ describe("RollCallComponent", () => {

expect(component.complete.emit).toHaveBeenCalledWith(note);
}));

it("should only complete when clicking save and confirming in the dialog when roll call is not finished yet", fakeAsync(() => {
const note = new Note();
const confirmationDialogService = TestBed.inject(ConfirmationDialogService);
// Set component to be not finished
component.currentIndex = 0;
component.entries = [undefined, undefined];
spyOn(component.complete, "emit");
component.eventEntity = note;
spyOn(confirmationDialogService, "openDialog").and.returnValue({
afterClosed: () => of(true),
} as any);

component.save();
tick();

expect(component.complete.emit).toHaveBeenCalledWith(note);
}));

it("should directly complete when clicking save and the roll call finished", () => {
const note = new Note();
component.eventEntity = note;
const confirmationDialogService = TestBed.inject(ConfirmationDialogService);
spyOn(confirmationDialogService, "openDialog");
spyOn(component, "isFinished").and.returnValue(true);
spyOn(component.complete, "emit");

component.save();

expect(confirmationDialogService.openDialog).not.toHaveBeenCalled();
expect(component.complete.emit).toHaveBeenCalledWith(note);
});

it("should not open the dialog when the roll call is finished", () => {
const confirmationDialogService = TestBed.inject(ConfirmationDialogService);
spyOn(confirmationDialogService, "openDialog");
spyOn(component, "isFinished").and.returnValue(true);

component.abort();

expect(confirmationDialogService.openDialog).not.toHaveBeenCalled();
});

it("should open the dialog when the roll call is not finished", () => {
const confirmationDialogService = TestBed.inject(ConfirmationDialogService);
spyOn(confirmationDialogService, "openDialog").and.returnValue({
afterClosed: () => of(true),
} as any);
spyOn(component, "isFinished").and.returnValue(false);

component.abort();

expect(confirmationDialogService.openDialog).toHaveBeenCalled();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import {
import { EntityMapperService } from "../../../../core/entity/entity-mapper.service";
import { Child } from "../../../children/model/child";
import { LoggingService } from "../../../../core/logging/logging.service";
import { FormGroup } from "@angular/forms";
import { ConfirmationDialogService } from "../../../../core/confirmation-dialog/confirmation-dialog.service";

/**
* Displays the participants of the given event one by one to mark attendance status.
Expand Down Expand Up @@ -53,11 +55,13 @@ export class RollCallComponent implements OnInit {
availableStatus: AttendanceStatusType[];

entries: { child: Child; attendance: EventAttendance }[];
form: FormGroup;

constructor(
private configService: ConfigService,
private entityMapper: EntityMapperService,
private loggingService: LoggingService
private loggingService: LoggingService,
private confirmationDialog: ConfirmationDialogService
) {}

async ngOnInit() {
Expand Down Expand Up @@ -116,4 +120,39 @@ export class RollCallComponent implements OnInit {
isFinished(): boolean {
return this.currentIndex >= this.entries?.length;
}

save() {
if (this.isFinished()) {
this.goToNextParticipant(this.entries?.length);
} else {
const remainingParticipant = this.entries.length - this.currentIndex;
const dialogRef = this.confirmationDialog.openDialog(
$localize`:Save & Next confirmation title: Save & Exit`,
$localize`:Save & Exit confirmation text:Are you sure you want to save, exit and skip the remaining ${remainingParticipant.toString()} participants?`
);

dialogRef.afterClosed().subscribe((confirmed) => {
if (confirmed) {
this.goToNextParticipant(this.entries?.length);
}
});
}
}

abort() {
if (this.isFinished()) {
this.exit.emit();
} else {
const dialogRef = this.confirmationDialog.openDialog(
$localize`:Abort confirmation title: Abort`,
$localize`:Abort confirmation text:Are you sure you want to exit and discard all recordings?`
);

dialogRef.afterClosed().subscribe((confirmed) => {
if (confirmed) {
this.exit.emit();
}
});
}
}
}
56 changes: 51 additions & 5 deletions src/locale/messages.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,24 @@
<context context-type="linenumber">46</context>
</context-group>
</trans-unit>
<trans-unit id="004c780ad24219ab7e2f577a5557225675f512df" datatype="html">
<source> Save &amp; Exit </source>
<target state="translated"> Speichern &amp; Beenden </target>
<context-group purpose="location">
<context context-type="sourcefile">src/app/child-dev-project/attendance/add-day-attendance/roll-call/roll-call.component.html</context>
<context context-type="linenumber">60,66</context>
</context-group>
<note priority="1" from="description">Button to finish roll call early</note>
<note priority="1" from="meaning">Save-Button</note>
</trans-unit>
<trans-unit id="058db649ec3f6f1dba6157a51b6c48d15b2ca96a" datatype="html">
<source> Back </source>
<target state="translated"> Zurück </target>
<note priority="1" from="description">Button to go to the previous child</note>
<note priority="1" from="meaning">Back-button</note>
<context-group purpose="location">
<context context-type="sourcefile">src/app/child-dev-project/attendance/add-day-attendance/roll-call/roll-call.component.html</context>
<context context-type="linenumber">60</context>
<context context-type="linenumber">71</context>
</context-group>
</trans-unit>
<trans-unit id="871ad34321b1517e1707bd0f05d8ba7c122d34ed" datatype="html">
Expand All @@ -219,7 +229,7 @@
<note priority="1" from="meaning">Skip-Button</note>
<context-group purpose="location">
<context context-type="sourcefile">src/app/child-dev-project/attendance/add-day-attendance/roll-call/roll-call.component.html</context>
<context context-type="linenumber">71</context>
<context context-type="linenumber">82</context>
</context-group>
</trans-unit>
<trans-unit id="e5c1448d20c9e9833d7f5f8a51312899f867fce9" datatype="html">
Expand All @@ -228,7 +238,7 @@
<note priority="1" from="description">Finish entering the attendance of a child</note>
<context-group purpose="location">
<context context-type="sourcefile">src/app/child-dev-project/attendance/add-day-attendance/roll-call/roll-call.component.html</context>
<context context-type="linenumber">77</context>
<context context-type="linenumber">88</context>
</context-group>
</trans-unit>
<trans-unit id="258b18886b42770303b23f052e7213217fe64513" datatype="html">
Expand All @@ -237,8 +247,44 @@
<note priority="1" from="description">Abort entering the attendance of a child</note>
<context-group purpose="location">
<context context-type="sourcefile">src/app/child-dev-project/attendance/add-day-attendance/roll-call/roll-call.component.html</context>
<context context-type="linenumber">80</context>
<context context-type="linenumber">91</context>
</context-group>
</trans-unit>
<trans-unit id="6149790421325658341" datatype="html">
<source> Save &amp; Exit</source>
<target state="translated"> Save &amp; Exit </target>
<context-group purpose="location">
<context context-type="sourcefile">src/app/child-dev-project/attendance/add-day-attendance/roll-call/roll-call.component.ts</context>
<context context-type="linenumber">130,129</context>
</context-group>
<note priority="1" from="description">Save &amp; Next confirmation title</note>
</trans-unit>
<trans-unit id="5773856749871082334" datatype="html">
<source>Are you sure you want to save, exit and skip the remaining <x id="PH" equiv-text="remainingParticipant.toString()"/> participants?</source>
<target state="translated">Sind Sie sicher, dass Sie die Aufzeichung der Anwesenheit beenden und <x id="PH" equiv-text="remainingParticipant.toString()"/> Teilnehmer:innen überspringen wollen?</target>
<context-group purpose="location">
<context context-type="sourcefile">src/app/child-dev-project/attendance/add-day-attendance/roll-call/roll-call.component.ts</context>
<context context-type="linenumber">131,129</context>
</context-group>
<note priority="1" from="description">Save &amp; Exit confirmation text</note>
</trans-unit>
<trans-unit id="3304180909188588981" datatype="html">
<source> Abort</source>
<target state="translated">Abbrechen</target>
<context-group purpose="location">
<context context-type="sourcefile">src/app/child-dev-project/attendance/add-day-attendance/roll-call/roll-call.component.ts</context>
<context context-type="linenumber">147,146</context>
</context-group>
<note priority="1" from="description">Abort confirmation title</note>
</trans-unit>
<trans-unit id="2317876813032660437" datatype="html">
<source>Are you sure you want to exit and discard all recordings?</source>
<target state="translated">Sind Sie sicher, dass Sie die Aufzeichung der Anwesenheit beenden und alle Änderungen verwerfen wollen?</target>
<context-group purpose="location">
<context context-type="sourcefile">src/app/child-dev-project/attendance/add-day-attendance/roll-call/roll-call.component.ts</context>
<context context-type="linenumber">148,146</context>
</context-group>
<note priority="1" from="description">Abort confirmation text</note>
</trans-unit>
<trans-unit id="828a009e2c01bece732333b25efb6b62ed46f6ec" datatype="html">
<source> attended <x id="INTERPOLATION" equiv-text="{{ attendanceDescription }"/> events </source>
Expand Down Expand Up @@ -2714,7 +2760,7 @@
</trans-unit>
<trans-unit id="819578366272929200" datatype="html">
<source>Overall Activity Report</source>
<target state="new">Overall Activity Report</target>
<target state="translated">Anwesenheitsbericht</target>
<context-group purpose="location">
<context context-type="sourcefile">src/app/core/config/config-fix.ts</context>
<context context-type="linenumber">804</context>
Expand Down
51 changes: 46 additions & 5 deletions src/locale/messages.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -325,17 +325,26 @@
<source> Attendance completed. </source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/child-dev-project/attendance/add-day-attendance/roll-call/roll-call.component.html</context>
<context context-type="linenumber">46,53</context>
<context context-type="linenumber">46,54</context>
</context-group>
<note priority="1" from="description">shows when the user has registered the attendance of
all children</note>
<note priority="1" from="meaning">Attendance completed</note>
</trans-unit>
<trans-unit id="004c780ad24219ab7e2f577a5557225675f512df" datatype="html">
<source> Save &amp; Exit </source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/child-dev-project/attendance/add-day-attendance/roll-call/roll-call.component.html</context>
<context context-type="linenumber">60,66</context>
</context-group>
<note priority="1" from="description">Button to finish roll call early</note>
<note priority="1" from="meaning">Save-Button</note>
</trans-unit>
<trans-unit id="058db649ec3f6f1dba6157a51b6c48d15b2ca96a" datatype="html">
<source> Back </source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/child-dev-project/attendance/add-day-attendance/roll-call/roll-call.component.html</context>
<context context-type="linenumber">60,66</context>
<context context-type="linenumber">71,77</context>
</context-group>
<note priority="1" from="description">Button to go to the previous child</note>
<note priority="1" from="meaning">Back-button</note>
Expand All @@ -344,7 +353,7 @@
<source> Skip </source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/child-dev-project/attendance/add-day-attendance/roll-call/roll-call.component.html</context>
<context context-type="linenumber">71,76</context>
<context context-type="linenumber">82,87</context>
</context-group>
<note priority="1" from="description">Button to skip a step in the roll call</note>
<note priority="1" from="meaning">Skip-Button</note>
Expand All @@ -353,18 +362,50 @@
<source> Finish </source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/child-dev-project/attendance/add-day-attendance/roll-call/roll-call.component.html</context>
<context context-type="linenumber">77,80</context>
<context context-type="linenumber">88,91</context>
</context-group>
<note priority="1" from="description">Finish entering the attendance of a child</note>
</trans-unit>
<trans-unit id="258b18886b42770303b23f052e7213217fe64513" datatype="html">
<source> Abort </source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/child-dev-project/attendance/add-day-attendance/roll-call/roll-call.component.html</context>
<context context-type="linenumber">80,84</context>
<context context-type="linenumber">91,95</context>
</context-group>
<note priority="1" from="description">Abort entering the attendance of a child</note>
</trans-unit>
<trans-unit id="6149790421325658341" datatype="html">
<source> Save &amp; Exit</source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/child-dev-project/attendance/add-day-attendance/roll-call/roll-call.component.ts</context>
<context context-type="linenumber">130,129</context>
</context-group>
<note priority="1" from="description">Save &amp; Next confirmation title</note>
</trans-unit>
<trans-unit id="5773856749871082334" datatype="html">
<source>Are you sure you want to save, exit and skip the remaining <x id="PH" equiv-text="remainingParticipant.toString()"/> participants?</source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/child-dev-project/attendance/add-day-attendance/roll-call/roll-call.component.ts</context>
<context context-type="linenumber">131,129</context>
</context-group>
<note priority="1" from="description">Save &amp; Exit confirmation text</note>
</trans-unit>
<trans-unit id="3304180909188588981" datatype="html">
<source> Abort</source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/child-dev-project/attendance/add-day-attendance/roll-call/roll-call.component.ts</context>
<context context-type="linenumber">147,146</context>
</context-group>
<note priority="1" from="description">Abort confirmation title</note>
</trans-unit>
<trans-unit id="2317876813032660437" datatype="html">
<source>Are you sure you want to exit and discard all recordings?</source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/child-dev-project/attendance/add-day-attendance/roll-call/roll-call.component.ts</context>
<context context-type="linenumber">148,146</context>
</context-group>
<note priority="1" from="description">Abort confirmation text</note>
</trans-unit>
<trans-unit id="828a009e2c01bece732333b25efb6b62ed46f6ec" datatype="html">
<source> attended <x id="INTERPOLATION" equiv-text="{{ attendanceDescription }"/> events </source>
<context-group purpose="location">
Expand Down

0 comments on commit d5ec37c

Please sign in to comment.