From bf3681c215d6d699e9bb560bd374316aa9290253 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Wed, 3 Feb 2021 10:19:51 +0100 Subject: [PATCH 01/20] style(ontology): update ontology editor style --- .../project/ontology/ontology.component.html | 111 +++++++------ .../project/ontology/ontology.component.scss | 150 ++++++++++-------- src/assets/style/_config.scss | 1 + 3 files changed, 141 insertions(+), 121 deletions(-) diff --git a/src/app/project/ontology/ontology.component.html b/src/app/project/ontology/ontology.component.html index 096b199529..77be5062f5 100644 --- a/src/app/project/ontology/ontology.component.html +++ b/src/app/project/ontology/ontology.component.html @@ -1,6 +1,7 @@
-

This is a first version of the ontology editor. Some features may not work as intended.

+

This is a first version of the ontology editor. Some features may not work as + intended.

@@ -53,7 +54,7 @@

-
+
@@ -102,62 +103,70 @@

{{ontology?.label}}

-

This ontology can't be edited because of - missing "lastModificationDate"!

-
- -
- - - - + + + +
- - -
- - -

- {{resClass.label | dspTruncate: 24}}

- - - - - - -
-
-
-
    - - +
    + + +

    + {{resClass.label | dspTruncate: 24}}

    + + + + + + +
    +
    +
    +
      + + -
    • - {{ontology?.properties[prop.propertyIndex].label}} -
    • -
      - -
    -
    +
  • + {{ontology?.properties[prop.propertyIndex].label}} +
  • + -
    +
