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

[editor] Fix section counter update

New section components no longer get their number on creation. This has 
the effect that the section gets a new number and is updated again with 
all others after that.
Numbering of all sections is triggered in one place (UnitService) and 
updates all existing sections.
parent ae549c53
No related branches found
No related tags found
No related merge requests found
......@@ -72,7 +72,7 @@ import { SectionCounter } from 'common/util/section-counter';
.section-wrapper .section {flex-grow: 1;}
`
})
export class SectionComponent implements OnInit {
export class SectionComponent {
@Input() section!: Section;
@Input() sectionIndex!: number;
@Input() lastSectionIndex!: number;
......@@ -88,10 +88,6 @@ export class SectionComponent implements OnInit {
public elementService: ElementService,
public sectionService: SectionService) { }
ngOnInit(): void {
this.updateSectionCounter();
}
updateSectionCounter(): void {
this.sectionCounter = undefined;
if (this.unitService.unit.enableSectionNumbering &&
......
......@@ -41,6 +41,7 @@ export class SectionService {
page.addSection(section, sectionIndex);
this.selectionService.selectedSectionIndex =
Math.max(0, this.selectionService.selectedSectionIndex - 1);
this.unitService.updateSectionCounter();
return { section, sectionIndex };
},
rollback: (deletedData: Record<string, unknown>) => {
......@@ -53,6 +54,7 @@ export class SectionService {
page.deleteSection(sectionIndex);
this.selectionService.selectedSectionIndex =
Math.max(0, this.selectionService.selectedSectionIndex - 1);
this.unitService.updateSectionCounter();
}
});
}
......@@ -130,12 +132,14 @@ export class SectionService {
page.deleteSection(sectionIndex);
page.addSection(newSection, sectionIndex);
this.unitService.updateUnitDefinition();
this.unitService.updateSectionCounter();
}
insertSection(pageIndex: number, sectionIndex: number, newSection: Section): void {
const page = this.unitService.unit.pages[pageIndex];
page.addSection(newSection, sectionIndex);
this.unitService.updateUnitDefinition();
this.unitService.updateSectionCounter();
}
/* Move element between sections */
......
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