From c72586851cf21fa9025bc694e27b39d4bc9d5e62 Mon Sep 17 00:00:00 2001 From: rhenck <richard.henck@iqb.hu-berlin.de> Date: Mon, 26 Jul 2021 11:22:36 +0200 Subject: [PATCH] Add label and id property to UnitPage Those props are set when page is created and can not be changed. This will have to be refactored when the functionality to switch pages is implemented. --- projects/common/unit.ts | 2 ++ .../src/app/components/unit-view/unit-view.component.html | 2 +- projects/editor/src/app/model/UnitFactory.ts | 4 +++- projects/editor/src/app/unit.service.ts | 4 ++-- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/projects/common/unit.ts b/projects/common/unit.ts index 509eecb40..fe299e282 100644 --- a/projects/common/unit.ts +++ b/projects/common/unit.ts @@ -3,6 +3,8 @@ export interface Unit { } export interface UnitPage { + id: string; + label: string; sections: UnitPageSection[]; width: number; margin: number; diff --git a/projects/editor/src/app/components/unit-view/unit-view.component.html b/projects/editor/src/app/components/unit-view/unit-view.component.html index 665ae5e90..a2ff4f7e6 100644 --- a/projects/editor/src/app/components/unit-view/unit-view.component.html +++ b/projects/editor/src/app/components/unit-view/unit-view.component.html @@ -17,7 +17,7 @@ <mat-tab *ngFor="let page of (unitService.unit | async)!.pages; let i = index" label="Seite {{i+1}}"> <ng-template mat-tab-label> <mat-icon *ngIf="page.alwaysVisible" class="page-alwaysVisible-icon">assignment</mat-icon> - Seite {{i+1}} + {{page.label}} <button class="delete-page-button" mat-button (click)="deletePage()"> <mat-icon>delete</mat-icon> </button> diff --git a/projects/editor/src/app/model/UnitFactory.ts b/projects/editor/src/app/model/UnitFactory.ts index 6c66cbbe8..9de4a6461 100644 --- a/projects/editor/src/app/model/UnitFactory.ts +++ b/projects/editor/src/app/model/UnitFactory.ts @@ -12,8 +12,10 @@ export function createUnit(): Unit { }; } -export function createUnitPage(): UnitPage { +export function createUnitPage(pageIndex: number): UnitPage { return { + id: `page${pageIndex}`, + label: `Seite ${pageIndex + 1}`, sections: [], width: 1100, margin: 15, diff --git a/projects/editor/src/app/unit.service.ts b/projects/editor/src/app/unit.service.ts index 6381b18dd..e8db2e74e 100644 --- a/projects/editor/src/app/unit.service.ts +++ b/projects/editor/src/app/unit.service.ts @@ -27,7 +27,7 @@ export class UnitService { private idService: IdService, private dialogService: DialogService) { const initialUnit = UnitFactory.createUnit(); - const initialPage = UnitFactory.createUnitPage(); + const initialPage = UnitFactory.createUnitPage(0); const initialSection = UnitFactory.createUnitPageSection(); initialPage.sections.push(initialSection); initialUnit.pages.push(initialPage); @@ -69,7 +69,7 @@ export class UnitService { } addPage(): void { - const newPage = UnitFactory.createUnitPage(); + const newPage = UnitFactory.createUnitPage(this._unit.value.pages.length); newPage.sections.push(UnitFactory.createUnitPageSection()); this._unit.value.pages.push(newPage); this._pages.push(new BehaviorSubject(newPage as UnitPage)); -- GitLab