Skip to content

Commit

Permalink
fix(resource-instance-form): resource class name now updates correctl…
Browse files Browse the repository at this point in the history
…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 5783d27
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
Expand Up @@ -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'])
}
Expand Down Expand Up @@ -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);
}
);

Expand All @@ -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);
}
);

Expand Down
Expand Up @@ -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
Expand Down

0 comments on commit 5783d27

Please sign in to comment.