+
+
+
+
diff --git a/src/app/project/ontology/ontology.component.scss b/src/app/project/ontology/ontology.component.scss index f18f8fda3f..061c638563 100644 --- a/src/app/project/ontology/ontology.component.scss +++ b/src/app/project/ontology/ontology.component.scss @@ -4,94 +4,104 @@ $width: 304px; .app-toolbar-action { - &.select-form { - margin-top: -18px; - } + &.select-form { + margin-top: -18px; + } - .form-content { - display: contents; + .form-content { + display: contents; - .select-ontology { - margin: 0 24px 0 0; - } + .select-ontology { + margin: 0 24px 0 0; } + } - .create-data-model-btn { - margin: 0 0 16px; - min-width: 140px; - } + .create-data-model-btn { + margin: 0 0 16px; + min-width: 140px; + } } .ontology-editor { - width: 98vw; - max-width: 1280px; - min-height: calc(100vh - #{$header-height} - #{$tab-bar-margin} - 100px); - border: 1px dotted $primary_200; - background: $primary_200; - position: relative; - margin: 0 auto 60px auto; + width: 98vw; + max-width: 1280px; + min-height: calc(100vh - #{$header-height} - #{$tab-bar-margin} - 100px); + border: 1px dotted $primary_200; + background: $primary_200; + position: relative; + margin: 0 auto 60px auto; } .ontology-viewer { - width: 98vw; - max-width: 1280px; - min-height: calc(100vh - #{$header-height} - #{$tab-bar-margin} - 100px); - border: 1px dotted $primary_200; - position: relative; - margin: 0 auto 60px auto; + width: 98vw; + max-width: 1280px; + min-height: calc(100vh - #{$header-height} - #{$tab-bar-margin} - 100px); + border: 1px dotted $primary_200; + position: relative; + margin: 0 auto 60px auto; } -.ontology-editor-canvas { - display: grid; - grid-template-columns: repeat(auto-fill, minmax($width, 1fr)); - grid-column-gap: 12px; - grid-row-gap: 12px; - padding-top: 60px; +.ontology-editor-container { + .ontology-editor-subheader { + height: $sub-header-height; + } + + .ontology-editor-canvas { + min-height: calc(100vh - #{$sub-header-height} - #{$header-height} - #{$tab-bar-margin} - 100px); + + .ontology-editor-grid { + display: grid; + grid-template-columns: repeat(auto-fill, minmax($width, 1fr)); + grid-column-gap: 12px; + grid-row-gap: 12px; + // padding-top: 60px; + } + } } .resource-class { - min-height: 120px; - height: auto; - position: relative; - @include mat-elevation-transition; - @include mat-elevation(2); - padding: 12px; - margin: 12px; - background-color: #fff; - - .resource-class-header { - margin: -12px -12px 12px -12px; - width: calc(100% + 24px); - min-height: 48px !important; - height: 48px; - cursor: move; - } + min-height: 120px; + height: auto; + position: relative; + @include mat-elevation-transition; + @include mat-elevation(2); + padding: 12px; + margin: 12px; + background-color: #fff; + + .resource-class-header { + margin: -12px -12px 12px -12px; + width: calc(100% + 24px); + min-height: 48px !important; + height: 48px; + cursor: move; + } - .resource-class-properties { - li { - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - margin-left: -24px; - list-style-position: inside; - } + .resource-class-properties { + li { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + margin-left: -24px; + list-style-position: inside; } + } - &:active { - @include mat-elevation(8); - } + &:active { + @include mat-elevation(8); + } } .ontology-editor-header { - border-bottom: 1px solid rgba(0, 0, 0, 0.12); - position: sticky !important; - top: 0; + border-bottom: 1px solid rgba(0, 0, 0, 0.12); + position: sticky !important; + top: 0; - .switch-view-label { - margin-right: 16px; - } + .switch-view-label { + margin-right: 16px; + } - button.active { - background-color: $black-12-opacity; - } + button.active { + background-color: $black-12-opacity; + } } /* .ontology-container { @@ -131,9 +141,9 @@ $width: 304px; */ .add-resource-class { - position: absolute; - right: 12px; - top: 80px; + position: absolute; + right: 12px; + top: 80px; } .mat-caption.space-reducer { diff --git a/src/assets/style/_config.scss b/src/assets/style/_config.scss index 29afb876ce..46727e4a67 100644 --- a/src/assets/style/_config.scss +++ b/src/assets/style/_config.scss @@ -20,4 +20,5 @@ $warn: #ef5350; $active: #66bb6a; $header-height: 72px; +$sub-header-height: 64px; $tab-bar-margin: 36px; From 003d342978e54ff2d9f96721a91c7631780e3d86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Wed, 3 Feb 2021 14:11:52 +0100 Subject: [PATCH 02/20] feat(ontology): init "update cardinality" funcitonality --- src/app/main/dialog/dialog.component.html | 29 +++++++++++++++++------ 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/app/main/dialog/dialog.component.html b/src/app/main/dialog/dialog.component.html index 45a19c019c..508d77d765 100644 --- a/src/app/main/dialog/dialog.component.html +++ b/src/app/main/dialog/dialog.component.html @@ -12,13 +12,15 @@
- + +
- + +
@@ -95,13 +97,15 @@
- + +
- + + Do you want to deactivate this project?
+
+ + + + +
+
@@ -235,7 +249,8 @@
- + +
From 5d807b975047b2ca41bf1fe8b3ec07cf51525803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Wed, 3 Feb 2021 14:12:37 +0100 Subject: [PATCH 03/20] chore(ontology): prepare resclass from for card update --- .../resource-class-form.component.html | 5 ++++- .../resource-class-form.component.ts | 22 ++++++++++++++----- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/app/project/ontology/resource-class-form/resource-class-form.component.html b/src/app/project/ontology/resource-class-form/resource-class-form.component.html index 81c09d7a7e..9a763b303f 100644 --- a/src/app/project/ontology/resource-class-form/resource-class-form.component.html +++ b/src/app/project/ontology/resource-class-form/resource-class-form.component.html @@ -76,9 +76,12 @@
- + diff --git a/src/app/project/ontology/resource-class-form/resource-class-form.component.ts b/src/app/project/ontology/resource-class-form/resource-class-form.component.ts index 7ca82b0363..d27fde0d37 100644 --- a/src/app/project/ontology/resource-class-form/resource-class-form.component.ts +++ b/src/app/project/ontology/resource-class-form/resource-class-form.component.ts @@ -53,6 +53,19 @@ export class ResourceClassFormComponent implements OnInit, OnDestroy, AfterViewC // store name as resourceClassTitle on init; in this case it can't be overwritten in the next / prev navigation resourceClassTitle: string; + // two step form: which should be active? + /** + * two step form: which should be active? + * true => step 1 shows label and comment of resource class + * false => step 2 shows list of properties of resource class + */ + @Input() showResourceClassForm: boolean = true; + + /** + * edit mode (true); otherwise create mode + */ + @Input() edit: boolean; + /** * emit event, when closing dialog */ @@ -81,9 +94,6 @@ export class ResourceClassFormComponent implements OnInit, OnDestroy, AfterViewC // in case of an error error: boolean; - // two step form: which should be active? - showResourceClassForm: boolean = true; - // form group, form array (for properties) errors and validation messages resourceClassForm: FormGroup; @@ -164,7 +174,7 @@ export class ResourceClassFormComponent implements OnInit, OnDestroy, AfterViewC } ); - // get all lists; will be used to set guit attribut in list property + // get all lists; will be used to set gui attribute in list property this._dspApiConnection.admin.listsEndpoint.getListsInProject(this.projectIri).subscribe( (response: ApiResponseData) => { this._cache.set('currentOntologyLists', response.body.lists); @@ -285,7 +295,7 @@ export class ResourceClassFormComponent implements OnInit, OnDestroy, AfterViewC this.showResourceClassForm = false; // use response to go further with properties - this.updateParent.emit({ title: this.resourceClassLabels[0].value, subtitle: 'Define the metadata for resource class' }); + this.updateParent.emit({ title: this.resourceClassLabels[0].value, subtitle: 'Define the metadata fields for the resource class' }); // load one first property line if (!this.resourceClassForm.value.properties.length) { @@ -297,7 +307,7 @@ export class ResourceClassFormComponent implements OnInit, OnDestroy, AfterViewC */ prevStep(ev: Event) { ev.preventDefault(); - this.updateParent.emit({ title: this.resourceClassTitle, subtitle: 'Customize resource class' }); + this.updateParent.emit({ title: this.resourceClassTitle, subtitle: 'Customize the resource class' }); this.showResourceClassForm = true; } From 30ebdd2cde0b6864a04649d159aae4bfcc10db4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Wed, 3 Feb 2021 14:12:58 +0100 Subject: [PATCH 04/20] feat(ontology): update card --- .../project/ontology/ontology.component.html | 3 ++ .../project/ontology/ontology.component.ts | 34 ++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/app/project/ontology/ontology.component.html b/src/app/project/ontology/ontology.component.html index 77be5062f5..95e72b841d 100644 --- a/src/app/project/ontology/ontology.component.html +++ b/src/app/project/ontology/ontology.component.html @@ -144,6 +144,9 @@

+ diff --git a/src/app/project/ontology/ontology.component.ts b/src/app/project/ontology/ontology.component.ts index d9fad80e7f..873e27d61f 100644 --- a/src/app/project/ontology/ontology.component.ts +++ b/src/app/project/ontology/ontology.component.ts @@ -320,7 +320,39 @@ export class OntologyComponent implements OnInit { data: { name: subClassOf.iri, title: subClassOf.label, subtitle: 'Customize resource class', mode: mode, project: this.project.id } }; - const dialogRef = this._dialog.open(DialogComponent, dialogConfig); + const dialogRef = this._dialog.open( + DialogComponent, + dialogConfig + ); + + dialogRef.afterClosed().subscribe(result => { + // update the view + this.getOntology(this.ontologyIri); + }); + } + + + /** + * Updates cardinality + * @param subClassOf resource class + */ + updateCard(subClassOf: DefaultClass) { + + console.log(subClassOf) + + const dialogConfig: MatDialogConfig = { + width: '560px', + maxHeight: '80vh', + position: { + top: '112px' + }, + data: { mode: 'updateCardinality', id: subClassOf.iri, title: subClassOf.label, subtitle: 'Update the metadata fields of resource class', project: this.project.id} + }; + + const dialogRef = this._dialog.open( + DialogComponent, + dialogConfig + ); dialogRef.afterClosed().subscribe(result => { // update the view From a104065e3715e4290797e3ffa1cd788bc71e98a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Thu, 4 Feb 2021 17:10:44 +0100 Subject: [PATCH 05/20] chore(dsp-js): using yalc for dsp-js for the moment --- package-lock.json | 4 +- package.json | 2 +- src/app/main/dialog/dialog.component.html | 4 +- .../project/ontology/ontology.component.ts | 16 +- .../property-form.component.html | 2 +- .../property-form/property-form.component.ts | 26 +- .../resource-class-form.component.html | 6 +- .../resource-class-form.component.ts | 263 +++++++++++++----- .../resource-class-form.service.ts | 77 ++++- 9 files changed, 298 insertions(+), 102 deletions(-) diff --git a/package-lock.json b/package-lock.json index 322508293d..1595bc0d1a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1700,9 +1700,7 @@ } }, "@dasch-swiss/dsp-js": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@dasch-swiss/dsp-js/-/dsp-js-1.3.0.tgz", - "integrity": "sha512-wF3ib5sc3DWhJkAu8NOdgNHc40P38NtCtrxt3HR0cletc+HXrdhvVbM2hzfkuIyDPnnnY6a7QEguBrhkVlwZ9A==", + "version": "file:.yalc/@dasch-swiss/dsp-js", "requires": { "@types/jsonld": "^1.5.0", "json2typescript": "1.4.1", diff --git a/package.json b/package.json index 882a92f4c7..5de908854f 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "@angular/platform-browser-dynamic": "~9.1.12", "@angular/router": "~9.1.12", "@ckeditor/ckeditor5-angular": "^1.2.3", - "@dasch-swiss/dsp-js": "^1.3.0", + "@dasch-swiss/dsp-js": "file:.yalc/@dasch-swiss/dsp-js", "@dasch-swiss/dsp-ui": "^1.2.1", "@ngx-translate/core": "^13.0.0", "@ngx-translate/http-loader": "^6.0.0", diff --git a/src/app/main/dialog/dialog.component.html b/src/app/main/dialog/dialog.component.html index 508d77d765..adb94c7736 100644 --- a/src/app/main/dialog/dialog.component.html +++ b/src/app/main/dialog/dialog.component.html @@ -201,7 +201,7 @@
-
@@ -235,7 +235,7 @@
-
diff --git a/src/app/project/ontology/ontology.component.ts b/src/app/project/ontology/ontology.component.ts index 873e27d61f..c7fcf45524 100644 --- a/src/app/project/ontology/ontology.component.ts +++ b/src/app/project/ontology/ontology.component.ts @@ -15,6 +15,7 @@ import { ProjectResponse, ReadOntology, ReadProject, + ResourceClassDefinition, UpdateOntology } from '@dasch-swiss/dsp-js'; import { DspApiConnectionToken, Session, SessionService } from '@dasch-swiss/dsp-ui'; @@ -312,12 +313,13 @@ export class OntologyComponent implements OnInit { this._cache.set('currentOntology', this.ontology); const dialogConfig: MatDialogConfig = { + disableClose: true, width: '840px', maxHeight: '90vh', position: { top: '112px' }, - data: { name: subClassOf.iri, title: subClassOf.label, subtitle: 'Customize resource class', mode: mode, project: this.project.id } + data: { id: subClassOf.iri, title: subClassOf.label, subtitle: 'Customize resource class', mode: mode, project: this.project.id } }; const dialogRef = this._dialog.open( @@ -336,17 +338,19 @@ export class OntologyComponent implements OnInit { * Updates cardinality * @param subClassOf resource class */ - updateCard(subClassOf: DefaultClass) { + updateCard(subClassOf: ResourceClassDefinition) { - console.log(subClassOf) + // set ontology cache + this._cache.set('currentOntology', this.ontology); const dialogConfig: MatDialogConfig = { - width: '560px', - maxHeight: '80vh', + disableClose: true, + width: '840px', + maxHeight: '90vh', position: { top: '112px' }, - data: { mode: 'updateCardinality', id: subClassOf.iri, title: subClassOf.label, subtitle: 'Update the metadata fields of resource class', project: this.project.id} + data: { mode: 'updateCardinality', id: subClassOf.id, title: subClassOf.label, subtitle: 'Update the metadata fields of resource class', project: this.project.id} }; const dialogRef = this._dialog.open( diff --git a/src/app/project/ontology/property-form/property-form.component.html b/src/app/project/ontology/property-form/property-form.component.html index 2256c19c4a..37fe0daf1a 100644 --- a/src/app/project/ontology/property-form/property-form.component.html +++ b/src/app/project/ontology/property-form/property-form.component.html @@ -16,7 +16,7 @@ - + {{ prop?.label }} diff --git a/src/app/project/ontology/property-form/property-form.component.ts b/src/app/project/ontology/property-form/property-form.component.ts index 31c634982c..369a0baf6c 100644 --- a/src/app/project/ontology/property-form/property-form.component.ts +++ b/src/app/project/ontology/property-form/property-form.component.ts @@ -46,6 +46,8 @@ export class PropertyFormComponent implements OnInit { @Input() index: number; + @Input() ontology?: ReadOntology; + @Output() deleteProperty: EventEmitter = new EventEmitter(); iri = new FormControl(); @@ -63,7 +65,7 @@ export class PropertyFormComponent implements OnInit { lists: ListNodeInfo[]; // current ontology - ontology: ReadOntology; + // ontology: ReadOntology; // reresource classs in this ontology reresourceClasss: ClassDefinition[] = []; @@ -104,6 +106,18 @@ export class PropertyFormComponent implements OnInit { if (this.propertyForm) { // init list of property types with first element this.propertyForm.patchValue({ type: this.propertyTypes[0].elements[0] }); + + if (this.propertyForm.value.label) { + + const existingProp: AutocompleteItem = { + iri: this.propertyForm.value.iri, + label: this.propertyForm.value.label, + name: '' + } + + // edit mode: this prop value exists already + this.updateFieldsDependingOnLabel(existingProp); + } } this._cache.get('currentOntology').subscribe( @@ -197,14 +211,14 @@ export class PropertyFormComponent implements OnInit { /** * @param {MatOption} option */ - updateFieldsDependingOnLabel(option: MatOption) { - this.propertyForm.controls['iri'].setValue(option.value.iri); + updateFieldsDependingOnLabel(option: AutocompleteItem) { + this.propertyForm.controls['iri'].setValue(option.iri); - this.propertyForm.controls['label'].setValue(option.value.label); + this.propertyForm.controls['label'].setValue(option.label); this.propertyForm.controls['label'].disable(); - if (this.ontology.properties[option.value.iri] instanceof ResourcePropertyDefinition) { - const tempProp: any | ResourcePropertyDefinition = this.ontology.properties[option.value.iri]; + if (this.ontology.properties[option.iri] instanceof ResourcePropertyDefinition) { + const tempProp: any | ResourcePropertyDefinition = this.ontology.properties[option.iri]; let obj: PropertyType; // find gui ele from list of default property-types to set type value diff --git a/src/app/project/ontology/resource-class-form/resource-class-form.component.html b/src/app/project/ontology/resource-class-form/resource-class-form.component.html index 9a763b303f..8a3f54cc41 100644 --- a/src/app/project/ontology/resource-class-form/resource-class-form.component.html +++ b/src/app/project/ontology/resource-class-form/resource-class-form.component.html @@ -60,7 +60,7 @@ drag_indicator - +

diff --git a/src/app/project/ontology/resource-class-form/resource-class-form.component.ts b/src/app/project/ontology/resource-class-form/resource-class-form.component.ts index d27fde0d37..e038537e35 100644 --- a/src/app/project/ontology/resource-class-form/resource-class-form.component.ts +++ b/src/app/project/ontology/resource-class-form/resource-class-form.component.ts @@ -4,12 +4,16 @@ import { FormArray, FormGroup } from '@angular/forms'; import { ApiResponseData, ApiResponseError, + ClassDefinition, Constants, CreateResourceClass, CreateResourceProperty, + IHasProperty, KnoraApiConnection, ListsResponse, + PropertyDefinition, ReadOntology, + ResourceClassDefinitionWithAllLanguages, ResourcePropertyDefinitionWithAllLanguages, StringLiteral, @@ -40,10 +44,11 @@ export class ResourceClassFormComponent implements OnInit, OnDestroy, AfterViewC @Input() projectIri: string; /** - * selected resource class is a subclass from knora base (baseClassIri) + * create mode: iri selected resource class is a subclass from knora base (baseClassIri) + * edit mode: iri of resource class * e.g. knora-api:StillImageRepresentation */ - @Input() subClassOf: string; + @Input() iri: string; /** * name of resource class e.g. Still image @@ -64,7 +69,7 @@ export class ResourceClassFormComponent implements OnInit, OnDestroy, AfterViewC /** * edit mode (true); otherwise create mode */ - @Input() edit: boolean; + @Input() edit: boolean; /** * emit event, when closing dialog @@ -206,12 +211,46 @@ export class ResourceClassFormComponent implements OnInit, OnDestroy, AfterViewC // reset properties this._resourceClassFormService.resetProperties(); - this.resourceClassFormSub = this._resourceClassFormService.resourceClassForm$ - .subscribe(resourceClass => { - this.resourceClassForm = resourceClass; - this.properties = this.resourceClassForm.get('properties') as FormArray; + if (this.edit) { + // get resource class and property definition first + + // get list of ontology properties + const ontoProperties: PropertyDefinition[] = this.ontology.getAllPropertyDefinitions(); + // Object.keys(ontoProperties).forEach(key => { + // if (ontoProperties[key].id === ontoClasses[key]. .iri) { + + // console.warn('you want to edit the card. of', ontoClasses[key]); + // this._resourceClassFormService.setProperties(ontoClasses[key]); + + // this.resourceClassFormSub = this._resourceClassFormService.resourceClassForm$ + // .subscribe(resourceClass => { + // this.resourceClassForm = resourceClass; + // this.properties = this.resourceClassForm.get('properties') as FormArray; + // }); + // } + // }); + // find prop cardinality in resource class + const ontoClasses: ClassDefinition[] = this.ontology.getAllClassDefinitions(); + Object.keys(ontoClasses).forEach(key => { + if (ontoClasses[key].id === this.iri) { + + this._resourceClassFormService.setProperties(ontoClasses[key], ontoProperties); + + this.resourceClassFormSub = this._resourceClassFormService.resourceClassForm$ + .subscribe(resourceClass => { + this.resourceClassForm = resourceClass; + this.properties = this.resourceClassForm.get('properties') as FormArray; + }); + } }); + } else { + this.resourceClassFormSub = this._resourceClassFormService.resourceClassForm$ + .subscribe(resourceClass => { + this.resourceClassForm = resourceClass; + this.properties = this.resourceClassForm.get('properties') as FormArray; + }); + } this.resourceClassForm.valueChanges.subscribe(data => this.onValueChanged(data)); } @@ -320,40 +359,50 @@ export class ResourceClassFormComponent implements OnInit, OnDestroy, AfterViewC submitData() { this.loading = true; - // set resource class name / id - const uniqueClassName: string = this._resourceClassFormService.setUniqueName(this.ontology.id, this.resourceClassLabels[0].value); - const onto = new UpdateOntology(); - onto.id = this.ontology.id; - onto.lastModificationDate = this.lastModificationDate; + // submit resource class data to knora and create resource class incl. cardinality + // console.log('submit resource class data:', resourceClassData); + // let i: number = 0; + if (this.edit) { + // edit mode + console.log(this.lastModificationDate); + // post prop data; one by one + this.submitProps(this.resourceClassForm.value.properties, this.iri); - const newResClass = new CreateResourceClass(); + } else { + // create mode + // set resource class name / id + const uniqueClassName: string = this._resourceClassFormService.setUniqueName(this.ontology.id, this.resourceClassLabels[0].value); - newResClass.name = uniqueClassName - newResClass.label = this.resourceClassLabels; - newResClass.comment = this.resourceClassComments; - newResClass.subClassOf = [this.subClassOf]; + const onto = new UpdateOntology(); - onto.entity = newResClass; + onto.id = this.ontology.id; + onto.lastModificationDate = this.lastModificationDate; - // submit resource class data to knora and create resource class incl. cardinality - // console.log('submit resource class data:', resourceClassData); - // let i: number = 0; - this._dspApiConnection.v2.onto.createResourceClass(onto).subscribe( - (classResponse: ResourceClassDefinitionWithAllLanguages) => { - // console.log('classResponse', classResponse); - // need lmd from classResponse - this.lastModificationDate = classResponse.lastModificationDate; + const newResClass = new CreateResourceClass(); - // post prop data; one by one - this.submitProps(this.resourceClassForm.value.properties, classResponse.id); + newResClass.name = uniqueClassName + newResClass.label = this.resourceClassLabels; + newResClass.comment = this.resourceClassComments; + newResClass.subClassOf = [this.iri]; - }, - (error: ApiResponseError) => { - this._errorHandler.showMessage(error); - } - ); + onto.entity = newResClass; + this._dspApiConnection.v2.onto.createResourceClass(onto).subscribe( + (classResponse: ResourceClassDefinitionWithAllLanguages) => { + // console.log('classResponse', classResponse); + // need lmd from classResponse + this.lastModificationDate = classResponse.lastModificationDate; + + // post prop data; one by one + this.submitProps(this.resourceClassForm.value.properties, classResponse.id); + + }, + (error: ApiResponseError) => { + this._errorHandler.showMessage(error); + } + ); + } // show message to close dialog box @@ -371,43 +420,48 @@ export class ResourceClassFormComponent implements OnInit, OnDestroy, AfterViewC submitProps(props: Property[], classIri: string) { - let i = 1; - from(props) - .pipe(concatMap( - (prop: Property) => { - // submit prop - // console.log('first pipe operator...waiting...prepare and submit prop', prop); - if (prop.iri) { - // the defined prop exists already in this ontology. We can proceed with cardinality. - this.setCardinality(prop.iri, classIri, prop.multiple, prop.required, i); - } else { - // the defined prop does not exist yet. We have to create it. - this.createProp(prop, classIri, i); + if (this.edit) { + this.replaceCardinality(props, classIri); + } else { + let i = 1; + from(props) + .pipe(concatMap( + (prop: Property) => { + // submit prop + // console.log('first pipe operator...waiting...prepare and submit prop', prop); + if (prop.iri) { + // the defined prop exists already in this ontology. We can proceed with cardinality. + this.setCardinality(prop.iri, classIri, prop.multiple, prop.required, i); + } else { + // the defined prop does not exist yet. We have to create it. + this.createProp(prop, classIri, i); + } + return new Promise(resolve => setTimeout(() => resolve(prop), 1200)); } - return new Promise(resolve => setTimeout(() => resolve(prop), 1200)); - } - )) - .pipe(concatMap( - (prop: Property) => { - i++; - // console.log('second pipe operator; do sth. with prop response', prop); - return of(prop); - } - )) - .subscribe( - (prop: Property) => { - // this.getOntology(this.ontologyId); - - if (i > props.length) { - // console.log('at the end: created', prop) - // TODO: reset ontology cache - - // close the dialog box - this.loading = false; - this.closeDialog.emit(); + )) + .pipe(concatMap( + (prop: Property) => { + i++; + // console.log('second pipe operator; do sth. with prop response', prop); + return of(prop); } - } - ); + )) + .subscribe( + (prop: Property) => { + // this.getOntology(this.ontologyId); + + if (i > props.length) { + // console.log('at the end: created', prop) + // TODO: reset ontology cache + + // close the dialog box + this.loading = false; + this.closeDialog.emit(); + } + } + ); + } + } @@ -482,11 +536,15 @@ export class ResourceClassFormComponent implements OnInit, OnDestroy, AfterViewC setCardinality(propIri: string, classIri: string, multiple: boolean, required: boolean, index: number) { - const addCard = new UpdateOntologyResourceClassCardinality(); + const onto = new UpdateOntology(); + + onto.lastModificationDate = this.lastModificationDate; - addCard.lastModificationDate = this.lastModificationDate; + onto.id = this.ontology.id; + + const addCard = new UpdateOntologyResourceClassCardinality(); - addCard.id = this.ontology.id; + addCard.id = classIri; const cardinality = this._resourceClassFormService.translateCardinality(multiple, required); @@ -494,18 +552,75 @@ export class ResourceClassFormComponent implements OnInit, OnDestroy, AfterViewC { propertyIndex: propIri, cardinality: cardinality, - resourceClass: classIri, guiOrder: index } ]; + onto.entity = addCard; + + if (this.edit) { + + this._dspApiConnection.v2.onto.replaceCardinalityOfResourceClass(onto).subscribe( + (res: ResourceClassDefinitionWithAllLanguages) => { + this.lastModificationDate = res.lastModificationDate; + }, + (error: ApiResponseError) => { + this._errorHandler.showMessage(error); + } + ) + + } else { + this._dspApiConnection.v2.onto.addCardinalityToResourceClass(onto).subscribe( + (res: ResourceClassDefinitionWithAllLanguages) => { + this.lastModificationDate = res.lastModificationDate; + }, + (error: ApiResponseError) => { + this._errorHandler.showMessage(error); + } + ); + } + + } + + replaceCardinality(props: Property[], classIri: string) { + const onto = new UpdateOntology(); - this._dspApiConnection.v2.onto.addCardinalityToResourceClass(addCard).subscribe( + onto.lastModificationDate = this.lastModificationDate; + + console.log(this.lastModificationDate); + + onto.id = this.ontology.id; + + const addCard = new UpdateOntologyResourceClassCardinality(); + + addCard.id = classIri; + + addCard.cardinalities = []; + + props.forEach((prop, index) => { + const propCard: IHasProperty = { + propertyIndex: prop.iri, + cardinality: this._resourceClassFormService.translateCardinality(prop.multiple, prop.required), + guiOrder: index + 1 + } + + addCard.cardinalities.push(propCard); + }); + + onto.entity = addCard; + + this._dspApiConnection.v2.onto.replaceCardinalityOfResourceClass(onto).subscribe( (res: ResourceClassDefinitionWithAllLanguages) => { + console.log('result', res); this.lastModificationDate = res.lastModificationDate; + // close the dialog box + this.loading = false; + this.closeDialog.emit(); + }, + (error: ApiResponseError) => { + this._errorHandler.showMessage(error); } ); - } } diff --git a/src/app/project/ontology/resource-class-form/resource-class-form.service.ts b/src/app/project/ontology/resource-class-form/resource-class-form.service.ts index e0dd89cd6a..7333432e68 100644 --- a/src/app/project/ontology/resource-class-form/resource-class-form.service.ts +++ b/src/app/project/ontology/resource-class-form/resource-class-form.service.ts @@ -1,8 +1,8 @@ import { Injectable } from '@angular/core'; import { FormArray, FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; -import { Cardinality } from '@dasch-swiss/dsp-js'; +import { Cardinality, IHasProperty, PropertyDefinition, ResourceClassDefinition, ResourcePropertyDefinition } from '@dasch-swiss/dsp-js'; import { BehaviorSubject, Observable } from 'rxjs'; -import { PropertyType } from '../default-data/default-properties'; +import { DefaultProperties, PropertyType } from '../default-data/default-properties'; // property data structure export class Property { @@ -83,7 +83,14 @@ export class ResourceClassForm { constructor(resourceClass: ResourceClass) { if (resourceClass.properties) { - this.properties.setValue([resourceClass.properties]); + let i = 0; + this.properties.setControl + resourceClass.properties.forEach(prop => { + this.properties[i] = new FormControl(prop); + // this.properties[i].setValue(prop); + i++; + }); + // this.properties.setValue([resourceClass.properties]); } } } @@ -113,17 +120,75 @@ export class ResourceClassFormService { this.resourceClassForm.next(currentResourceClass); } + /** + * Sets properties in case of update resource class' cardinalities + * @param resClass + */ + setProperties(resClass: ResourceClassDefinition, ontoProperties: PropertyDefinition[]) { + + const updateResClass = new ResourceClass(); + + updateResClass.properties = []; + + // get cardinality and gui order and grab property definition + resClass.propertiesList.forEach((prop: IHasProperty) => { + if (prop.guiOrder >= 0) { + const property: Property = new Property(); + property.iri = prop.propertyIndex; + + // convert cardinality + switch(prop.cardinality) { + case 0: + property.multiple = false; + property.required = true; + break; + case 1: + property.multiple = false; + property.required = false; + break; + case 2: + property.multiple = true; + property.required = false; + break; + case 3: + property.multiple = true; + property.required = true; + break; + } + + // get property definition + Object.keys(ontoProperties).forEach(key => { + if (ontoProperties[key].id === property.iri) { + const propDef: ResourcePropertyDefinition = ontoProperties[key]; + property.label = propDef.label; + + // find property type in list of default properties + // just a test + // property.type = DefaultProperties.data[0].elements[0]; + + property.guiAttr = propDef.guiAttributes[0]; + } + }); + + this.addProperty(property); + + } + + }); + + } + /** * add new property line */ - addProperty() { + addProperty(prop?: Property) { const currentResourceClass = this.resourceClassForm.getValue(); const currentProperties = currentResourceClass.get('properties') as FormArray; currentProperties.push( this._fb.group( - new PropertyForm(new Property('', '', {}, false, false)) + new PropertyForm((prop ? prop : new Property('', '', {}, false, false))) ) ); @@ -198,6 +263,6 @@ export class ResourceClassFormService { // Cardinality 0-1 (optional) return Cardinality._0_1; } - } + } From 123a6de06918e308232f1127c8f2e718551c0742 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Thu, 4 Feb 2021 17:14:23 +0100 Subject: [PATCH 06/20] chore(dsp-api): using latest dsp-js version from main branch --- .../resource-class-form.component.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/app/project/ontology/resource-class-form/resource-class-form.component.ts b/src/app/project/ontology/resource-class-form/resource-class-form.component.ts index e038537e35..7d722e62c3 100644 --- a/src/app/project/ontology/resource-class-form/resource-class-form.component.ts +++ b/src/app/project/ontology/resource-class-form/resource-class-form.component.ts @@ -18,7 +18,7 @@ import { ResourcePropertyDefinitionWithAllLanguages, StringLiteral, UpdateOntology, - UpdateOntologyResourceClassCardinality + UpdateResourceClassCardinality } from '@dasch-swiss/dsp-js'; import { StringLiteralV2 } from '@dasch-swiss/dsp-js/src/models/v2/string-literal-v2'; import { DspApiConnectionToken } from '@dasch-swiss/dsp-ui'; @@ -536,13 +536,13 @@ export class ResourceClassFormComponent implements OnInit, OnDestroy, AfterViewC setCardinality(propIri: string, classIri: string, multiple: boolean, required: boolean, index: number) { - const onto = new UpdateOntology(); + const onto = new UpdateOntology(); onto.lastModificationDate = this.lastModificationDate; onto.id = this.ontology.id; - const addCard = new UpdateOntologyResourceClassCardinality(); + const addCard = new UpdateResourceClassCardinality(); addCard.id = classIri; @@ -583,7 +583,7 @@ export class ResourceClassFormComponent implements OnInit, OnDestroy, AfterViewC } replaceCardinality(props: Property[], classIri: string) { - const onto = new UpdateOntology(); + const onto = new UpdateOntology(); onto.lastModificationDate = this.lastModificationDate; @@ -591,7 +591,7 @@ export class ResourceClassFormComponent implements OnInit, OnDestroy, AfterViewC onto.id = this.ontology.id; - const addCard = new UpdateOntologyResourceClassCardinality(); + const addCard = new UpdateResourceClassCardinality(); addCard.id = classIri; From 5b4ae569c84ea241f00932d5f8faa5e61fff31d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Fri, 5 Feb 2021 16:17:44 +0100 Subject: [PATCH 07/20] chore(dependency): update js-lib to latest version --- package-lock.json | 4 +++- package.json | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1595bc0d1a..d1ac2d0820 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1700,7 +1700,9 @@ } }, "@dasch-swiss/dsp-js": { - "version": "file:.yalc/@dasch-swiss/dsp-js", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@dasch-swiss/dsp-js/-/dsp-js-2.0.0.tgz", + "integrity": "sha512-nPYUa1Pl2lpBbNvaOu2YTmVJATksNUOmDKiag8wJI/uux7KVfLjsX08wirMN/fsPr4PnR/Gg/4uTUAMMzMIe0g==", "requires": { "@types/jsonld": "^1.5.0", "json2typescript": "1.4.1", diff --git a/package.json b/package.json index 5de908854f..e106144e42 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "@angular/platform-browser-dynamic": "~9.1.12", "@angular/router": "~9.1.12", "@ckeditor/ckeditor5-angular": "^1.2.3", - "@dasch-swiss/dsp-js": "file:.yalc/@dasch-swiss/dsp-js", + "@dasch-swiss/dsp-js": "^2.0.0", "@dasch-swiss/dsp-ui": "^1.2.1", "@ngx-translate/core": "^13.0.0", "@ngx-translate/http-loader": "^6.0.0", From f8261078b254a92f9eab611d246fb9e0986b81cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Sat, 6 Feb 2021 10:35:55 +0100 Subject: [PATCH 08/20] refactor(ontology): clean up code --- .../project/ontology/ontology.component.ts | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/app/project/ontology/ontology.component.ts b/src/app/project/ontology/ontology.component.ts index c7fcf45524..405db9b7c2 100644 --- a/src/app/project/ontology/ontology.component.ts +++ b/src/app/project/ontology/ontology.component.ts @@ -10,6 +10,7 @@ import { DeleteOntologyResponse, DeleteResourceClass, KnoraApiConnection, + ListsResponse, OntologiesMetadata, OntologyMetadata, ProjectResponse, @@ -309,8 +310,8 @@ export class OntologyComponent implements OnInit { */ openResourceClassForm(mode: 'createResourceClass' | 'editResourceClass', subClassOf: DefaultClass): void { - // set ontology cache - this._cache.set('currentOntology', this.ontology); + // set cache for ontology and lists + this.setCache(); const dialogConfig: MatDialogConfig = { disableClose: true, @@ -340,8 +341,8 @@ export class OntologyComponent implements OnInit { */ updateCard(subClassOf: ResourceClassDefinition) { - // set ontology cache - this._cache.set('currentOntology', this.ontology); + // set cache for ontology and lists + this.setCache(); const dialogConfig: MatDialogConfig = { disableClose: true, @@ -350,7 +351,7 @@ export class OntologyComponent implements OnInit { position: { top: '112px' }, - data: { mode: 'updateCardinality', id: subClassOf.id, title: subClassOf.label, subtitle: 'Update the metadata fields of resource class', project: this.project.id} + data: { mode: 'updateCardinality', id: subClassOf.id, title: subClassOf.label, subtitle: 'Update the metadata fields of resource class', project: this.project.id } }; const dialogRef = this._dialog.open( @@ -451,4 +452,23 @@ export class OntologyComponent implements OnInit { this.view = view; } + setCache() { + + // get all lists; will be used to set gui attribute in list property + this._dspApiConnection.admin.listsEndpoint.getListsInProject(this.project.id).subscribe( + (response: ApiResponseData) => { + this._cache.set('currentOntologyLists', response.body.lists); + console.log('set currentOntologyLists', response.body.lists); + + }, + (error: ApiResponseError) => { + console.error('currentOntologyLists', error) + this._errorHandler.showMessage(error); + } + ); + + // set cache for current ontology + this._cache.set('currentOntology', this.ontology); + } + } From 0f9d54c4e3b11733a1b701ec79fc9177010cd5f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Sat, 6 Feb 2021 10:37:59 +0100 Subject: [PATCH 09/20] feat(ontology): set and replace cardinality --- .../property-form/property-form.component.ts | 3 - .../resource-class-form.component.ts | 194 +++++------------- 2 files changed, 57 insertions(+), 140 deletions(-) diff --git a/src/app/project/ontology/property-form/property-form.component.ts b/src/app/project/ontology/property-form/property-form.component.ts index 369a0baf6c..d469a7a7a3 100644 --- a/src/app/project/ontology/property-form/property-form.component.ts +++ b/src/app/project/ontology/property-form/property-form.component.ts @@ -158,9 +158,6 @@ export class PropertyFormComponent implements OnInit { this._cache.get('currentOntologyLists').subscribe( (response: ListNodeInfo[]) => { this.lists = response; - }, - (error: ApiResponseError) => { - this._errorHandler.showMessage(error); } ); diff --git a/src/app/project/ontology/resource-class-form/resource-class-form.component.ts b/src/app/project/ontology/resource-class-form/resource-class-form.component.ts index 7d722e62c3..efbf1490e1 100644 --- a/src/app/project/ontology/resource-class-form/resource-class-form.component.ts +++ b/src/app/project/ontology/resource-class-form/resource-class-form.component.ts @@ -2,7 +2,6 @@ import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop'; import { AfterViewChecked, ChangeDetectorRef, Component, EventEmitter, Inject, Input, OnDestroy, OnInit, Output } from '@angular/core'; import { FormArray, FormGroup } from '@angular/forms'; import { - ApiResponseData, ApiResponseError, ClassDefinition, Constants, @@ -10,10 +9,8 @@ import { CreateResourceProperty, IHasProperty, KnoraApiConnection, - ListsResponse, PropertyDefinition, ReadOntology, - ResourceClassDefinitionWithAllLanguages, ResourcePropertyDefinitionWithAllLanguages, StringLiteral, @@ -84,6 +81,9 @@ export class ResourceClassFormComponent implements OnInit, OnDestroy, AfterViewC // current ontology; will get it from cache by key 'currentOntology' ontology: ReadOntology; + // set a list of properties to set res class cardinality for + propsForCard: Property[] = []; + // success of sending data success = false; @@ -168,10 +168,10 @@ export class ResourceClassFormComponent implements OnInit, OnDestroy, AfterViewC for (const c of classKeys) { this.existingResourceClassNames.push( new RegExp('(?:^|W)' + c.split('#')[1] + '(?:$|W)') - ) + ); } - const propKeys: string[] = Object.keys(response.properties); + // const propKeys: string[] = Object.keys(response.properties); }, (error: ApiResponseError) => { @@ -179,16 +179,6 @@ export class ResourceClassFormComponent implements OnInit, OnDestroy, AfterViewC } ); - // get all lists; will be used to set gui attribute in list property - this._dspApiConnection.admin.listsEndpoint.getListsInProject(this.projectIri).subscribe( - (response: ApiResponseData) => { - this._cache.set('currentOntologyLists', response.body.lists); - }, - (error: ApiResponseError) => { - this._errorHandler.showMessage(error); - } - ); - this.buildForm(); this._cdr.detectChanges(); @@ -212,23 +202,12 @@ export class ResourceClassFormComponent implements OnInit, OnDestroy, AfterViewC this._resourceClassFormService.resetProperties(); if (this.edit) { + // edit mode // get resource class and property definition first // get list of ontology properties const ontoProperties: PropertyDefinition[] = this.ontology.getAllPropertyDefinitions(); - // Object.keys(ontoProperties).forEach(key => { - // if (ontoProperties[key].id === ontoClasses[key]. .iri) { - - // console.warn('you want to edit the card. of', ontoClasses[key]); - // this._resourceClassFormService.setProperties(ontoClasses[key]); - - // this.resourceClassFormSub = this._resourceClassFormService.resourceClassForm$ - // .subscribe(resourceClass => { - // this.resourceClassForm = resourceClass; - // this.properties = this.resourceClassForm.get('properties') as FormArray; - // }); - // } - // }); + // find prop cardinality in resource class const ontoClasses: ClassDefinition[] = this.ontology.getAllClassDefinitions(); Object.keys(ontoClasses).forEach(key => { @@ -245,6 +224,7 @@ export class ResourceClassFormComponent implements OnInit, OnDestroy, AfterViewC }); } else { + // create mode this.resourceClassFormSub = this._resourceClassFormService.resourceClassForm$ .subscribe(resourceClass => { this.resourceClassForm = resourceClass; @@ -274,6 +254,9 @@ export class ResourceClassFormComponent implements OnInit, OnDestroy, AfterViewC } + // + // property form: handle list of properties + /** * add property line */ @@ -327,6 +310,7 @@ export class ResourceClassFormComponent implements OnInit, OnDestroy, AfterViewC /** * Go to next step: from resource-class form forward to properties form + * In create mode only */ nextStep(ev: Event) { @@ -343,6 +327,7 @@ export class ResourceClassFormComponent implements OnInit, OnDestroy, AfterViewC } /** * Go to previous step: from properties form back to resource-class form + * In create mode only */ prevStep(ev: Event) { ev.preventDefault(); @@ -358,20 +343,15 @@ export class ResourceClassFormComponent implements OnInit, OnDestroy, AfterViewC */ submitData() { this.loading = true; - - - - // submit resource class data to knora and create resource class incl. cardinality - // console.log('submit resource class data:', resourceClassData); - // let i: number = 0; if (this.edit) { // edit mode - console.log(this.lastModificationDate); - // post prop data; one by one + // submit properties and set cardinality this.submitProps(this.resourceClassForm.value.properties, this.iri); } else { // create mode + // submit resource class data to knora and create resource class incl. cardinality + // set resource class name / id const uniqueClassName: string = this._resourceClassFormService.setUniqueName(this.ontology.id, this.resourceClassLabels[0].value); @@ -390,11 +370,10 @@ export class ResourceClassFormComponent implements OnInit, OnDestroy, AfterViewC onto.entity = newResClass; this._dspApiConnection.v2.onto.createResourceClass(onto).subscribe( (classResponse: ResourceClassDefinitionWithAllLanguages) => { - // console.log('classResponse', classResponse); // need lmd from classResponse this.lastModificationDate = classResponse.lastModificationDate; - // post prop data; one by one + // submit properties and set cardinality this.submitProps(this.resourceClassForm.value.properties, classResponse.id); }, @@ -404,9 +383,6 @@ export class ResourceClassFormComponent implements OnInit, OnDestroy, AfterViewC ); } - - // show message to close dialog box - // this.closeMessage(); } /** @@ -420,52 +396,46 @@ export class ResourceClassFormComponent implements OnInit, OnDestroy, AfterViewC submitProps(props: Property[], classIri: string) { - if (this.edit) { - this.replaceCardinality(props, classIri); - } else { - let i = 1; - from(props) - .pipe(concatMap( - (prop: Property) => { - // submit prop - // console.log('first pipe operator...waiting...prepare and submit prop', prop); - if (prop.iri) { - // the defined prop exists already in this ontology. We can proceed with cardinality. - this.setCardinality(prop.iri, classIri, prop.multiple, prop.required, i); - } else { - // the defined prop does not exist yet. We have to create it. - this.createProp(prop, classIri, i); - } - return new Promise(resolve => setTimeout(() => resolve(prop), 1200)); - } - )) - .pipe(concatMap( - (prop: Property) => { - i++; - // console.log('second pipe operator; do sth. with prop response', prop); - return of(prop); + let i = 1; + from(props) + .pipe(concatMap( + (prop: Property) => { + // submit prop + // console.log('first pipe operator...waiting...prepare and submit prop', prop); + if (prop.iri) { + // already existing property; add it to the new list of properties + + this.propsForCard.push(prop); + } else { + // the defined prop does not exist yet. We have to create it. + this.createProp(prop, classIri); } - )) - .subscribe( - (prop: Property) => { - // this.getOntology(this.ontologyId); - - if (i > props.length) { - // console.log('at the end: created', prop) - // TODO: reset ontology cache - - // close the dialog box - this.loading = false; - this.closeDialog.emit(); - } - } - ); - } + return new Promise(resolve => setTimeout(() => resolve(prop), 1200)); + } + )) + .pipe(concatMap( + (prop: Property) => { + i++; + // console.log('second pipe operator; do sth. with prop response', prop); + return of(prop); + } + )) + .subscribe( + (prop: Property) => { + if (i > props.length) { + // console.log('at the end: created', prop) + + // all properties are created and exist + // set the cardinality + this.setCardinality(this.propsForCard, classIri); + } + } + ); } - createProp(prop: Property, classIri: string, index: number) { + createProp(prop: Property, classIri?: string) { return new Promise((resolve, reject) => { // set resource property name / id @@ -474,6 +444,7 @@ export class ResourceClassFormComponent implements OnInit, OnDestroy, AfterViewC const onto = new UpdateOntology(); onto.id = this.ontology.id; + onto.lastModificationDate = this.lastModificationDate; // prepare payload for property const newResProp = new CreateResourceProperty(); @@ -517,15 +488,15 @@ export class ResourceClassFormComponent implements OnInit, OnDestroy, AfterViewC newResProp.objectType = prop.type.objectType; } - onto.lastModificationDate = this.lastModificationDate; onto.entity = newResProp; this._dspApiConnection.v2.onto.createResourceProperty(onto).subscribe( (response: ResourcePropertyDefinitionWithAllLanguages) => { this.lastModificationDate = response.lastModificationDate; - // update cardinality - this.setCardinality(response.id, classIri, prop.multiple, prop.required, index); + // prepare prop for cardinality + prop.iri = response.id; + this.propsForCard.push(prop); }, (error: ApiResponseError) => { this._errorHandler.showMessage(error); @@ -534,61 +505,11 @@ export class ResourceClassFormComponent implements OnInit, OnDestroy, AfterViewC }) } - setCardinality(propIri: string, classIri: string, multiple: boolean, required: boolean, index: number) { - - const onto = new UpdateOntology(); - - onto.lastModificationDate = this.lastModificationDate; - - onto.id = this.ontology.id; - - const addCard = new UpdateResourceClassCardinality(); - - addCard.id = classIri; - - const cardinality = this._resourceClassFormService.translateCardinality(multiple, required); - - addCard.cardinalities = [ - { - propertyIndex: propIri, - cardinality: cardinality, - guiOrder: index - } - ]; - - onto.entity = addCard; - - if (this.edit) { - - this._dspApiConnection.v2.onto.replaceCardinalityOfResourceClass(onto).subscribe( - (res: ResourceClassDefinitionWithAllLanguages) => { - this.lastModificationDate = res.lastModificationDate; - }, - (error: ApiResponseError) => { - this._errorHandler.showMessage(error); - } - ) - - } else { - this._dspApiConnection.v2.onto.addCardinalityToResourceClass(onto).subscribe( - (res: ResourceClassDefinitionWithAllLanguages) => { - this.lastModificationDate = res.lastModificationDate; - }, - (error: ApiResponseError) => { - this._errorHandler.showMessage(error); - } - ); - } - - } - - replaceCardinality(props: Property[], classIri: string) { + setCardinality(props: Property[], classIri: string) { const onto = new UpdateOntology(); onto.lastModificationDate = this.lastModificationDate; - console.log(this.lastModificationDate); - onto.id = this.ontology.id; const addCard = new UpdateResourceClassCardinality(); @@ -611,7 +532,6 @@ export class ResourceClassFormComponent implements OnInit, OnDestroy, AfterViewC this._dspApiConnection.v2.onto.replaceCardinalityOfResourceClass(onto).subscribe( (res: ResourceClassDefinitionWithAllLanguages) => { - console.log('result', res); this.lastModificationDate = res.lastModificationDate; // close the dialog box this.loading = false; From 4d9e4219e6f1c6adee2270425f1c313dd196e184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Sat, 6 Feb 2021 12:16:26 +0100 Subject: [PATCH 10/20] style(ontology): change position of add prop button --- .../ontology/property-form/property-form.component.scss | 4 +++- .../resource-class-form.component.html | 9 ++++----- .../resource-class-form.component.scss | 5 ++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/app/project/ontology/property-form/property-form.component.scss b/src/app/project/ontology/property-form/property-form.component.scss index e3dc33b29f..ee7c59b8e9 100644 --- a/src/app/project/ontology/property-form/property-form.component.scss +++ b/src/app/project/ontology/property-form/property-form.component.scss @@ -28,7 +28,9 @@ } .reset-button { - margin: 0 0 0 auto; + position: absolute; + right: 0; + bottom: 12px; } .hidden { diff --git a/src/app/project/ontology/resource-class-form/resource-class-form.component.html b/src/app/project/ontology/resource-class-form/resource-class-form.component.html index 8a3f54cc41..88dd733b05 100644 --- a/src/app/project/ontology/resource-class-form/resource-class-form.component.html +++ b/src/app/project/ontology/resource-class-form/resource-class-form.component.html @@ -66,12 +66,11 @@ aria-label="Delete this property" class="suffix delete-line" (click)="removeProperty(i)"> delete_outlined -
- +
diff --git a/src/app/project/ontology/resource-class-form/resource-class-form.component.scss b/src/app/project/ontology/resource-class-form/resource-class-form.component.scss index 7066d442ab..248d734804 100644 --- a/src/app/project/ontology/resource-class-form/resource-class-form.component.scss +++ b/src/app/project/ontology/resource-class-form/resource-class-form.component.scss @@ -76,14 +76,13 @@ button { } } - &.delete-line, - &.add-new-line { + &.delete-line { position: absolute; right: 12px; } &.add-new-line { - bottom: 12px; + top: 12px; } &.delete-line { From 9b87c008579fde247eb119d652791e1245e3d093 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Sat, 6 Feb 2021 12:22:31 +0100 Subject: [PATCH 11/20] feat(ontology): create prop and class name from randomized string --- .../resource-class-form.component.ts | 10 +++++----- .../resource-class-form/resource-class-form.service.ts | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/app/project/ontology/resource-class-form/resource-class-form.component.ts b/src/app/project/ontology/resource-class-form/resource-class-form.component.ts index efbf1490e1..554e2cd0a8 100644 --- a/src/app/project/ontology/resource-class-form/resource-class-form.component.ts +++ b/src/app/project/ontology/resource-class-form/resource-class-form.component.ts @@ -352,8 +352,9 @@ export class ResourceClassFormComponent implements OnInit, OnDestroy, AfterViewC // create mode // submit resource class data to knora and create resource class incl. cardinality - // set resource class name / id - const uniqueClassName: string = this._resourceClassFormService.setUniqueName(this.ontology.id, this.resourceClassLabels[0].value); + // set resource class name / id: randomized string + const uniqueClassName: string = this._resourceClassFormService.setUniqueName(this.ontology.id); + // OR const uniqueClassName: string = this._resourceClassFormService.setUniqueName(this.ontology.id, this.resourceClassLabels[0].value, 'class'); const onto = new UpdateOntology(); @@ -438,8 +439,8 @@ export class ResourceClassFormComponent implements OnInit, OnDestroy, AfterViewC createProp(prop: Property, classIri?: string) { return new Promise((resolve, reject) => { - // set resource property name / id - const uniquePropName: string = this._resourceClassFormService.setUniqueName(this.ontology.id, prop.label); + // set resource property name / id: randomized string + const uniquePropName: string = this._resourceClassFormService.setUniqueName(this.ontology.id); const onto = new UpdateOntology(); @@ -488,7 +489,6 @@ export class ResourceClassFormComponent implements OnInit, OnDestroy, AfterViewC newResProp.objectType = prop.type.objectType; } - onto.entity = newResProp; this._dspApiConnection.v2.onto.createResourceProperty(onto).subscribe( diff --git a/src/app/project/ontology/resource-class-form/resource-class-form.service.ts b/src/app/project/ontology/resource-class-form/resource-class-form.service.ts index 7333432e68..516c742261 100644 --- a/src/app/project/ontology/resource-class-form/resource-class-form.service.ts +++ b/src/app/project/ontology/resource-class-form/resource-class-form.service.ts @@ -214,12 +214,12 @@ export class ResourceClassFormService { * @param [label] * @returns unique name */ - setUniqueName(ontologyIri: string, label?: string): string { + setUniqueName(ontologyIri: string, label?: string, type?: 'class' | 'prop'): string { - if (label) { + if (label && type) { // build name from label // normalize and replace spaces and special chars - return label.normalize('NFD').replace(/[\u0300-\u036f]/g, '').replace(/[\u00a0-\u024f]/g, '').replace(/[\])}[{(]/g, '').replace(/\s+/g, '-').replace(/\//g, '-').toLowerCase(); + return type + '-' + label.normalize('NFD').replace(/[\u0300-\u036f]/g, '').replace(/[\u00a0-\u024f]/g, '').replace(/[\])}[{(]/g, '').replace(/\s+/g, '-').replace(/\//g, '-').toLowerCase(); } else { // build randomized name // The name starts with the three first character of ontology iri to avoid a start with a number followed by randomized string From 3e6ebefdca7d403fcf1bfb91113f380be887cc41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Sat, 6 Feb 2021 13:01:07 +0100 Subject: [PATCH 12/20] refactor(ontology): fix typo --- src/app/project/ontology/ontology.component.ts | 2 +- .../ontology/property-form/property-form.component.html | 4 ++-- .../ontology/property-form/property-form.component.ts | 6 +++--- .../resource-class-form/resource-class-form.component.html | 4 ++-- .../resource-class-form/resource-class-form.component.ts | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/app/project/ontology/ontology.component.ts b/src/app/project/ontology/ontology.component.ts index 405db9b7c2..c1f7df796d 100644 --- a/src/app/project/ontology/ontology.component.ts +++ b/src/app/project/ontology/ontology.component.ts @@ -419,7 +419,7 @@ export class OntologyComponent implements OnInit { break; case 'ResourceClass': - // delete reresource class and refresh the view + // delete resource class and refresh the view this.loadOntology = true; const resClass: DeleteResourceClass = new DeleteResourceClass(); resClass.id = id; diff --git a/src/app/project/ontology/property-form/property-form.component.html b/src/app/project/ontology/property-form/property-form.component.html index 37fe0daf1a..855f28ce12 100644 --- a/src/app/project/ontology/property-form/property-form.component.html +++ b/src/app/project/ontology/property-form/property-form.component.html @@ -65,9 +65,9 @@
- Select reresource class + Select resource class - + {{item.label}} diff --git a/src/app/project/ontology/property-form/property-form.component.ts b/src/app/project/ontology/property-form/property-form.component.ts index d469a7a7a3..ea0565fe7b 100644 --- a/src/app/project/ontology/property-form/property-form.component.ts +++ b/src/app/project/ontology/property-form/property-form.component.ts @@ -67,7 +67,7 @@ export class PropertyFormComponent implements OnInit { // current ontology // ontology: ReadOntology; - // reresource classs in this ontology + // resource classs in this ontology reresourceClasss: ClassDefinition[] = []; // list of existing properties @@ -126,7 +126,7 @@ export class PropertyFormComponent implements OnInit { // set various lists to select from // a) in case of link value: - // set list of reresource classes from response; needed for linkValue + // set list of resource classes from response; needed for linkValue const classKeys: string[] = Object.keys(response.classes); for (const c of classKeys) { this.reresourceClasss.push(this.ontology.classes[c]); @@ -186,7 +186,7 @@ export class PropertyFormComponent implements OnInit { this.propertyForm.controls['guiAttr'].setValue(undefined); // depending on the selected property type, // we have to define gui element attributes - // e.g. iri of list or connected reresource class + // e.g. iri of list or connected resource class switch (event.value.objectType) { case Constants.ListValue: case Constants.Resource: diff --git a/src/app/project/ontology/resource-class-form/resource-class-form.component.html b/src/app/project/ontology/resource-class-form/resource-class-form.component.html index 88dd733b05..552400ab19 100644 --- a/src/app/project/ontology/resource-class-form/resource-class-form.component.html +++ b/src/app/project/ontology/resource-class-form/resource-class-form.component.html @@ -3,7 +3,7 @@ - +
@@ -45,7 +45,7 @@
- +
diff --git a/src/app/project/ontology/resource-class-form/resource-class-form.component.ts b/src/app/project/ontology/resource-class-form/resource-class-form.component.ts index 554e2cd0a8..8f8bf96d0f 100644 --- a/src/app/project/ontology/resource-class-form/resource-class-form.component.ts +++ b/src/app/project/ontology/resource-class-form/resource-class-form.component.ts @@ -112,7 +112,7 @@ export class ResourceClassFormComponent implements OnInit, OnDestroy, AfterViewC // container for properties properties: FormArray; - // reresource class name should be unique + // resource class name should be unique existingResourceClassNames: [RegExp]; existingPropertyNames: [RegExp]; @@ -152,7 +152,7 @@ export class ResourceClassFormComponent implements OnInit, OnDestroy, AfterViewC new RegExp('anEmptyRegularExpressionWasntPossible') ]; - // set file representation or default reresource class as title + // set file representation or default resource class as title this.resourceClassTitle = this.name; this._cache.get('currentOntology').subscribe( From 1fff529766872b9fd98a226bd3fb35cc96159d93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Sat, 6 Feb 2021 13:04:59 +0100 Subject: [PATCH 13/20] feat(ontology): disable own res class in res pointer --- .../project/ontology/property-form/property-form.component.html | 2 +- .../project/ontology/property-form/property-form.component.ts | 2 ++ .../resource-class-form/resource-class-form.component.html | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/app/project/ontology/property-form/property-form.component.html b/src/app/project/ontology/property-form/property-form.component.html index 855f28ce12..6eb9c85046 100644 --- a/src/app/project/ontology/property-form/property-form.component.html +++ b/src/app/project/ontology/property-form/property-form.component.html @@ -67,7 +67,7 @@ Select resource class - + {{item.label}} diff --git a/src/app/project/ontology/property-form/property-form.component.ts b/src/app/project/ontology/property-form/property-form.component.ts index ea0565fe7b..6a56431aff 100644 --- a/src/app/project/ontology/property-form/property-form.component.ts +++ b/src/app/project/ontology/property-form/property-form.component.ts @@ -48,6 +48,8 @@ export class PropertyFormComponent implements OnInit { @Input() ontology?: ReadOntology; + @Input() resClassIri?: string; + @Output() deleteProperty: EventEmitter = new EventEmitter(); iri = new FormControl(); diff --git a/src/app/project/ontology/resource-class-form/resource-class-form.component.html b/src/app/project/ontology/resource-class-form/resource-class-form.component.html index 552400ab19..fe606f3d94 100644 --- a/src/app/project/ontology/resource-class-form/resource-class-form.component.html +++ b/src/app/project/ontology/resource-class-form/resource-class-form.component.html @@ -60,7 +60,7 @@ drag_indicator - + + (click)="delete(resClass.id, 'ResourceClass', resClass.label)">Delete resource class diff --git a/src/app/project/ontology/ontology.component.ts b/src/app/project/ontology/ontology.component.ts index c1f7df796d..e115925f01 100644 --- a/src/app/project/ontology/ontology.component.ts +++ b/src/app/project/ontology/ontology.component.ts @@ -458,11 +458,11 @@ export class OntologyComponent implements OnInit { this._dspApiConnection.admin.listsEndpoint.getListsInProject(this.project.id).subscribe( (response: ApiResponseData) => { this._cache.set('currentOntologyLists', response.body.lists); - console.log('set currentOntologyLists', response.body.lists); + // console.log('set currentOntologyLists', response.body.lists); }, (error: ApiResponseError) => { - console.error('currentOntologyLists', error) + // console.error('currentOntologyLists', error) this._errorHandler.showMessage(error); } ); diff --git a/src/app/project/ontology/property-form/property-form.component.html b/src/app/project/ontology/property-form/property-form.component.html index 6eb9c85046..bc98e1a7f9 100644 --- a/src/app/project/ontology/property-form/property-form.component.html +++ b/src/app/project/ontology/property-form/property-form.component.html @@ -18,7 +18,7 @@ + matTooltip="Label: {{ prop?.label }} (Name is part of the id: {{prop?.name}})" matTooltipPosition="after"> {{ prop?.label }} @@ -63,7 +63,7 @@
-
+
Select resource class diff --git a/src/app/project/ontology/property-form/property-form.component.ts b/src/app/project/ontology/property-form/property-form.component.ts index 6a56431aff..097d7f2d8e 100644 --- a/src/app/project/ontology/property-form/property-form.component.ts +++ b/src/app/project/ontology/property-form/property-form.component.ts @@ -66,9 +66,6 @@ export class PropertyFormComponent implements OnInit { // list of project specific lists (TODO: probably we have to add default knora lists?!) lists: ListNodeInfo[]; - // current ontology - // ontology: ReadOntology; - // resource classs in this ontology reresourceClasss: ClassDefinition[] = []; @@ -82,6 +79,8 @@ export class PropertyFormComponent implements OnInit { existingProperty: boolean; + loading = false; + Constants = Constants; constructor( @@ -118,6 +117,7 @@ export class PropertyFormComponent implements OnInit { } // edit mode: this prop value exists already + this.loading = true; this.updateFieldsDependingOnLabel(existingProp); } } @@ -138,7 +138,8 @@ export class PropertyFormComponent implements OnInit { // set list of properties from response; needed for autocomplete in label to reuse existing property const propKeys: string[] = Object.keys(response.properties); for (const p of propKeys) { - if (this.ontology.properties[p].objectType !== 'http://api.knora.org/ontology/knora-api/v2#LinkValue') { + const prop = this.ontology.properties[p]; + if (prop.objectType !== Constants.LinkValue && prop.objectType !== this.resClassIri) { const existingProperty: AutocompleteItem = { iri: this.ontology.properties[p].id, name: this.ontology.properties[p].id.split('#')[1], @@ -191,7 +192,7 @@ export class PropertyFormComponent implements OnInit { // e.g. iri of list or connected resource class switch (event.value.objectType) { case Constants.ListValue: - case Constants.Resource: + case Constants.LinkValue: this.showGuiAttr = true; this.propertyForm.controls['guiAttr'].setValidators([ Validators.required @@ -213,16 +214,19 @@ export class PropertyFormComponent implements OnInit { updateFieldsDependingOnLabel(option: AutocompleteItem) { this.propertyForm.controls['iri'].setValue(option.iri); + // set label and disable the input this.propertyForm.controls['label'].setValue(option.label); this.propertyForm.controls['label'].disable(); + // find corresponding property type + if (this.ontology.properties[option.iri] instanceof ResourcePropertyDefinition) { const tempProp: any | ResourcePropertyDefinition = this.ontology.properties[option.iri]; let obj: PropertyType; // find gui ele from list of default property-types to set type value for (let group of this.propertyTypes) { - obj = group.elements.find(i => i.gui_ele === tempProp.guiElement && i.objectType === tempProp.objectType); + obj = group.elements.find(i => i.gui_ele === tempProp.guiElement && (i.objectType === tempProp.objectType || i.subPropOf === tempProp.subPropertyOf[0])); if (obj) { this.propertyForm.controls['type'].setValue(obj); @@ -246,6 +250,7 @@ export class PropertyFormComponent implements OnInit { this.propertyForm.controls['guiAttr'].setValue(listIri); this.propertyForm.controls['guiAttr'].disable(); break; + // prop type is resource pointer case Constants.SalsahGui + Constants.HashDelimiter + 'Searchbox': diff --git a/src/app/project/ontology/resource-class-form/resource-class-form.component.html b/src/app/project/ontology/resource-class-form/resource-class-form.component.html index fe606f3d94..4d7a0f4229 100644 --- a/src/app/project/ontology/resource-class-form/resource-class-form.component.html +++ b/src/app/project/ontology/resource-class-form/resource-class-form.component.html @@ -12,8 +12,7 @@
+ (enter)="nextStep($event)" (dataChanged)="handleData($event, 'labels')"> {{ formErrors.label }} @@ -53,6 +52,8 @@
+ +
- + + +
+
diff --git a/src/app/project/ontology/resource-class-form/resource-class-form.component.ts b/src/app/project/ontology/resource-class-form/resource-class-form.component.ts index 8f8bf96d0f..e87ae3241c 100644 --- a/src/app/project/ontology/resource-class-form/resource-class-form.component.ts +++ b/src/app/project/ontology/resource-class-form/resource-class-form.component.ts @@ -484,7 +484,7 @@ export class ResourceClassFormComponent implements OnInit, OnDestroy, AfterViewC if (prop.type.subPropOf === Constants.HasLinkTo) { newResProp.objectType = prop.guiAttr; - newResProp.subjectType = classIri; + // newResProp.subjectType = classIri; } else { newResProp.objectType = prop.type.objectType; } diff --git a/src/app/project/ontology/resource-class-form/resource-class-form.service.ts b/src/app/project/ontology/resource-class-form/resource-class-form.service.ts index 516c742261..00ea478986 100644 --- a/src/app/project/ontology/resource-class-form/resource-class-form.service.ts +++ b/src/app/project/ontology/resource-class-form/resource-class-form.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; import { FormArray, FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; -import { Cardinality, IHasProperty, PropertyDefinition, ResourceClassDefinition, ResourcePropertyDefinition } from '@dasch-swiss/dsp-js'; +import { Cardinality, Constants, IHasProperty, PropertyDefinition, ResourceClassDefinition, ResourcePropertyDefinition } from '@dasch-swiss/dsp-js'; import { BehaviorSubject, Observable } from 'rxjs'; import { DefaultProperties, PropertyType } from '../default-data/default-properties'; @@ -133,45 +133,53 @@ export class ResourceClassFormService { // get cardinality and gui order and grab property definition resClass.propertiesList.forEach((prop: IHasProperty) => { if (prop.guiOrder >= 0) { - const property: Property = new Property(); - property.iri = prop.propertyIndex; - - // convert cardinality - switch(prop.cardinality) { - case 0: - property.multiple = false; - property.required = true; - break; - case 1: - property.multiple = false; - property.required = false; - break; - case 2: - property.multiple = true; - property.required = false; - break; - case 3: - property.multiple = true; - property.required = true; - break; - } // get property definition Object.keys(ontoProperties).forEach(key => { - if (ontoProperties[key].id === property.iri) { + if (ontoProperties[key].id === prop.propertyIndex && !ontoProperties[key].isLinkValueProperty) { const propDef: ResourcePropertyDefinition = ontoProperties[key]; + + const property: Property = new Property(); + // property.propDef = ontoProperties[key]; + property.label = propDef.label; + if(ontoProperties[key].isLinkProperty) { + property.guiAttr = propDef.objectType; + } else { + property.guiAttr = propDef.guiAttributes[0]; + } + property.iri = prop.propertyIndex; + + // convert cardinality + switch (prop.cardinality) { + case 0: + property.multiple = false; + property.required = true; + break; + case 1: + property.multiple = false; + property.required = false; + break; + case 2: + property.multiple = true; + property.required = false; + break; + case 3: + property.multiple = true; + property.required = true; + break; + } + // find property type in list of default properties // just a test // property.type = DefaultProperties.data[0].elements[0]; - property.guiAttr = propDef.guiAttributes[0]; + this.addProperty(property); + } }); - this.addProperty(property); - } }); From fd091d8e1e07311fff764d9ad61a7d739802ee3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Tue, 9 Feb 2021 23:56:22 +0100 Subject: [PATCH 15/20] feat(ontology): disable edit menu in case of missing lmd --- .../project/ontology/ontology.component.html | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/app/project/ontology/ontology.component.html b/src/app/project/ontology/ontology.component.html index 7d989dca50..b6a26cfb2d 100644 --- a/src/app/project/ontology/ontology.component.html +++ b/src/app/project/ontology/ontology.component.html @@ -106,10 +106,9 @@

{{ontology?.label}}

-

This ontology can't be edited - because - of - missing "lastModificationDate"!

+

+ This ontology can't be edited because of missing "lastModificationDate"! +

@@ -137,18 +136,24 @@

{{ontology?.label}}

{{resClass.label | dspTruncate: 24}}

- - - + - + From 9ed63f2e4508c6bd59e22776bc16140619ae8951 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Wed, 10 Feb 2021 10:39:48 +0100 Subject: [PATCH 16/20] fix(ontology): fix cache issue --- src/app/project/ontology/ontology.component.ts | 3 +++ .../ontology/property-form/property-form.component.ts | 6 ++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/app/project/ontology/ontology.component.ts b/src/app/project/ontology/ontology.component.ts index e115925f01..157feb0a6b 100644 --- a/src/app/project/ontology/ontology.component.ts +++ b/src/app/project/ontology/ontology.component.ts @@ -150,6 +150,9 @@ export class OntologyComponent implements OnInit { // get the ontologies for this project this.initList(); + // cache other things like ontology and lists + this.setCache(); + this.ontologyForm = this._fb.group({ ontology: new FormControl({ value: this.ontologyIri, disabled: false diff --git a/src/app/project/ontology/property-form/property-form.component.ts b/src/app/project/ontology/property-form/property-form.component.ts index 097d7f2d8e..4ad4621d4f 100644 --- a/src/app/project/ontology/property-form/property-form.component.ts +++ b/src/app/project/ontology/property-form/property-form.component.ts @@ -178,8 +178,9 @@ export class PropertyFormComponent implements OnInit { * @returns Filtered list of options */ filter(list: AutocompleteItem[], label: string) { + console.log(list) return list.filter(prop => - prop.label.toLowerCase().includes(label.toLowerCase()) + prop.label?.toLowerCase().includes(label.toLowerCase()) ); } @@ -261,13 +262,10 @@ export class PropertyFormComponent implements OnInit { default: this.showGuiAttr = false; - } - } this.propertyForm.controls['type'].disable(); this.existingProperty = true; - } resetProperty(ev: Event) { From d74a77dd13906f7df4fea070986cbb53a8ac5b62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Fri, 12 Feb 2021 09:51:35 +0100 Subject: [PATCH 17/20] refactor(ontology): delete console.log --- .../project/ontology/property-form/property-form.component.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app/project/ontology/property-form/property-form.component.ts b/src/app/project/ontology/property-form/property-form.component.ts index 4ad4621d4f..558fe41e6a 100644 --- a/src/app/project/ontology/property-form/property-form.component.ts +++ b/src/app/project/ontology/property-form/property-form.component.ts @@ -178,7 +178,6 @@ export class PropertyFormComponent implements OnInit { * @returns Filtered list of options */ filter(list: AutocompleteItem[], label: string) { - console.log(list) return list.filter(prop => prop.label?.toLowerCase().includes(label.toLowerCase()) ); From 4df6c4812b3474f4b5874990ffbd2dc53c2ed35f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Fri, 12 Feb 2021 09:53:00 +0100 Subject: [PATCH 18/20] chore(ontology): replace ontology with data model --- src/app/project/ontology/ontology.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/project/ontology/ontology.component.html b/src/app/project/ontology/ontology.component.html index b6a26cfb2d..1a5ae96168 100644 --- a/src/app/project/ontology/ontology.component.html +++ b/src/app/project/ontology/ontology.component.html @@ -1,6 +1,6 @@
-

This is a first version of the ontology editor. Some features may not work as +

This is a first version of the data model editor. Some features may not work as intended.

From de4ac1f497602b81a6443ab6d4ca00796a664327 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Fri, 12 Feb 2021 09:58:21 +0100 Subject: [PATCH 19/20] refactor(ontology): delete commented code --- .../ontology/resource-class-form/resource-class-form.service.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/app/project/ontology/resource-class-form/resource-class-form.service.ts b/src/app/project/ontology/resource-class-form/resource-class-form.service.ts index 00ea478986..645c0e10c3 100644 --- a/src/app/project/ontology/resource-class-form/resource-class-form.service.ts +++ b/src/app/project/ontology/resource-class-form/resource-class-form.service.ts @@ -87,10 +87,8 @@ export class ResourceClassForm { this.properties.setControl resourceClass.properties.forEach(prop => { this.properties[i] = new FormControl(prop); - // this.properties[i].setValue(prop); i++; }); - // this.properties.setValue([resourceClass.properties]); } } } From ff9949a0255631c01170cffbc25f4c4e2325ebe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Fri, 12 Feb 2021 14:12:34 +0100 Subject: [PATCH 20/20] chore(deps): bump dsp-js from 1.3.0 to 2.0.1 and dsp-ui 1.2.1 to 1.2.2 --- package-lock.json | 45 +++++++++++++++++++++++++++++++-------------- package.json | 4 ++-- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1759b05797..8bc168b504 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,8 +18,8 @@ "@angular/platform-browser-dynamic": "~9.1.12", "@angular/router": "~9.1.12", "@ckeditor/ckeditor5-angular": "^1.2.3", - "@dasch-swiss/dsp-js": "^1.3.0", - "@dasch-swiss/dsp-ui": "^1.2.1", + "@dasch-swiss/dsp-js": "^2.0.1", + "@dasch-swiss/dsp-ui": "^1.2.2", "@ngx-translate/core": "^13.0.0", "@ngx-translate/http-loader": "^6.0.0", "3d-force-graph": "^1.60.12", @@ -1894,21 +1894,38 @@ } }, "node_modules/@dasch-swiss/dsp-js": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@dasch-swiss/dsp-js/-/dsp-js-1.3.0.tgz", - "integrity": "sha512-wF3ib5sc3DWhJkAu8NOdgNHc40P38NtCtrxt3HR0cletc+HXrdhvVbM2hzfkuIyDPnnnY6a7QEguBrhkVlwZ9A==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@dasch-swiss/dsp-js/-/dsp-js-2.0.1.tgz", + "integrity": "sha512-6S/N2GBPxwixGGI0lflgqXcSCt4H0Io3QWeLFKbSKTYaMOSl2Xmo479KLDl9xw9bv6HIe3ZrNHv2b8CT2PXsxA==", "dependencies": { "@types/jsonld": "^1.5.0", "json2typescript": "1.4.1", "jsonld": "^1.8.0" + }, + "peerDependencies": { + "rxjs": "6.x" } }, "node_modules/@dasch-swiss/dsp-ui": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@dasch-swiss/dsp-ui/-/dsp-ui-1.2.1.tgz", - "integrity": "sha512-t5/UBLGwYVes2SN2nndCB9wZb/8OWAEZG4idY1qbCumgL057BG0QaaZ6i1AjgLMwbsMoptYVhI9ODbHWxltlrA==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@dasch-swiss/dsp-ui/-/dsp-ui-1.2.2.tgz", + "integrity": "sha512-qJUHZiaFOhGazTSA4gS6Y40ulW0/s/4z8XLKuIg3/IFwdTAvPCFGFIZ471hd2yzD+jsia4V5t2SRB5os7/4npw==", "dependencies": { "tslib": "^1.10.0" + }, + "peerDependencies": { + "@angular/cdk": "^9.0.0", + "@angular/common": "^9.0.0", + "@angular/core": "^9.0.0", + "@angular/material": "^9.0.0", + "@ckeditor/ckeditor5-angular": "^1.2.3", + "@dasch-swiss/dsp-js": "^2.0.1", + "ckeditor5-custom-build": "github:dasch-swiss/ckeditor_custom_build", + "jdnconvertiblecalendar": "^0.0.5", + "jdnconvertiblecalendardateadapter": "^0.0.13", + "ngx-color-picker": "^10.0.1", + "openseadragon": "^2.4.2", + "svg-overlay": "github:openseadragon/svg-overlay" } }, "node_modules/@istanbuljs/schema": { @@ -19259,9 +19276,9 @@ } }, "@dasch-swiss/dsp-js": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@dasch-swiss/dsp-js/-/dsp-js-2.0.0.tgz", - "integrity": "sha512-nPYUa1Pl2lpBbNvaOu2YTmVJATksNUOmDKiag8wJI/uux7KVfLjsX08wirMN/fsPr4PnR/Gg/4uTUAMMzMIe0g==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@dasch-swiss/dsp-js/-/dsp-js-2.0.1.tgz", + "integrity": "sha512-6S/N2GBPxwixGGI0lflgqXcSCt4H0Io3QWeLFKbSKTYaMOSl2Xmo479KLDl9xw9bv6HIe3ZrNHv2b8CT2PXsxA==", "requires": { "@types/jsonld": "^1.5.0", "json2typescript": "1.4.1", @@ -19269,9 +19286,9 @@ } }, "@dasch-swiss/dsp-ui": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@dasch-swiss/dsp-ui/-/dsp-ui-1.2.1.tgz", - "integrity": "sha512-t5/UBLGwYVes2SN2nndCB9wZb/8OWAEZG4idY1qbCumgL057BG0QaaZ6i1AjgLMwbsMoptYVhI9ODbHWxltlrA==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@dasch-swiss/dsp-ui/-/dsp-ui-1.2.2.tgz", + "integrity": "sha512-qJUHZiaFOhGazTSA4gS6Y40ulW0/s/4z8XLKuIg3/IFwdTAvPCFGFIZ471hd2yzD+jsia4V5t2SRB5os7/4npw==", "requires": { "tslib": "^1.10.0" } diff --git a/package.json b/package.json index 04ded0542b..5b98f13e3b 100644 --- a/package.json +++ b/package.json @@ -31,8 +31,8 @@ "@angular/platform-browser-dynamic": "~9.1.12", "@angular/router": "~9.1.12", "@ckeditor/ckeditor5-angular": "^1.2.3", - "@dasch-swiss/dsp-js": "^2.0.0", - "@dasch-swiss/dsp-ui": "^1.2.1", + "@dasch-swiss/dsp-js": "^2.0.1", + "@dasch-swiss/dsp-ui": "^1.2.2", "@ngx-translate/core": "^13.0.0", "@ngx-translate/http-loader": "^6.0.0", "3d-force-graph": "^1.60.12",