Skip to content

Commit 4c1bc24

Browse files
authored
fix(ontology): bug fix in ontology form (DEV-280) (#603)
* fix(ontology): bug fix in ontology form (DEV-280) * test(ontology): fix broken tests
1 parent f2c8d7a commit 4c1bc24

3 files changed

Lines changed: 9 additions & 7 deletions

File tree

‎src/app/project/ontology/ontology-form/ontology-form.component.html‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
</mat-form-field>
1313

1414
<mat-form-field class="large-field ontology-label">
15-
<input matInput [formControl]="ontologyForm.controls['label']" [placeholder]="iri ? 'Label *' : 'Label'"
16-
[value]="ontologyLabel">
1715
<span *ngIf="!iri" matPrefix>{{project.shortname}}:&nbsp;</span>
16+
<input matInput [formControl]="ontologyForm.controls['label']" placeholder="Label *"
17+
[value]="ontologyLabel">
1818
<mat-hint *ngIf="formErrors.label">
1919
{{ formErrors.label }}
2020
</mat-hint>

‎src/app/project/ontology/ontology-form/ontology-form.component.spec.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ describe('OntologyFormComponent', () => {
174174
nameInput.setValue('biblio');
175175

176176
const compiled = ontologyFormFixture.debugElement;
177-
expect(ontologyFormComponent.ontologyLabel).toEqual('Biblio');
177+
expect(ontologyFormComponent.ontologyForm.controls.label.value).toEqual('Biblio');
178178
expect(form.valid).toBeTruthy();
179179

180180

‎src/app/project/ontology/ontology-form/ontology-form.component.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,12 @@ export class OntologyFormComponent implements OnInit {
194194
});
195195

196196
this.ontologyForm.valueChanges.subscribe(data => this.onValueChanged(data));
197+
198+
if (!this.iri) {
199+
this.ontologyForm.get('name').valueChanges.subscribe(val => {
200+
this.ontologyForm.controls.label.setValue(this.capitalizeFirstLetter(val));
201+
});
202+
}
197203
}
198204

199205
onValueChanged(data?: any) {
@@ -202,10 +208,6 @@ export class OntologyFormComponent implements OnInit {
202208
return;
203209
}
204210

205-
if (!this.iri) {
206-
this.ontologyLabel = this.capitalizeFirstLetter(data.name);
207-
}
208-
209211
Object.keys(this.formErrors).map(field => {
210212
this.formErrors[field] = '';
211213
const control = this.ontologyForm.get(field);

0 commit comments

Comments
 (0)