Skip to content

Commit 5783d27

Browse files
authored
fix(resource-instance-form): resource class name now updates correctly in the event that the name was changed and the page was not refreshed (#531)
1 parent e80a4d2 commit 5783d27

2 files changed

Lines changed: 8 additions & 18 deletions

File tree

‎src/app/workspace/resource/resource-instance-form/resource-instance-form.component.spec.ts‎

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ describe('ResourceInstanceFormComponent', () => {
299299
usersEndpoint: jasmine.createSpyObj('usersEndpoint', ['getUserByUsername'])
300300
},
301301
v2: {
302-
onto: jasmine.createSpyObj('onto', ['getOntologiesByProjectIri']),
302+
onto: jasmine.createSpyObj('onto', ['getOntologiesByProjectIri', 'getOntology', 'getResourceClassDefinition']),
303303
ontologyCache: jasmine.createSpyObj('ontologyCache', ['getOntology', 'getResourceClassDefinition']),
304304
res: jasmine.createSpyObj('res', ['createResource'])
305305
}
@@ -452,16 +452,11 @@ describe('ResourceInstanceFormComponent', () => {
452452
it('should show the select resource class component', () => {
453453
const dspConnSpy = TestBed.inject(DspApiConnectionToken);
454454

455-
(dspConnSpy.v2.ontologyCache as jasmine.SpyObj<OntologyCache>).getOntology.and.callFake(
455+
(dspConnSpy.v2.onto as jasmine.SpyObj<OntologiesEndpointV2>).getOntology.and.callFake(
456456
() => {
457457

458458
const anythingOnto = MockOntology.mockReadOntology('http://0.0.0.0:3333/ontology/0001/anything/v2');
459-
460-
const ontoMap: Map<string, ReadOntology> = new Map();
461-
462-
ontoMap.set('http://0.0.0.0:3333/ontology/0001/anything/v2', anythingOnto);
463-
464-
return of(ontoMap);
459+
return of(anythingOnto);
465460
}
466461
);
467462

@@ -484,16 +479,11 @@ describe('ResourceInstanceFormComponent', () => {
484479

485480
const dspConnSpy = TestBed.inject(DspApiConnectionToken);
486481

487-
(dspConnSpy.v2.ontologyCache as jasmine.SpyObj<OntologyCache>).getOntology.and.callFake(
482+
(dspConnSpy.v2.onto as jasmine.SpyObj<OntologiesEndpointV2>).getOntology.and.callFake(
488483
() => {
489484

490485
const anythingOnto = MockOntology.mockReadOntology('http://0.0.0.0:3333/ontology/0001/anything/v2');
491-
492-
const ontoMap: Map<string, ReadOntology> = new Map();
493-
494-
ontoMap.set('http://0.0.0.0:3333/ontology/0001/anything/v2', anythingOnto);
495-
496-
return of(ontoMap);
486+
return of(anythingOnto);
497487
}
498488
);
499489

‎src/app/workspace/resource/resource-instance-form/resource-instance-form.component.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,9 @@ export class ResourceInstanceFormComponent implements OnInit, OnDestroy {
305305

306306
this.selectedOntology = ontologyIri;
307307

308-
this._dspApiConnection.v2.ontologyCache.getOntology(ontologyIri).subscribe(
309-
(onto: Map<string, ReadOntology>) => {
310-
this.resourceClasses = onto.get(ontologyIri).getClassDefinitionsByType(ResourceClassDefinition);
308+
this._dspApiConnection.v2.onto.getOntology(ontologyIri).subscribe(
309+
(onto: ReadOntology) => {
310+
this.resourceClasses = onto.getClassDefinitionsByType(ResourceClassDefinition);
311311

312312
if (this.selectResourceClassComponent && this.resourceClasses.length === 1) {
313313
// since the component already exists, the ngAfterInit method of the component will not be called so we must assign the value here manually

0 commit comments

Comments
 (0)