Skip to content
Snippets Groups Projects
Commit 7c3e2ee6 authored by paflov's avatar paflov
Browse files

Dont't check navigationLeaveRestrictions if unit is already time-locked.

Fixes #347
parent 8efb9fb0
No related branches found
No related tags found
No related merge requests found
......@@ -5,10 +5,10 @@ Various Bugfixes:
* (#341) When you visited a test in demo-mode as a monitor, and terminated it, you returned to the starter but didn't see the monitor-monitor button again. That got fixed.
* (#340) After reload you return to the correct unit now
* (#335) Order of checks when leaving a unit is fixed: First check completeness, then ask for leaving the timed block
*
* (#347) Dont't check navigationLeaveRestrictions if unit is already time-locked.
Minor Changes
* In "demo" mode "showTimeLeft2 is off now
* In "demo" mode "showTimeLeft" is off now
## 12.0.2
Use Font Roboto everywhere
......
......@@ -55,7 +55,7 @@ export class UnitDeactivateGuard implements CanDeactivate<UnithostComponent> {
private router: Router
) {}
private checkAndSolve_maxTime(newUnit: UnitControllerData, force: boolean): Observable<boolean> {
private checkAndSolveMaxTime(newUnit: UnitControllerData): Observable<boolean> {
if (!this.tcs.currentMaxTimerTestletId) { // leaving unit is not in a timed block
return of(true);
}
......@@ -67,10 +67,6 @@ export class UnitDeactivateGuard implements CanDeactivate<UnithostComponent> {
) {
return of(true);
}
if (force) {
this.tcs.interruptMaxTimer();
return of(true);
}
const dialogCDRef = this.confirmDialog.open(ConfirmDialogComponent, {
width: '500px',
data: <ConfirmDialogData>{
......@@ -95,10 +91,7 @@ export class UnitDeactivateGuard implements CanDeactivate<UnithostComponent> {
);
}
private checkAndSolve_Completeness(newUnit: UnitControllerData, force: boolean): Observable<boolean> {
if (force) {
return of(true);
}
private checkAndSolveCompleteness(newUnit: UnitControllerData): Observable<boolean> {
const direction = (newUnit && this.tcs.currentUnitSequenceId < newUnit.unitDef.sequenceId) ? 'Next' : 'Prev';
const reasons = this.checkCompleteness(direction);
if (!reasons.length) {
......@@ -109,6 +102,9 @@ export class UnitDeactivateGuard implements CanDeactivate<UnithostComponent> {
private checkCompleteness(direction: 'Next' | 'Prev'): VeronaNavigationDeniedReason[] {
const unit = this.tcs.rootTestlet.getUnitAt(this.tcs.currentUnitSequenceId);
if (unit.unitDef.locked) {
return [];
}
const reasons: VeronaNavigationDeniedReason[] = [];
const checkOnValue = {
Next: <NavigationLeaveRestrictionValue[]>['ON', 'ALWAYS'],
......@@ -183,15 +179,14 @@ export class UnitDeactivateGuard implements CanDeactivate<UnithostComponent> {
}
const forceNavigation = this.router.getCurrentNavigation().extras?.state?.force ?? false;
if (forceNavigation) {
this.tcs.interruptMaxTimer();
return of(true);
}
return this.checkAndSolve_Completeness(newUnit, forceNavigation)
return this.checkAndSolveCompleteness(newUnit)
.pipe(
switchMap(cAsC => {
if (!cAsC) {
return of(false);
}
return this.checkAndSolve_maxTime(newUnit, forceNavigation);
})
switchMap(cAsC => (!cAsC ? of(false) : this.checkAndSolveMaxTime(newUnit)))
);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment