diff --git a/src/app/main/dialog/dialog.component.html b/src/app/main/dialog/dialog.component.html index b82622cbe4..d2682da841 100644 --- a/src/app/main/dialog/dialog.component.html +++ b/src/app/main/dialog/dialog.component.html @@ -323,7 +323,11 @@
- +
diff --git a/src/app/main/dialog/dialog.component.ts b/src/app/main/dialog/dialog.component.ts index fa5f7c5014..1270ad0b3a 100644 --- a/src/app/main/dialog/dialog.component.ts +++ b/src/app/main/dialog/dialog.component.ts @@ -7,7 +7,7 @@ import { FilteredResources } from 'src/app/workspace/results/list-view/list-view export interface DialogData { mode: string; // switch mode id: string | number; // main iri or status code - project?: string; // project code + project?: string; // project code (or iri) title?: string; subtitle?: string; comment?: string; diff --git a/src/app/project/ontology/resource-class-info/resource-class-info.component.html b/src/app/project/ontology/resource-class-info/resource-class-info.component.html index e751f80b04..640d1847af 100644 --- a/src/app/project/ontology/resource-class-info/resource-class-info.component.html +++ b/src/app/project/ontology/resource-class-info/resource-class-info.component.html @@ -33,8 +33,13 @@ (click)="editResourceClass.emit({iri: resourceClass.id, label: resourceClass.label})"> Edit resource class info + + + - diff --git a/src/app/project/ontology/resource-class-info/resource-class-info.component.ts b/src/app/project/ontology/resource-class-info/resource-class-info.component.ts index 367134d12e..ce380ece52 100644 --- a/src/app/project/ontology/resource-class-info/resource-class-info.component.ts +++ b/src/app/project/ontology/resource-class-info/resource-class-info.component.ts @@ -10,6 +10,7 @@ import { KnoraApiConnection, PropertyDefinition, ReadOntology, + ReadProject, ResourceClassDefinitionWithAllLanguages, ResourcePropertyDefinitionWithAllLanguages, UpdateOntology, @@ -490,7 +491,7 @@ export class ResourceClassInfoComponent implements OnInit { * opens resource instances in new tab using gravsearch * @param iri */ - openResource(iri: string) { + openResourceInstances(iri: string) { // open resource instances in new tab: // it's important not to indent the gravsearch. const gravsearch = ` @@ -514,4 +515,32 @@ OFFSET 0`; window.open(doSearchRoute, '_blank'); } + createResourceInstance(iri: string, label: string) { + let projectIri: string; + // get project iri + this._cache.get(this.projectCode).subscribe( + (res: ReadProject) => { + projectIri = res.id; + } + ); + + + const dialogConfig: MatDialogConfig = { + width: '840px', + maxHeight: '80vh', + position: { + top: '112px' + }, + data: { id: iri, mode: 'createResource', project: projectIri, title: label, subtitle: 'Set the property values of the resource' }, + disableClose: true + }; + + const dialogRef = this._dialog.open( + DialogComponent, + dialogConfig + ); + + dialogRef.afterClosed().subscribe(() => { }); + } + } diff --git a/src/app/workspace/resource/resource-instance-form/resource-instance-form.component.html b/src/app/workspace/resource/resource-instance-form/resource-instance-form.component.html index 6c1a9a8f39..c423577156 100644 --- a/src/app/workspace/resource/resource-instance-form/resource-instance-form.component.html +++ b/src/app/workspace/resource/resource-instance-form/resource-instance-form.component.html @@ -51,7 +51,7 @@ @@ -70,6 +70,7 @@
- - - + diff --git a/src/app/workspace/resource/resource-instance-form/resource-instance-form.component.ts b/src/app/workspace/resource/resource-instance-form/resource-instance-form.component.ts index 25d18f71a7..098eaa4ecf 100644 --- a/src/app/workspace/resource/resource-instance-form/resource-instance-form.component.ts +++ b/src/app/workspace/resource/resource-instance-form/resource-instance-form.component.ts @@ -1,4 +1,4 @@ -import { Component, EventEmitter, Inject, OnDestroy, OnInit, Output, ViewChild } from '@angular/core'; +import { Component, EventEmitter, Inject, Input, OnDestroy, OnInit, Output, ViewChild } from '@angular/core'; import { FormBuilder, FormGroup } from '@angular/forms'; import { Router } from '@angular/router'; import { @@ -9,7 +9,8 @@ import { CreateTextValueAsString, CreateValue, KnoraApiConnection, - OntologiesMetadata, ReadOntology, + OntologiesMetadata, + ReadOntology, ReadResource, ResourceClassAndPropertyDefinitions, ResourceClassDefinition, @@ -34,6 +35,11 @@ import { SelectResourceClassComponent } from './select-resource-class/select-res }) export class ResourceInstanceFormComponent implements OnInit, OnDestroy { + // ontology's resource class iri + @Input() selectedResourceClassIri?: string; + // corresponding project (iri) + @Input() selectedProject?: string; + // output to close dialog @Output() closeDialog: EventEmitter = new EventEmitter(); @@ -59,7 +65,6 @@ export class ResourceInstanceFormComponent implements OnInit, OnDestroy { userWentBack = false; usersProjects: StoredProject[]; - selectedProject: string; ontologiesMetadata: OntologiesMetadata; selectedOntology: string; resourceClasses: ResourceClassDefinition[]; @@ -100,24 +105,39 @@ export class ResourceInstanceFormComponent implements OnInit, OnDestroy { ngOnInit(): void { - // parent form is empty, it gets passed to the child components - this.selectResourceForm = this._fb.group({}); - this.propertiesParentForm = this._fb.group({}); + if (this.selectedResourceClassIri && this.selectedProject) { + // get ontology iri from res class iri + const splittedIri = this.selectedResourceClassIri.split('#'); + this.selectedOntology = splittedIri[0]; + this.selectProperties(this.selectedResourceClassIri); + + this.showNextStepForm = false; + + this.propertiesParentForm = this._fb.group({}); + + } else { + + // parent form is empty, it gets passed to the child components + this.selectResourceForm = this._fb.group({}); + this.propertiesParentForm = this._fb.group({}); - // initialize projects to be used for the project selection in the creation form - this._project.initializeProjects().subscribe( - (proj: StoredProject[]) => { - this.usersProjects = proj; + // initialize projects to be used for the project selection in the creation form + this._project.initializeProjects().subscribe( + (proj: StoredProject[]) => { + this.usersProjects = proj; - // notifies the user that he/she is not part of any project - if (proj.length === 0) { - this.errorMessage = 'You are not a part of any active projects or something went wrong'; + // notifies the user that he/she is not part of any project + if (proj.length === 0) { + this.errorMessage = 'You are not a part of any active projects or something went wrong'; + } } - } - ); + ); + + // boolean to show only the first step of the form (= selectResourceForm) + this.showNextStepForm = true; + } + - // boolean to show only the first step of the form (= selectResourceForm) - this.showNextStepForm = true; } @@ -186,7 +206,6 @@ export class ResourceInstanceFormComponent implements OnInit, OnDestroy { this.propertiesObj[iri] = [createVal]; } } - }); if (this.fileValue) { @@ -420,7 +439,6 @@ export class ResourceInstanceFormComponent implements OnInit, OnDestroy { if (!this.selectPropertiesComponent && this.properties.length === 0 && !this.hasFileValue) { this.errorMessage = 'No properties defined for the selected resource.'; } - this.loading = false; },