Skip to content

Commit 6fdfa89

Browse files
Remove submit buttons
1 parent 2fae276 commit 6fdfa89

5 files changed

Lines changed: 57 additions & 85 deletions

File tree

frontend/src/app/annotate/annotation-input/annotation-input.component.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ <h2 i18n>Parser input</h2>
55
below.
66
</p>
77

8-
<div class="d-flex flex-column gap-5">
9-
@if (form(); as inputForm) {
10-
<la-premises-form
11-
[form]="inputForm"
12-
/>
13-
<la-knowledge-base-form
14-
[form]="inputForm"
15-
/>
16-
}
8+
@if (form(); as inputForm) {
9+
<div class="d-flex flex-row gap-5">
10+
<la-premises-form class="w-50" [form]="inputForm" />
11+
<la-knowledge-base-form class="w-50" [form]="inputForm" />
1712
</div>
13+
<button type="submit" class="btn btn-success" [disabled]="inputForm?.invalid">
14+
<fa-icon [icon]="faCheck" class="fa-sm" aria-hidden="true"></fa-icon>
15+
<span class="ms-2" i18n>Submit</span>
16+
</button>
17+
}

frontend/src/app/annotate/annotation-input/annotation-input.component.ts

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,19 @@ import {
1818
import { AnnotateService } from "../../services/annotate.service";
1919
import { toSignal } from "@angular/core/rxjs-interop";
2020
import { ProblemResponse } from "../../types";
21+
import { FontAwesomeModule } from "@fortawesome/angular-fontawesome";
22+
import { faCheck } from "@fortawesome/free-solid-svg-icons";
23+
24+
type KnowledgeBaseItemsForm = FormGroup<{
25+
entity1: FormControl<string>;
26+
relationship: FormControl<KnowledgeBaseRelationship>;
27+
entity2: FormControl<string>;
28+
}>;
2129

2230
export type AnnotationInputForm = FormGroup<{
2331
premises: FormArray<FormControl<string>>;
2432
conclusion: FormControl<string>;
25-
kbItems: FormArray<
26-
FormGroup<{
27-
entity1: FormControl<string>;
28-
relationship: FormControl<KnowledgeBaseRelationship>;
29-
entity2: FormControl<string>;
30-
}>
31-
>;
33+
kbItems: FormArray<KnowledgeBaseItemsForm>;
3234
}>;
3335

3436
@Component({
@@ -39,6 +41,7 @@ export type AnnotationInputForm = FormGroup<{
3941
PremisesFormComponent,
4042
KnowledgeBaseFormComponent,
4143
ReactiveFormsModule,
44+
FontAwesomeModule,
4245
],
4346
templateUrl: "./annotation-input.component.html",
4447
styleUrl: "./annotation-input.component.scss",
@@ -66,28 +69,12 @@ export class AnnotationInputComponent {
6669
validators: [Validators.required],
6770
nonNullable: true,
6871
}),
69-
kbItems: new FormArray([
70-
new FormGroup({
71-
entity1: new FormControl<string>("", {
72-
validators: [Validators.required],
73-
nonNullable: true,
74-
}),
75-
relationship: new FormControl<KnowledgeBaseRelationship>(
76-
KnowledgeBaseRelationship.EQUAL,
77-
{
78-
validators: [Validators.required],
79-
nonNullable: true,
80-
}
81-
),
82-
entity2: new FormControl<string>("", {
83-
validators: [Validators.required],
84-
nonNullable: true,
85-
}),
86-
}),
87-
]),
72+
kbItems: new FormArray<KnowledgeBaseItemsForm>([]),
8873
});
8974
});
9075

76+
public faCheck = faCheck;
77+
9178
constructor(private annotateService: AnnotateService) {}
9279

