Skip to content
Permalink
Browse files
fix(resource-instance-form): resource class name now updates correctl…
…y in the event that the name was changed and the page was not refreshed (#531)
  • Loading branch information
mdelez committed Sep 10, 2021
1 parent e80a4d2 commit 5783d27b2e7641b8491f28d6f0245de4421bfc1f
@@ -299,7 +299,7 @@ describe('ResourceInstanceFormComponent', () => {
usersEndpoint: jasmine.createSpyObj('usersEndpoint', ['getUserByUsername'])
},
v2: {
onto: jasmine.createSpyObj('onto', ['getOntologiesByProjectIri']),
onto: jasmine.createSpyObj('onto', ['getOntologiesByProjectIri', 'getOntology', 'getResourceClassDefinition']),
ontologyCache: jasmine.createSpyObj('ontologyCache', ['getOntology', 'getResourceClassDefinition']),
res: jasmine.createSpyObj('res', ['createResource'])
}
@@ -452,16 +452,11 @@ describe('ResourceInstanceFormComponent', () => {
it('should show the select resource class component', () => {
const dspConnSpy = TestBed.inject(DspApiConnectionToken);

(dspConnSpy.v2.ontologyCache as jasmine.SpyObj<OntologyCache>).getOntology.and.callFake(
(dspConnSpy.v2.onto as jasmine.SpyObj<OntologiesEndpointV2>).getOntology.and.callFake(
() => {

const anythingOnto = MockOntology.mockReadOntology('http://0.0.0.0:3333/ontology/0001/anything/v2');

const ontoMap: Map<string, ReadOntology> = new Map();

ontoMap.set('http://0.0.0.0:3333/ontology/0001/anything/v2', anythingOnto);

return of(ontoMap);
return of(anythingOnto);
}
);

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

const dspConnSpy = TestBed.inject(DspApiConnectionToken);

(dspConnSpy.v2.ontologyCache as jasmine.SpyObj<OntologyCache>).getOntology.and.callFake(
(dspConnSpy.v2.onto as jasmine.SpyObj<OntologiesEndpointV2>).getOntology.and.callFake(
() => {

const anythingOnto = MockOntology.mockReadOntology('http://0.0.0.0:3333/ontology/0001/anything/v2');

const ontoMap: Map<string, ReadOntology> = new Map();

ontoMap.set('http://0.0.0.0:3333/ontology/0001/anything/v2', anythingOnto);

return of(ontoMap);
return of(anythingOnto);
}
);

@@ -305,9 +305,9 @@ export class ResourceInstanceFormComponent implements OnInit, OnDestroy {

this.selectedOntology = ontologyIri;

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

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

0 comments on commit 5783d27

Please sign in to comment.