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

[editor] Fix page selection

New elements are now put on the current(/newly created) page or section.
parent dbde1114
No related branches found
No related tags found
No related merge requests found
......@@ -107,6 +107,7 @@ export class PageCanvasComponent implements OnInit, OnDestroy {
addSection(index: number | null = null): void {
this.unitService.addSection(this.page, index);
this.selectionService.setSelectedPageSection(this.page.sections[this.page.sections.length - 1]);
}
sectionDrop(event: CdkDragDrop<UnitPageSection[]>): void {
......
......@@ -56,11 +56,13 @@ export class UnitViewComponent implements OnInit, OnDestroy {
selectPage(newIndex: number): void {
this.selectedPageIndex = newIndex;
this.selectionService.setSelectedPageSection(this.unit.pages[this.selectedPageIndex].sections[0]);
}
addPage(): void {
this.unitService.addPage();
this.selectedPageIndex -= 1;
this.selectedPageIndex += 1;
this.selectionService.setSelectedPageSection(this.unit.pages[this.selectedPageIndex].sections[0]);
}
movePage(page: UnitPage, direction: 'up' | 'down'): void {
......@@ -76,6 +78,7 @@ export class UnitViewComponent implements OnInit, OnDestroy {
this.selectedPageIndex -= 1;
}
});
this.selectionService.setSelectedPageSection(this.unit.pages[this.selectedPageIndex].sections[0]);
}
updateModel(page: UnitPage, property: string, value: number | boolean, isInputValid: boolean | null = true): void {
......
......@@ -41,6 +41,10 @@ export class SelectionService {
get selectedPageSection(): Observable<UnitPageSection> {
return this._selectedPageSection.asObservable();
}
setSelectedPageSection(section: UnitPageSection): void {
this._selectedPageSection.next(section);
}
// ### SECTION ######
get selectedElements(): Observable<UnitUIElement[]> {
......
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