Skip to content

Commit 0b8b5ce

Browse files
committed
feat: use chapters
1 parent 9d7daf8 commit 0b8b5ce

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

frontend/src/angular/src/app/book-import/book-import.component.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export class BookImportComponent {
5454
}
5555

5656
protected removeChapter(chapterFg: FormGroup) {
57-
const chapterFormArray = this.bookForm.controls[FormGroupKey.chapters] as FormArray<FormGroup>;
57+
const chapterFormArray = this.bookForm.controls[FormGroupKey.chapters] as FormArray<FormGroup>;
5858
for(let i = 0;i < chapterFormArray.length;i++) {
5959
if(chapterFormArray.at(i) === chapterFg) {
6060
chapterFormArray.removeAt(i);
@@ -86,7 +86,11 @@ export class BookImportComponent {
8686

8787
if (!!this.bookForm.controls[FormGroupKey.file].value) {
8888
const formData = new FormData();
89-
const chapters = [{startPage: 1, endPage: 2} as ChapterPages];
89+
const chapterFormArray = (this.bookForm.controls[FormGroupKey.chapters] as FormArray<FormGroup>);
90+
let chapters = new Array(chapterFormArray.length)
91+
.map((v, index) => chapterFormArray.at(index) as FormGroup)
92+
.map(chapterFg => ({startPage: chapterFg.controls[FormGroupKey.chapterStart].value,
93+
endPage: chapterFg.controls[FormGroupKey.chapterEnd].value } as ChapterPages));
9094
formData.append('book', this.bookForm.controls[FormGroupKey.file].value)
9195
formData.append('chapters', JSON.stringify(chapters));
9296

0 commit comments

Comments
 (0)