Skip to content

Commit

Permalink
fix(ontology): bug fix in ontology form (DEV-280) (#603)
Browse files Browse the repository at this point in the history
* 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 4c1bc24
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
Expand Up @@ -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>
Expand Down
Expand Up @@ -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();


Expand Down
Expand Up @@ -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) {
Expand All @@ -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);
Expand Down

0 comments on commit 4c1bc24

Please sign in to comment.