File tree 1 file changed +6
-2
lines changed
frontend/src/angular/src/app/book-import
1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ export class BookImportComponent {
54
54
}
55
55
56
56
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 > ;
58
58
for ( let i = 0 ; i < chapterFormArray . length ; i ++ ) {
59
59
if ( chapterFormArray . at ( i ) === chapterFg ) {
60
60
chapterFormArray . removeAt ( i ) ;
@@ -86,7 +86,11 @@ export class BookImportComponent {
86
86
87
87
if ( ! ! this . bookForm . controls [ FormGroupKey . file ] . value ) {
88
88
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 ) ) ;
90
94
formData . append ( 'book' , this . bookForm . controls [ FormGroupKey . file ] . value )
91
95
formData . append ( 'chapters' , JSON . stringify ( chapters ) ) ;
92
96
You can’t perform that action at this time.
0 commit comments