Skip to content
Permalink
Browse files
fix(ontology): bug fix in ontology form (DEV-280) (#603)
* fix(ontology): bug fix in ontology form (DEV-280)

* test(ontology): fix broken tests
  • Loading branch information
kilchenmann committed Dec 8, 2021
1 parent f2c8d7a commit 4c1bc248d5020ea62b57dbac5a83294481275442
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
@@ -12,9 +12,9 @@
</mat-form-field>

<mat-form-field class="large-field ontology-label">
<input matInput [formControl]="ontologyForm.controls['label']" [placeholder]="iri ? 'Label *' : 'Label'"
[value]="ontologyLabel">
<span *ngIf="!iri" matPrefix>{{project.shortname}}:&nbsp;</span>
<input matInput [formControl]="ontologyForm.controls['label']" placeholder="Label *"
[value]="ontologyLabel">
<mat-hint *ngIf="formErrors.label">
{{ formErrors.label }}
</mat-hint>
@@ -174,7 +174,7 @@ describe('OntologyFormComponent', () => {
nameInput.setValue('biblio');

const compiled = ontologyFormFixture.debugElement;
expect(ontologyFormComponent.ontologyLabel).toEqual('Biblio');
expect(ontologyFormComponent.ontologyForm.controls.label.value).toEqual('Biblio');
expect(form.valid).toBeTruthy();


@@ -194,6 +194,12 @@ export class OntologyFormComponent implements OnInit {
});

this.ontologyForm.valueChanges.subscribe(data => this.onValueChanged(data));

if (!this.iri) {
this.ontologyForm.get('name').valueChanges.subscribe(val => {
this.ontologyForm.controls.label.setValue(this.capitalizeFirstLetter(val));
});
}
}

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

if (!this.iri) {
this.ontologyLabel = this.capitalizeFirstLetter(data.name);
}

Object.keys(this.formErrors).map(field => {
this.formErrors[field] = '';
const control = this.ontologyForm.get(field);

0 comments on commit 4c1bc24

Please sign in to comment.