9380
public onSubmit(): void {
Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1+
@if (form().controls.kbItems.controls.length > 0) {
12
<section class="card">
23
<header class="card-header">
34
<h3 class="h5" i18n>Knowledge Base</h3>
45
</header>
56
<div class="card-body">
67
<form [formGroup]="form()" (ngSubmit)="onSubmit()">
78
<ul formArrayName="kbItems" class="ps-0 list-unstyled">
8-
<li
9-
*ngFor="
10-
let kbItem of form().controls.kbItems.controls;
11-
let i = index
12-
"
13-
class="mb-3"
14-
>
9+
@for (kbItem of form().controls.kbItems.controls; let i =
10+
$index; track $index) {
11+
<li class="mb-3">
1512
<div [formGroupName]="i" class="input-group">
1613
<input
1714
type="text"
@@ -27,9 +24,12 @@ <h3 class="h5" i18n>Knowledge Base</h3>
2724
<option value="" disabled selected i18n>
2825
Select Relationship
2926
</option>
30-
<option *ngFor="let relationship of relationshipTypes" [value]="relationship">
27+
@for (relationship of relationshipTypes; track
28+
$index) {
29+
<option [value]="relationship">
3130
{{ getRelationshipTypeName(relationship) }}
3231
</option>
32+
}
3333
</select>
3434
<input
3535
type="text"
@@ -53,33 +53,32 @@ <h3 class="h5" i18n>Knowledge Base</h3>
5353
</button>
5454
</div>
5555
</li>
56+
}
5657
</ul>
57-
<div class="btn-group" role="group">
58-
<button
59-
type="button"
60-
class="btn btn-primary"
61-
(click)="addKnowledgeBaseItem()"
62-
>
63-
<fa-icon
64-
[icon]="faPlus"
65-
class="fa-sm"
66-
aria-hidden="true"
67-
></fa-icon>
68-
<span class="ms-2" i18n>Add Item</span>
69-
</button>
70-
<button
71-
type="submit"
72-
class="btn btn-success"
73-
[disabled]="form().invalid"
74-
>
75-
<fa-icon
76-
[icon]="faCheck"
77-
class="fa-sm"
78-
aria-hidden="true"
79-
></fa-icon>
80-
<span class="ms-2" i18n>Submit</span>
81-
</button>
82-
</div>
58+
<button
59+
type="button"
60+
class="btn btn-primary"
61+
(click)="addKnowledgeBaseItem()"
62+
>
63+
<fa-icon
64+
[icon]="faPlus"
65+
class="fa-sm"
66+
aria-hidden="true"
67+
></fa-icon>
68+
<span class="ms-2" i18n>Add Item</span>
69+
</button>
8370
</form>
8471
</div>
8572
</section>
73+
} @else {
74+
<section>
75+
<button
76+
type="button"
77+
class="btn btn-primary"
78+
(click)="addKnowledgeBaseItem()"
79+
>
80+
<fa-icon [icon]="faPlus" class="fa-sm" aria-hidden="true"></fa-icon>
81+
<span class="ms-2" i18n>Add knowledge base item</span>
82+
</button>
83+
</section>
84+
}

frontend/src/app/annotate/annotation-input/knowledge-base-form/knowledge-base-form.component.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { Component, input } from "@angular/core";
2-
import { FormArray, FormGroup, Validators, FormControl } from "@angular/forms";
2+
import { FormGroup, Validators, FormControl } from "@angular/forms";
33
import { CommonModule } from "@angular/common";
44
import { ReactiveFormsModule } from "@angular/forms";
55
import { FontAwesomeModule } from "@fortawesome/angular-fontawesome";
6-
import { faCheck, faPlus, faTrash } from "@fortawesome/free-solid-svg-icons";
6+
import { faPlus, faTrash } from "@fortawesome/free-solid-svg-icons";
77
import { AnnotationInputForm } from "../annotation-input.component";
88

99
export enum KnowledgeBaseRelationship {
@@ -32,7 +32,6 @@ export class KnowledgeBaseFormComponent {
3232

3333
public relationshipTypes = Object.values(KnowledgeBaseRelationship);
3434

35-
public faCheck = faCheck;
3635
public faPlus = faPlus;
3736
public faTrash = faTrash;
3837

frontend/src/app/annotate/annotation-input/premises-form/premises-form.component.html

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,6 @@ <h3 class="h5" i18n>Premises and Conclusion</h3>
6565
[formControl]="form().controls.conclusion"
6666
/>
6767
</div>
68-
69-
<button
70-
type="submit"
71-
class="btn btn-success"
72-
[disabled]="form().invalid"
73-
>
74-
<fa-icon
75-
[icon]="faCheck"
76-
class="fa-sm"
77-
aria-hidden="true"
78-
></fa-icon>
79-
<span class="ms-2" i18n>Submit</span>
80-
</button>
8168
</form>
8269
</div>
8370
</section>

0 commit comments

Comments
 (0)