Skip to content
Snippets Groups Projects
Commit cad78019 authored by rhenck's avatar rhenck
Browse files

[editor] Improve logic for allowing setting pageAlwaysVisible

This is now always disallowed when there is only 1 page. There is an 
issue when this is set and further pages are deleted, but this scenario 
should be very rare und non-consequential.
parent a794be96
No related branches found
No related tags found
No related merge requests found
...@@ -49,7 +49,7 @@ export class PagePropertiesComponent implements OnInit, OnDestroy { ...@@ -49,7 +49,7 @@ export class PagePropertiesComponent implements OnInit, OnDestroy {
.pipe(takeUntil(this.ngUnsubscribe)) .pipe(takeUntil(this.ngUnsubscribe))
.subscribe((page: UnitPage) => { .subscribe((page: UnitPage) => {
this.selectedPage = page; this.selectedPage = page;
this.alwaysVisibleDisabled = this.unitService.isPageAlwaysVisibleSet() && !page.alwaysVisible; this.alwaysVisibleDisabled = (!this.unitService.isSetPageAlwaysVisibleAllowed() && !page.alwaysVisible);
}); });
} }
......
...@@ -60,7 +60,7 @@ export class UnitService { ...@@ -60,7 +60,7 @@ export class UnitService {
} }
updatePageProperty(page: UnitPage, property: string, value: number | boolean): void { updatePageProperty(page: UnitPage, property: string, value: number | boolean): void {
if (property === 'alwaysVisible' && value === true && this.isPageAlwaysVisibleSet()) { if (property === 'alwaysVisible' && value === true && !this.isSetPageAlwaysVisibleAllowed()) {
this.messageService.showError('Kann nur für eine Seite gesetzt werden'); this.messageService.showError('Kann nur für eine Seite gesetzt werden');
} else { } else {
page[property] = value; page[property] = value;
...@@ -68,9 +68,9 @@ export class UnitService { ...@@ -68,9 +68,9 @@ export class UnitService {
this.veronaApiService.sendVoeDefinitionChangedNotification(); this.veronaApiService.sendVoeDefinitionChangedNotification();
} }
/** Check if a page already has this setting. */ /* Disallow when not more than 1 page or when is already set. */
isPageAlwaysVisibleSet(): boolean { isSetPageAlwaysVisibleAllowed(): boolean {
return this._unit.value.pages.find(page => page.alwaysVisible) !== undefined; return this._unit.value.pages.length > 1 && this._unit.value.pages.find(page => page.alwaysVisible) === undefined;
} }
addSection(page: UnitPage): void { addSection(page: UnitPage): void {
......
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