Skip to content

Commit 71cea8c

Browse files
committed
feat: update forms
1 parent 010a9c9 commit 71cea8c

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,17 @@
2121
<ng-container formArrayName="chapters">
2222
@for(chaptersForm of chapters.controls;track chaptersForm) {
2323
<div class="chapter-container" [formGroup]="chaptersForm">
24-
<div>A</div>
25-
<div>B</div>
24+
<mat-form-field class="chapter-pages">
25+
<mat-label>First Page</mat-label>
26+
<input matInput [formControlName]="FormGroupKey.chapterStart" placeholder="first page">
27+
</mat-form-field>
28+
<mat-form-field class="chapter-pages">
29+
<mat-label>Last Page</mat-label>
30+
<input matInput [formControlName]="FormGroupKey.chapterEnd" placeholder="last page">
31+
</mat-form-field>
32+
<button mat-icon-button (click)="removeChapter(chaptersForm)">
33+
<mat-icon>remove</mat-icon>
34+
</button>
2635
</div>
2736
}
2837
</ng-container>

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,11 @@
4141

4242
.chapter-container {
4343
display: flex;
44+
margin-top: 20px;
45+
align-items: center;
46+
}
47+
48+
.chapter-pages {
49+
width: 200px;
50+
margin: 10px;
4451
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import { MatToolbarModule } from '@angular/material/toolbar';
2020
import { MatButtonModule } from '@angular/material/button';
2121
import { FormArray, FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
2222
import { CommonModule } from '@angular/common';
23+
import { MatFormFieldModule } from '@angular/material/form-field';
24+
import { MatInputModule } from '@angular/material/input';
2325

2426
enum FormGroupKey{
2527
file='file',
@@ -31,7 +33,7 @@ enum FormGroupKey{
3133
@Component({
3234
selector: 'app-book-import',
3335
standalone: true,
34-
imports: [MatIconModule,MatToolbarModule,MatButtonModule,ReactiveFormsModule, CommonModule],
36+
imports: [MatIconModule,MatToolbarModule,MatButtonModule,ReactiveFormsModule, CommonModule,MatFormFieldModule,MatInputModule],
3537
templateUrl: './book-import.component.html',
3638
styleUrl: './book-import.component.scss'
3739
})
@@ -51,6 +53,10 @@ export class BookImportComponent {
5153
return this.bookForm.controls[FormGroupKey.chapters] as FormArray<FormGroup>;
5254
}
5355

56+
protected removeChapter(chapterFg: FormGroup) {
57+
console.log(chapterFg);
58+
}
59+
5460
protected createChapterGroupForm(): FormGroup {
5561
return new FormGroup({
5662
[FormGroupKey.chapterStart]: new FormControl(0, Validators.required),

0 commit comments

Comments
 (0)