From f6deead94c9ccf7eaa337fd9cf40610cb62e3204 Mon Sep 17 00:00:00 2001 From: DaSCH Bot <50987250+daschbot@users.noreply.github.com> Date: Fri, 23 Feb 2024 17:00:11 +0100 Subject: [PATCH 1/5] chore(main): release 11.6.4 (#1482) --- CHANGELOG.md | 8 ++++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22de9a9fde..10395c81e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## [11.6.4](https://github.com/dasch-swiss/dsp-das/compare/v11.6.3...v11.6.4) (2024-02-23) + + +### Bug Fixes + +* new list node field error is not displayed ([#1481](https://github.com/dasch-swiss/dsp-das/issues/1481)) ([1ef0823](https://github.com/dasch-swiss/dsp-das/commit/1ef082364c13ead5a537bc32a734372744f1cbda)) +* ontology initialisation (DEV-3317) ([#1483](https://github.com/dasch-swiss/dsp-das/issues/1483)) ([be6ec9a](https://github.com/dasch-swiss/dsp-das/commit/be6ec9a5f4b16f4992b79ee69754da74f8b71178)) + ## [11.6.3](https://github.com/dasch-swiss/dsp-das/compare/v11.6.2...v11.6.3) (2024-02-23) diff --git a/package-lock.json b/package-lock.json index cba001a4ce..d76e118b01 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "dsp-app", - "version": "11.6.3", + "version": "11.6.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "dsp-app", - "version": "11.6.3", + "version": "11.6.4", "dependencies": { "@angular/animations": "^16.2.12", "@angular/cdk": "^16.2.12", diff --git a/package.json b/package.json index ff2cdfaf80..e9581fac6d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dsp-app", - "version": "11.6.3", + "version": "11.6.4", "repository": { "type": "git", "url": "https://github.com/dasch-swiss/dsp-app.git" From e1a51b5a224bf532f3a3f0ff8e6b4a49c9b42bd2 Mon Sep 17 00:00:00 2001 From: Julien Schneider Date: Tue, 27 Feb 2024 16:29:34 +0100 Subject: [PATCH 2/5] fix: submit button on upload resource does not load indefinitely (#1485) --- .../resource-instance-form.component.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/apps/dsp-app/src/app/workspace/resource/resource-instance-form/resource-instance-form.component.ts b/apps/dsp-app/src/app/workspace/resource/resource-instance-form/resource-instance-form.component.ts index 2a9085f1d2..f39d285058 100644 --- a/apps/dsp-app/src/app/workspace/resource/resource-instance-form/resource-instance-form.component.ts +++ b/apps/dsp-app/src/app/workspace/resource/resource-instance-form/resource-instance-form.component.ts @@ -24,11 +24,11 @@ import { } from '@dasch-swiss/dsp-js'; import { DspApiConnectionToken } from '@dasch-swiss/vre/shared/app-config'; import { - Events as CommsEvents, ComponentCommunicationEventService, DefaultClass, DefaultResourceClasses, EmitEvent, + Events as CommsEvents, } from '@dasch-swiss/vre/shared/app-helper-services'; import { NotificationService } from '@dasch-swiss/vre/shared/app-notification'; import { LoadClassItemsCountAction } from '@dasch-swiss/vre/shared/app-state'; @@ -191,9 +191,8 @@ export class ResourceInstanceFormComponent implements OnInit, OnChanges { } submitData() { - this.loading = true; - if (this.propertiesParentForm.valid) { + this.loading = true; const createResource = new CreateResource(); const resLabelVal = this.selectPropertiesComponent.createValueComponent.getNewValue(); From ce91ecccb192e29c8e0040fb8971f3205f54605c Mon Sep 17 00:00:00 2001 From: DaSCH Bot <50987250+daschbot@users.noreply.github.com> Date: Tue, 27 Feb 2024 17:20:06 +0100 Subject: [PATCH 3/5] chore(main): release 11.6.5 (#1486) --- CHANGELOG.md | 7 +++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 10395c81e4..c0b123b1fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [11.6.5](https://github.com/dasch-swiss/dsp-das/compare/v11.6.4...v11.6.5) (2024-02-27) + + +### Bug Fixes + +* submit button on upload resource does not load indefinitely ([#1485](https://github.com/dasch-swiss/dsp-das/issues/1485)) ([e1a51b5](https://github.com/dasch-swiss/dsp-das/commit/e1a51b5a224bf532f3a3f0ff8e6b4a49c9b42bd2)) + ## [11.6.4](https://github.com/dasch-swiss/dsp-das/compare/v11.6.3...v11.6.4) (2024-02-23) diff --git a/package-lock.json b/package-lock.json index d76e118b01..f811a29492 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "dsp-app", - "version": "11.6.4", + "version": "11.6.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "dsp-app", - "version": "11.6.4", + "version": "11.6.5", "dependencies": { "@angular/animations": "^16.2.12", "@angular/cdk": "^16.2.12", diff --git a/package.json b/package.json index e9581fac6d..7e72f89649 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dsp-app", - "version": "11.6.4", + "version": "11.6.5", "repository": { "type": "git", "url": "https://github.com/dasch-swiss/dsp-app.git" From 985bcd05fb157a938bd9ad6da95c186fb080f751 Mon Sep 17 00:00:00 2001 From: Irmantas Kaukas Date: Wed, 28 Feb 2024 10:04:06 +0100 Subject: [PATCH 4/5] fix: image region comment field validation removed(DEV-3315) (#1487) --- .../add-region-form/add-region-form.component.ts | 4 ++-- .../still-image/still-image.component.ts | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/apps/dsp-app/src/app/workspace/resource/representation/add-region-form/add-region-form.component.ts b/apps/dsp-app/src/app/workspace/resource/representation/add-region-form/add-region-form.component.ts index 2f29f012a8..51fa1ba0cb 100644 --- a/apps/dsp-app/src/app/workspace/resource/representation/add-region-form/add-region-form.component.ts +++ b/apps/dsp-app/src/app/workspace/resource/representation/add-region-form/add-region-form.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, Input } from '@angular/core'; +import { Component, Input, OnInit } from '@angular/core'; import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms'; @Component({ @@ -15,7 +15,7 @@ export class AddRegionFormComponent implements OnInit { ngOnInit(): void { this.regionForm = this._fb.group({ color: ['#ff3333', [Validators.required, Validators.pattern(this.colorPattern)]], - comment: [null, Validators.required], + comment: [null], label: [null, Validators.required], }); } diff --git a/apps/dsp-app/src/app/workspace/resource/representation/still-image/still-image.component.ts b/apps/dsp-app/src/app/workspace/resource/representation/still-image/still-image.component.ts index 100c8fb3e5..d4648ee923 100644 --- a/apps/dsp-app/src/app/workspace/resource/representation/still-image/still-image.component.ts +++ b/apps/dsp-app/src/app/workspace/resource/representation/still-image/still-image.component.ts @@ -521,16 +521,18 @@ export class StillImageComponent implements OnChanges, OnDestroy, AfterViewInit const linkVal = new CreateLinkValue(); linkVal.type = Constants.LinkValue; linkVal.linkedResourceIri = this.resourceIri; - const commentVal = new CreateTextValueAsString(); - commentVal.type = Constants.TextValue; - commentVal.text = comment; - createResource.properties = { - [Constants.HasComment]: [commentVal], [Constants.HasColor]: [colorVal], [Constants.IsRegionOfValue]: [linkVal], [Constants.HasGeometry]: [geomVal], }; + if (comment) { + const commentVal = new CreateTextValueAsString(); + commentVal.type = Constants.TextValue; + commentVal.text = comment; + createResource.properties[Constants.HasComment] = [commentVal]; + } + this._dspApiConnection.v2.res.createResource(createResource).subscribe((res: ReadResource) => { this.regionAdded.emit(res.id); }); From bae76097ae590fba810b979cc2aa2af47e4ba6a2 Mon Sep 17 00:00:00 2001 From: Julien Schneider Date: Wed, 28 Feb 2024 11:08:18 +0100 Subject: [PATCH 5/5] refactor: remove unused code in ontology component (#1472) --- .../project/ontology/ontology.component.html | 29 ++- .../project/ontology/ontology.component.ts | 242 +++++++----------- .../resource-class-info.component.ts | 18 +- 3 files changed, 113 insertions(+), 176 deletions(-) diff --git a/apps/dsp-app/src/app/project/ontology/ontology.component.html b/apps/dsp-app/src/app/project/ontology/ontology.component.html index ae4a636107..a725864670 100644 --- a/apps/dsp-app/src/app/project/ontology/ontology.component.html +++ b/apps/dsp-app/src/app/project/ontology/ontology.component.html @@ -10,14 +10,14 @@ class="mat-headline-6" [matTooltip]="(currentOntology$ | async).label + ((currentOntology$ | async).comment ? ' — ' + (currentOntology$ | async).comment : '')" matTooltipPosition="above"> - {{(currentOntology$ | async)?.label}} + {{ (currentOntology$ | async)?.label }}

- Updated on: {{(lastModificationDate$ | async) | date:'medium'}} + Updated on: {{ (lastModificationDate$ | async) | date:'medium' }} @@ -51,7 +51,7 @@ mat-button *ngIf="(currentOntology$ | async) as currentOntology" [disabled]="((lastModificationDate$ | async | isFalsy) || (currentOntologyCanBeDeleted$ | async) === false) || ((isAdmin$ | async) === false)" - (click)="$event.stopPropagation(); delete('Ontology', {iri: currentOntology.id, label: currentOntology.label})"> + (click)="$event.stopPropagation(); deleteOntology()"> delete Delete @@ -61,7 +61,6 @@ @@ -72,8 +71,8 @@ mat-button (click)="expandClasses = !expandClasses" [disabled]="!ontoClasses || !ontoClasses.length"> - {{expandClasses ? 'compress' : 'expand'}} - {{expandClasses ? "Collapse all" : "Expand all"}} + {{ expandClasses ? 'compress' : 'expand' }} + {{ expandClasses ? "Collapse all" : "Expand all" }} - {{type.icons[0]}} {{ type.label }} + {{ type.icons[0] }} + {{ type.label }} @@ -116,7 +116,7 @@ - + @@ -145,8 +146,8 @@ [expanded]="expandClasses" [userCanEdit]="isAdmin$ | async" (editResourceClass)="updateResourceClass($event)" - (deleteResourceClass)="delete('ResourceClass', $event)" - (updatePropertyAssignment)="onUpdatePropertyAssignment()" + (deleteResourceClass)="deleteResourceClass($event.iri)" + (updatePropertyAssignment)="initOntologiesList()" [updatePropertyAssignment$]="updatePropertyAssignment$"> @@ -158,16 +159,16 @@ *ngFor="let prop of ontoProperties?.properties; trackBy: trackByPropertyDefinitionFn; let odd = odd" [class.odd]="odd"> + if objectType is a linkValue hide it (otherwise we have the property twice) --> + (deleteResourceProperty)="deleteProperty($event.iri)"> diff --git a/apps/dsp-app/src/app/project/ontology/ontology.component.ts b/apps/dsp-app/src/app/project/ontology/ontology.component.ts index 547100e07c..574171e243 100644 --- a/apps/dsp-app/src/app/project/ontology/ontology.component.ts +++ b/apps/dsp-app/src/app/project/ontology/ontology.component.ts @@ -6,8 +6,6 @@ import { Inject, OnDestroy, OnInit, - ViewChild, - ViewContainerRef, } from '@angular/core'; import { UntypedFormBuilder, UntypedFormControl, UntypedFormGroup } from '@angular/forms'; import { MatDialog, MatDialogConfig } from '@angular/material/dialog'; @@ -16,14 +14,11 @@ import { ActivatedRoute, Params, Router } from '@angular/router'; import { ClassDefinition, Constants, - DeleteResourceClass, - DeleteResourceProperty, KnoraApiConnection, PropertyDefinition, ReadOntology, ReadProject, ReadUser, - UpdateOntology, } from '@dasch-swiss/dsp-js'; import { getAllEntityDefinitionsAsArray } from '@dasch-swiss/vre/shared/app-api'; import { DspApiConnectionToken, RouteConstants } from '@dasch-swiss/vre/shared/app-config'; @@ -53,8 +48,9 @@ import { } from '@dasch-swiss/vre/shared/app-state'; import { Actions, Select, Store, ofActionSuccessful } from '@ngxs/store'; import { Observable, Subject, combineLatest } from 'rxjs'; -import { map, take, takeUntil } from 'rxjs/operators'; +import { map, switchMap, take, takeUntil } from 'rxjs/operators'; import { DialogComponent, DialogEvent } from '../../main/dialog/dialog.component'; +import { DialogService } from '../../main/services/dialog.service'; import { ProjectBase } from '../project-base'; import { CreateResourceClassDialogComponent, @@ -72,7 +68,16 @@ import { styleUrls: ['./ontology.component.scss'], }) export class OntologyComponent extends ProjectBase implements OnInit, OnDestroy { - private ngUnsubscribe: Subject = new Subject(); + @Select(UserSelectors.user) user$: Observable; + @Select(UserSelectors.userProjectAdminGroups) userProjectAdminGroups$: Observable; + @Select(UserSelectors.isSysAdmin) isSysAdmin$: Observable; + @Select(ProjectsSelectors.isProjectsLoading) isProjectsLoading$: Observable; + @Select(OntologiesSelectors.currentProjectOntologies) currentProjectOntologies$: Observable; + @Select(OntologiesSelectors.currentOntologyCanBeDeleted) currentOntologyCanBeDeleted$: Observable; + isOntologiesLoading$ = this._store.select(OntologiesSelectors.isLoading); + currentOntology$ = this._store.select(OntologiesSelectors.currentOntology); + + private ngUnsubscribe = new Subject(); // all resource classes in the current ontology ontoClasses: ClassDefinition[]; @@ -101,45 +106,29 @@ export class OntologyComponent extends ProjectBase implements OnInit, OnDestroy /** * list of all default resource classes (subclass of) */ - defaultClasses: DefaultClass[] = DefaultResourceClasses.data; - defaultProperties: PropertyCategory[] = DefaultProperties.data; + readonly defaultClasses: DefaultClass[] = DefaultResourceClasses.data; + readonly defaultProperties: PropertyCategory[] = DefaultProperties.data; // disable content on small devices disableContent = false; // route to classes view - classesLink = `../${RouteConstants.classes}`; - propertiesLink = `../${RouteConstants.properties}`; + readonly classesLink = `../${RouteConstants.classes}`; + readonly propertiesLink = `../${RouteConstants.properties}`; - @ViewChild('ontologyEditor', { read: ViewContainerRef }) - ontologyEditor: ViewContainerRef; - - updatePropertyAssignment$: Subject = new Subject(); + updatePropertyAssignment$ = new Subject(); // the lastModificationDate is the most important key // when updating something inside the ontology - get lastModificationDate$(): Observable { - return this.currentOntology$.pipe( - takeUntil(this.ngUnsubscribe), - map(x => x?.lastModificationDate) - ); - } + lastModificationDate$ = this.currentOntology$.pipe( + takeUntil(this.ngUnsubscribe), + map(x => x?.lastModificationDate) + ); - get isLoading$(): Observable { - return combineLatest([this.isOntologiesLoading$, this.isProjectsLoading$]).pipe( - takeUntil(this.ngUnsubscribe), - map(([isOntologiesLoading, isProjectsLoading]) => isOntologiesLoading === true || isProjectsLoading === true) - ); - } - - @Select(UserSelectors.user) user$: Observable; - @Select(UserSelectors.userProjectAdminGroups) userProjectAdminGroups$: Observable; - @Select(UserSelectors.isSysAdmin) isSysAdmin$: Observable; - @Select(ProjectsSelectors.isProjectsLoading) isProjectsLoading$: Observable; - @Select(OntologiesSelectors.isLoading) isOntologiesLoading$: Observable; - @Select(OntologiesSelectors.currentProjectOntologies) currentProjectOntologies$: Observable; - @Select(OntologiesSelectors.currentOntology) currentOntology$: Observable; - @Select(OntologiesSelectors.currentOntologyCanBeDeleted) currentOntologyCanBeDeleted$: Observable; + isLoading$ = combineLatest([this.isOntologiesLoading$, this.isProjectsLoading$]).pipe( + takeUntil(this.ngUnsubscribe), + map(([isOntologiesLoading, isProjectsLoading]) => isOntologiesLoading === true || isProjectsLoading === true) + ); constructor( @Inject(DspApiConnectionToken) @@ -154,7 +143,8 @@ export class OntologyComponent extends ProjectBase implements OnInit, OnDestroy protected _store: Store, protected _titleService: Title, protected _projectService: ProjectService, - protected _cd: ChangeDetectorRef + protected _cd: ChangeDetectorRef, + private _dialogService: DialogService ) { super(_store, _route, _projectService, _titleService, _router, _cd, _actions$); } @@ -189,7 +179,7 @@ export class OntologyComponent extends ProjectBase implements OnInit, OnDestroy // TODO temporary solution to replace eventemitter with subject because emitter loses subscriber after child component // subscription responsible for emitting event is triggered this.updatePropertyAssignment$.pipe(takeUntil(this.ngUnsubscribe)).subscribe(() => { - this.onUpdatePropertyAssignment(); + this.initOntologiesList(); }); this._cd.markForCheck(); @@ -220,7 +210,7 @@ export class OntologyComponent extends ProjectBase implements OnInit, OnDestroy this._store.dispatch(new ClearCurrentOntologyAction()); } - initView(ontology: ReadOntology): void { + private initView(ontology: ReadOntology): void { this.disableContent = window.innerWidth <= 768; // set the page title @@ -234,7 +224,13 @@ export class OntologyComponent extends ProjectBase implements OnInit, OnDestroy }), }); - this.ontologyForm.valueChanges.subscribe(val => this.onValueChanged(val.ontology)); + this.ontologyForm.valueChanges.subscribe(val => { + if (!this.ontologyForm) { + return; + } + // reset and open selected ontology + this.resetOntology(val.ontology); + }); } /** @@ -292,7 +288,7 @@ export class OntologyComponent extends ProjectBase implements OnInit, OnDestroy } } - initOntoClasses(allOntoClasses: ClassDefinition[]) { + private initOntoClasses(allOntoClasses: ClassDefinition[]) { // reset the ontology classes this.ontoClasses = []; @@ -339,19 +335,7 @@ export class OntologyComponent extends ProjectBase implements OnInit, OnDestroy trackByElementFn = (index: number) => `${index}`; - /** - * update view after selecting an ontology from dropdown - * @param id - */ - onValueChanged(id: string) { - if (!this.ontologyForm) { - return; - } - // reset and open selected ontology - this.resetOntology(id); - } - - onLastModificationDateChange(lastModificationDate): void { + onLastModificationDateChange(): void { const ontology = this._store.selectSnapshot(OntologiesSelectors.currentOntology); // TODO reload or just update lastModificationDate in the state? this._store.dispatch(new LoadOntologyAction(ontology.id, this.projectUuid, true)); @@ -362,7 +346,7 @@ export class OntologyComponent extends ProjectBase implements OnInit, OnDestroy * @param id ontology id/iri * @param view 'classes' | 'properties' | ' graph' */ - openOntologyRoute(id: string, view: 'classes' | 'properties' | 'graph' = 'classes') { + private openOntologyRoute(id: string, view: 'classes' | 'properties' | 'graph' = 'classes') { this.view = view; this._router.navigate( @@ -375,7 +359,7 @@ export class OntologyComponent extends ProjectBase implements OnInit, OnDestroy * resets the current view and the selected ontology * @param id */ - resetOntology(id: string) { + private resetOntology(id: string) { this._store.dispatch([new SetCurrentOntologyAction(null), new CurrentOntologyCanBeDeletedAction()]); this.ontoClasses = []; this.openOntologyRoute(id, this.view); @@ -397,14 +381,6 @@ export class OntologyComponent extends ProjectBase implements OnInit, OnDestroy ]); } - /** - * filters owl class - * @param owlClass - */ - filterOwlClass(owlClass: any) { - return owlClass['@type'] === 'owl:class'; - } - /** * opens ontology form to create or edit ontology info * @param mode @@ -434,7 +410,7 @@ export class OntologyComponent extends ProjectBase implements OnInit, OnDestroy const dialogRef = this._dialog.open(DialogComponent, dialogConfig); - dialogRef.afterClosed().subscribe((ontologyId: string) => { + dialogRef.afterClosed().subscribe(() => { this.initOntologiesList(); }); } @@ -516,89 +492,65 @@ export class OntologyComponent extends ProjectBase implements OnInit, OnDestroy }); } - onUpdatePropertyAssignment() { - this.initOntologiesList(); - } + deleteOntology() { + const ontology = this._store.selectSnapshot(OntologiesSelectors.currentOntology); - /** - * delete either ontology, resource class or property - * - * @param mode Can be 'Ontology' or 'ResourceClass' - * @param info - */ - delete(mode: 'Ontology' | 'ResourceClass' | 'Property', info: DefaultClass) { - const dialogConfig: MatDialogConfig = { - width: '560px', - maxHeight: '80vh', - position: { - top: '112px', - }, - data: { mode: `delete${mode}`, title: info.label }, - }; + this._dialogService + .afterConfirmation('Do you want to delete this data model ?') + .pipe( + switchMap(() => + this._dspApiConnection.v2.onto.deleteOntology({ + id: ontology.id, + lastModificationDate: ontology.lastModificationDate, + }) + ) + ) + .subscribe(() => { + this._store.dispatch(new ClearProjectOntologiesAction(this.projectUuid)); + this.initOntologiesList(); + this._router.navigateByUrl(`/project/${this.projectUuid}`, { + skipLocationChange: false, + }); + }); + } - const dialogRef = this._dialog.open(DialogComponent, dialogConfig); + deleteResourceClass(resClassIri: string) { + const ontology = this._store.selectSnapshot(OntologiesSelectors.currentOntology); + this._dialogService + .afterConfirmation('Do you want to delete this resource class?') + .pipe( + switchMap(() => + this._dspApiConnection.v2.onto.deleteResourceClass({ + id: resClassIri, + lastModificationDate: ontology.lastModificationDate, + }) + ) + ) + .subscribe(() => { + this.ontoClasses = []; + this.initOntologiesList(); + }); + } - dialogRef.afterClosed().subscribe(answer => { - if (answer === true) { - const ontology = this._store.selectSnapshot(OntologiesSelectors.currentOntology); - // delete and refresh the view - switch (mode) { - case 'Ontology': - const updateOntology = new UpdateOntology(); - updateOntology.id = ontology.id; - updateOntology.lastModificationDate = ontology.lastModificationDate; - this._dspApiConnection.v2.onto - .deleteOntology(updateOntology) - .pipe(take(1)) - .subscribe(() => { - this._store.dispatch(new ClearProjectOntologiesAction(this.projectUuid)); - // reset current ontology - // this._store.dispatch([ - // new SetCurrentOntologyAction(null), - // new RemoveProjectOntologyAction(updateOntology.id, this.projectUuid) - // ]); - // get the ontologies for this project - this.initOntologiesList(); - // go to project ontology page - const goto = `/project/${this.projectUuid}`; - this._router.navigateByUrl(goto, { - skipLocationChange: false, - }); - }); - break; - - case 'ResourceClass': - // delete resource class and refresh the view - const resClass: DeleteResourceClass = new DeleteResourceClass(); - resClass.id = info.iri; - resClass.lastModificationDate = ontology.lastModificationDate; - this._dspApiConnection.v2.onto - .deleteResourceClass(resClass) - .pipe(take(1)) - .subscribe(() => { - this.ontoClasses = []; - this.initOntologiesList(); - }); - break; - case 'Property': - // delete resource property and refresh the view - const resProp: DeleteResourceProperty = new DeleteResourceProperty(); - resProp.id = info.iri; - resProp.lastModificationDate = ontology.lastModificationDate; - this._dspApiConnection.v2.onto - .deleteResourceProperty(resProp) - .pipe(take(1)) - .subscribe(() => { - this._store.dispatch(new ClearCurrentOntologyAction()); - // get the ontologies for this project - this.initOntologiesList(); - // update the view of resource class or list of properties - this.initOntology(); - }); - break; - } - } - }); + deleteProperty(iri: string) { + const ontology = this._store.selectSnapshot(OntologiesSelectors.currentOntology); + this._dialogService + .afterConfirmation('Do you want to delete this property?') + .pipe( + switchMap(() => + this._dspApiConnection.v2.onto.deleteResourceProperty({ + id: iri, + lastModificationDate: ontology.lastModificationDate, + }) + ) + ) + .subscribe(() => { + this._store.dispatch(new ClearCurrentOntologyAction()); + // get the ontologies for this project + this.initOntologiesList(); + // update the view of resource class or list of properties + this.initOntology(); + }); } private setTitle() { diff --git a/apps/dsp-app/src/app/project/ontology/resource-class-info/resource-class-info.component.ts b/apps/dsp-app/src/app/project/ontology/resource-class-info/resource-class-info.component.ts index 863879eda4..bb4caa600f 100644 --- a/apps/dsp-app/src/app/project/ontology/resource-class-info/resource-class-info.component.ts +++ b/apps/dsp-app/src/app/project/ontology/resource-class-info/resource-class-info.component.ts @@ -261,22 +261,6 @@ export class ResourceClassInfoComponent implements OnInit, OnDestroy { }); } - initOntoProperties(allOntoProperties: PropertyDefinition[]): PropertyDefinition[] { - // reset the ontology properties - const listOfProperties = []; - - // display only the properties which are not a subjectType of Standoff - allOntoProperties.forEach(resProp => { - const standoff = resProp.subjectType ? resProp.subjectType.includes('Standoff') : false; - if (resProp.objectType !== Constants.LinkValue && !standoff) { - listOfProperties.push(resProp); - } - }); - // sort properties by label - // --> TODO: add sort functionallity to the gui - return this._sortingService.keySortByAlphabetical(listOfProperties, 'label'); - } - canBeDeleted() { // check if the class can be deleted this._dspApiConnection.v2.onto @@ -331,7 +315,7 @@ export class ResourceClassInfoComponent implements OnInit, OnDestroy { * property and add it to the class * @param propertyAssignment information about the link of a property to a class * */ - assignProperty(propertyAssignment: PropertyAssignment, currentOntologyPropertiesToDisplay: PropToDisplay[]) { + private assignProperty(propertyAssignment: PropertyAssignment, currentOntologyPropertiesToDisplay: PropToDisplay[]) { if (!propertyAssignment) { return; }