Skip to content

Commit a946dc5

Browse files
committed
Adding button back to mining component
1 parent c3abc24 commit a946dc5

File tree

6 files changed

+31
-27
lines changed

6 files changed

+31
-27
lines changed

src/app/hpoautocomplete/hpo-dialog-wrapper.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, inject, Inject } from '@angular/core';
1+
import { Component, inject } from '@angular/core';
22
import { MatDialogRef, MatDialogContent, MatDialogModule, MAT_DIALOG_DATA } from '@angular/material/dialog';
33
import { HpoAutocompleteComponent } from './hpoautocomplete.component';
44
import { HpoTermDuplet } from '../models/hpo_term_dto';

src/app/hpoautocomplete/hpoautocomplete.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export class HpoAutocompleteComponent {
5151
selected = output<HpoMatch>();
5252

5353
inputElement = viewChild<HTMLInputElement>('hpoInput');
54-
control = new FormControl<string | HpoMatch>('', [hpoMatchValidator()]);
54+
control = new FormControl<string | HpoMatch>('', [hpoMatchValidator()]);
5555

5656
// A helper signal for the parent to check validity
5757
isValid = toSignal(this.control.statusChanges.pipe(map(status => status === 'VALID')), { initialValue: false });

src/app/hpomining/hpomining.component.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, EventEmitter, Output } from '@angular/core';
1+
import { Component, EventEmitter, inject, Output } from '@angular/core';
22
import { ConfigService } from '../services/config.service';
33
import { NotificationService } from '../services/notification.service';
44
import { TextAnnotationDto } from '../models/text_annotation_dto';
@@ -12,16 +12,16 @@ import { CommonModule } from '@angular/common';
1212
imports: [CommonModule, FormsModule],
1313
})
1414
export class HpoMiningComponent {
15+
private configService = inject(ConfigService);
16+
private notificationService = inject(NotificationService);
17+
1518
pastedText = '';
1619

1720
@Output() success = new EventEmitter<TextAnnotationDto[]>();
1821
@Output() error = new EventEmitter<string>();
1922
@Output() cancel = new EventEmitter<void>();
2023

21-
constructor(
22-
private configService: ConfigService,
23-
private notificationService: NotificationService
24-
) {}
24+
2525

2626
async runTextMining(): Promise<void> {
2727
try {

src/app/hpominingverifier/hpominingverifier.component.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,12 @@ export class HpoMiningVerifierComponent implements OnInit {
5353
return ((this.currentIndex() + 1) / this.concepts().length) * 100;
5454
}
5555

56-
handleUpdate(newTerm: HpoTermDuplet): void {
56+
handleUpdate(match: HpoMatch): void {
5757
const updated = [...this.concepts()];
5858
const index = this.currentIndex();
59-
const newMatch: HpoMatch = {
60-
id: newTerm.hpoId,
61-
label: newTerm.hpoLabel,
62-
matchedText: newTerm.hpoLabel
63-
};
6459
updated[index] = {
6560
...updated[index],
66-
suggestedTerms: [...updated[index].suggestedTerms, newMatch]
61+
suggestedTerms: [...updated[index].suggestedTerms, match]
6762
};
6863
this.concepts.set(updated);
6964
}

src/app/hpopolishing/hpopolishing.component.html

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,21 @@
153153
</div>
154154

155155
<div class="space-y-1">
156-
<app-hpoautocomplete
157-
[inputString]="hpoInputString"
158-
(selected)="handleSelection($event)"
159-
></app-hpoautocomplete>
156+
<div class="flex items-center gap-2 bg-gray-50 p-3 rounded-lg border border-gray-200 shadow-sm">
157+
<div class="flex-grow">
158+
<app-hpoautocomplete
159+
[inputString]="hpoInputString"
160+
(selected)="handleSelection($event)"
161+
></app-hpoautocomplete>
162+
</div>
163+
164+
<button
165+
color="primary"
166+
(click)="submitSelectedHpo()"
167+
[disabled]="!selectedHpoTerm"
168+
class="btn-outline-primary h-[40px] px-6"
169+
>Submit</button>
170+
</div>
160171

161172
@if (selectedHpoTerm) {
162173
<p class="text-xs text-blue-600 italic">Last added: {{ selectedHpoTerm.label }}</p>

src/app/hpopolishing/hpopolishing.component.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ import { AddageComponent } from '../addages/addage.component';
1111
import { MatDialog } from '@angular/material/dialog';
1212
import { NotificationService } from '../services/notification.service';
1313
import { HpoMatch } from '../models/hpo_mapping_result';
14+
import { MatIcon } from "@angular/material/icon";
1415

1516
/** This component takes the results of the raw text mining (fenominal) and allows the user to revise them and add new terms */
1617
@Component({
1718
selector: 'app-hpopolishing',
1819
templateUrl: './hpopolishing.component.html',
1920
styleUrls: ['./hpopolishing.component.scss'],
2021
standalone: true,
21-
imports: [CommonModule, FormsModule, HpoAutocompleteComponent]
22+
imports: [CommonModule, FormsModule, HpoAutocompleteComponent, MatIcon]
2223
})
2324
export class HpoPolishingComponent implements OnInit {
2425

@@ -27,6 +28,8 @@ export class HpoPolishingComponent implements OnInit {
2728
@Output() done = new EventEmitter<HpoTermData[]>();
2829
@Output() cancel = new EventEmitter<void>();
2930

31+
@ViewChild(HpoAutocompleteComponent) hpoAutocomplete!: HpoAutocompleteComponent;
32+
3033
private ageService = inject(AgeInputService);
3134
private configService = inject(ConfigService);
3235
private dialog = inject(MatDialog);
@@ -159,14 +162,6 @@ export class HpoPolishingComponent implements OnInit {
159162

160163
async handleSelection(match: HpoMatch) {
161164
this.selectedHpoTerm = match;
162-
163-
// If you need to immediately convert it for an existing function:
164-
const duplet: HpoTermDuplet = {
165-
hpoId: match.id,
166-
hpoLabel: match.label
167-
};
168-
169-
await this.submitHpoAutocompleteTerm(duplet);
170165
}
171166

172167
submitSelectedHpo = async () => {
@@ -189,6 +184,9 @@ export class HpoPolishingComponent implements OnInit {
189184
return exists ? current : [...current, annot];
190185
});
191186
}
187+
if (this.hpoAutocomplete) {
188+
this.hpoAutocomplete.clear();
189+
}
192190
}
193191

194192
/** We get a list of TextAnnotationDto objects from the HPO Textmining app.

0 commit comments

Comments
 (0)