From 2c5fd8064f79d5da202b1274813acbebe16020ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Fri, 14 Jan 2022 15:57:20 +0100 Subject: [PATCH] feat(resource): display deleted resource (DEV-299) (#632) * feat(resource): display deleted resource * feat(resource): display deleted resource * refactor(resource): make tslint happy * chore(deps): bump js-lib to latest * test: fix unit tests --- package-lock.json | 14 +-- package.json | 2 +- .../properties/properties.component.html | 117 +++++++++++------- .../properties/properties.component.scss | 9 ++ .../properties/properties.component.ts | 6 +- .../resource/resource.component.html | 9 +- .../workspace/resource/resource.component.ts | 83 +++++++------ ...ch-select-resource-class.component.spec.ts | 4 +- 8 files changed, 145 insertions(+), 99 deletions(-) diff --git a/package-lock.json b/package-lock.json index 010f590503..f6563d63c8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,7 @@ "@angular/platform-browser-dynamic": "^12.2.14", "@angular/router": "^12.2.14", "@ckeditor/ckeditor5-angular": "^2.0.2", - "@dasch-swiss/dsp-js": "^6.0.0", + "@dasch-swiss/dsp-js": "^6.1.0", "@datadog/browser-rum": "^3.7.0", "@ngx-translate/core": "^12.1.2", "@ngx-translate/http-loader": "5.0.0", @@ -2453,9 +2453,9 @@ } }, "node_modules/@dasch-swiss/dsp-js": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/@dasch-swiss/dsp-js/-/dsp-js-6.0.0.tgz", - "integrity": "sha512-zCqxyMzlNAmEGI1qJ+K3OSVWbfRux6pOmd59lAEPiGvAcI0trd9UBJOwucXGeW/cQoU01bWsU33evGs76I3/RA==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@dasch-swiss/dsp-js/-/dsp-js-6.1.0.tgz", + "integrity": "sha512-uREVh2HI+BxsL67bLaFX90vwqxm0uBWmZ7QJtP9lJUijp/T93dkh/unRsvG6PhWE2nGnpK3peEC2IyKOVU25hA==", "dependencies": { "@babel/helper-compilation-targets": "^7.14.5", "@types/jsonld": "^1.5.0", @@ -21204,9 +21204,9 @@ "dev": true }, "@dasch-swiss/dsp-js": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/@dasch-swiss/dsp-js/-/dsp-js-6.0.0.tgz", - "integrity": "sha512-zCqxyMzlNAmEGI1qJ+K3OSVWbfRux6pOmd59lAEPiGvAcI0trd9UBJOwucXGeW/cQoU01bWsU33evGs76I3/RA==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@dasch-swiss/dsp-js/-/dsp-js-6.1.0.tgz", + "integrity": "sha512-uREVh2HI+BxsL67bLaFX90vwqxm0uBWmZ7QJtP9lJUijp/T93dkh/unRsvG6PhWE2nGnpK3peEC2IyKOVU25hA==", "requires": { "@babel/helper-compilation-targets": "^7.14.5", "@types/jsonld": "^1.5.0", diff --git a/package.json b/package.json index a3c2b803db..ef6f635442 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "@angular/platform-browser-dynamic": "^12.2.14", "@angular/router": "^12.2.14", "@ckeditor/ckeditor5-angular": "^2.0.2", - "@dasch-swiss/dsp-js": "^6.0.0", + "@dasch-swiss/dsp-js": "^6.1.0", "@datadog/browser-rum": "^3.7.0", "@ngx-translate/core": "^12.1.2", "@ngx-translate/http-loader": "5.0.0", diff --git a/src/app/workspace/resource/properties/properties.component.html b/src/app/workspace/resource/properties/properties.component.html index 5b48115dd8..a9d2e83815 100644 --- a/src/app/workspace/resource/properties/properties.component.html +++ b/src/app/workspace/resource/properties/properties.component.html @@ -1,6 +1,5 @@ - -
+

{{resource.res.label}} (deleted) @@ -12,22 +11,23 @@

- - @@ -41,8 +41,8 @@

open_in_new Open resource in new tab - - + - - - - @@ -73,7 +77,7 @@

- This resource belongs to the project + This resource {{ resource.res.isDeleted ? 'belonged' : 'belongs' }} to the project {{project?.shortname}} open_in_new @@ -89,8 +93,7 @@

-
- +
@@ -106,38 +109,27 @@

prop.propDef.subjectType === representationConstants.region && prop.propDef.objectType !== representationConstants.color )) - )" - [class.border-bottom]="prop.values && !last" - class="property"> + )" [class.border-bottom]="prop.values && !last" class="property">
-

+

{{prop.propDef.label}}

-
- @@ -145,8 +137,7 @@

@@ -156,13 +147,11 @@

@@ -171,7 +160,45 @@

+ + - The resource {{resource?.res.resourceClassLabel}} has no defined properties. +
+
+
+ +

+ Deleted on +

+
+
+ {{ resource.res.deleteDate | date }} +
+
+
+
+ +

+ Comment +

+
+
+ {{ resource.res.deleteComment }} +
+
+
+ +
+
+
+

+ Info +

+
+
+ This resource has no defined properties. +
+
+
diff --git a/src/app/workspace/resource/properties/properties.component.scss b/src/app/workspace/resource/properties/properties.component.scss index 599ff2fcec..b474d683b1 100644 --- a/src/app/workspace/resource/properties/properties.component.scss +++ b/src/app/workspace/resource/properties/properties.component.scss @@ -146,6 +146,15 @@ } } +.no-properties, +.deleted-resource { + margin-top: 16px; + + .comment { + margin: 16px; + } +} + .label { color: rgba(0, 0, 0, 0.54); } diff --git a/src/app/workspace/resource/properties/properties.component.ts b/src/app/workspace/resource/properties/properties.component.ts index 5ccee42c92..448d14e34b 100644 --- a/src/app/workspace/resource/properties/properties.component.ts +++ b/src/app/workspace/resource/properties/properties.component.ts @@ -423,7 +423,7 @@ export class PropertiesComponent implements OnInit, OnChanges, OnDestroy { } } else { // --> TODO: better error handler! - console.error('No properties exist for this resource'); + console.warn('No properties exist for this resource'); } } @@ -452,7 +452,7 @@ export class PropertiesComponent implements OnInit, OnChanges, OnDestroy { this.regionColorChanged.emit(); } } else { - console.error('No properties exist for this resource'); + console.warn('No properties exist for this resource'); } } @@ -491,7 +491,7 @@ export class PropertiesComponent implements OnInit, OnChanges, OnDestroy { } ); } else { - console.error('No properties exist for this resource'); + console.warn('No properties exist for this resource'); } } diff --git a/src/app/workspace/resource/resource.component.html b/src/app/workspace/resource/resource.component.html index a2877fc194..97f0bfc1ea 100644 --- a/src/app/workspace/resource/resource.component.html +++ b/src/app/workspace/resource/resource.component.html @@ -34,7 +34,7 @@
- + + [label]="incomingResource.res.entityInfo?.classes[incomingResource.res.type].label"> @@ -69,6 +69,11 @@ + + + +
diff --git a/src/app/workspace/resource/resource.component.ts b/src/app/workspace/resource/resource.component.ts index 11a72f6563..b0cdfb42a8 100644 --- a/src/app/workspace/resource/resource.component.ts +++ b/src/app/workspace/resource/resource.component.ts @@ -218,55 +218,60 @@ export class ResourceComponent implements OnInit, OnChanges, OnDestroy { const res = new DspResource(response); this.resource = res; - // if there is no incomingResource and the resource has a still image property, assign the iiiUrl to be passed as an input to the still-image component - if (!this.incomingResource && this.resource.res.properties[Constants.HasStillImageFileValue]){ - this.iiifUrl = (this.resource.res.properties[Constants.HasStillImageFileValue][0] as ReadStillImageFileValue).fileUrl; - } - - this.selectedTabLabel = this.resource.res.entityInfo?.classes[this.resource.res.type].label; - - // get information about the logged-in user, if one is logged-in - if (this._session.getSession()) { - this.session = this._session.getSession(); - // is the logged-in user project member? - // --> TODO: as soon as we know how to handle the permissions, set this value the correct way - this.editPermissions = true; - // is the logged-in user system admin or project admin? - this.adminPermissions = this.session.user.sysAdmin ? this.session.user.sysAdmin : this.session.user.projectAdmin.some(e => e === res.res.attachedToProject); - } - - this.collectRepresentationsAndAnnotations(this.resource); - - if (!this.representationsToDisplay.length && !this.compoundPosition) { - // the resource could be a compound object - this._incomingService.getStillImageRepresentationsForCompoundResource(this.resource.res.id, 0, true).subscribe( - (countQuery: CountQueryResponse) => { + if (response.isDeleted) { + // deleted resource; no further infos needed - if (countQuery.numberOfResults > 0) { - this.compoundPosition = new DspCompoundPosition(countQuery.numberOfResults); - this.compoundNavigation(1); - } - }, - (error: ApiResponseError) => { - this._errorHandler.showMessage(error); - } - ); } else { - this.requestIncomingResources(this.resource); - } + // if there is no incomingResource and the resource has a still image property, assign the iiiUrl to be passed as an input to the still-image component + if (!this.incomingResource && this.resource.res.properties[Constants.HasStillImageFileValue]){ + this.iiifUrl = (this.resource.res.properties[Constants.HasStillImageFileValue][0] as ReadStillImageFileValue).fileUrl; + } + + this.selectedTabLabel = this.resource.res.entityInfo?.classes[this.resource.res.type].label; + + // get information about the logged-in user, if one is logged-in + if (this._session.getSession()) { + this.session = this._session.getSession(); + // is the logged-in user project member? + // --> TODO: as soon as we know how to handle the permissions, set this value the correct way + this.editPermissions = true; + // is the logged-in user system admin or project admin? + this.adminPermissions = this.session.user.sysAdmin ? this.session.user.sysAdmin : this.session.user.projectAdmin.some(e => e === res.res.attachedToProject); + } + + this.collectRepresentationsAndAnnotations(this.resource); + + if (!this.representationsToDisplay.length && !this.compoundPosition) { + // the resource could be a compound object + this._incomingService.getStillImageRepresentationsForCompoundResource(this.resource.res.id, 0, true).subscribe( + (countQuery: CountQueryResponse) => { + + if (countQuery.numberOfResults > 0) { + this.compoundPosition = new DspCompoundPosition(countQuery.numberOfResults); + this.compoundNavigation(1); + } + }, + (error: ApiResponseError) => { + this._errorHandler.showMessage(error); + } + ); + } else { + this.requestIncomingResources(this.resource); + } - // gather resource property information - res.resProps = this.initProps(response); + // gather resource property information + res.resProps = this.initProps(response); - // gather system property information - res.systemProps = this.resource.res.entityInfo.getPropertyDefinitionsByType(SystemPropertyDefinition); + // gather system property information + res.systemProps = this.resource.res.entityInfo.getPropertyDefinitionsByType(SystemPropertyDefinition); + } this.loading = false; }, (error: ApiResponseError) => { this.loading = false; if (error.status === 404) { - // resource not found: maybe it's deleted or the iri is wrong + // resource not found // display message that it couldn't be found this.resource = undefined; } else { diff --git a/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-resource-class/search-select-resource-class.component.spec.ts b/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-resource-class/search-select-resource-class.component.spec.ts index 5a59992ab1..e34c84f698 100644 --- a/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-resource-class/search-select-resource-class.component.spec.ts +++ b/src/app/workspace/search/advanced-search/resource-and-property-selection/search-select-resource-class/search-select-resource-class.component.spec.ts @@ -173,7 +173,7 @@ describe('SearchSelectResourceClassComponent', () => { testHostFixture.detectChanges(); - expect(testHostComponent.selectResourceClass.resourceClassDefinitions.length).toEqual(13); + expect(testHostComponent.selectResourceClass.resourceClassDefinitions.length).toEqual(14); const select = await loader.getHarness(MatSelectHarness); const initVal = await select.getValueText(); @@ -185,7 +185,7 @@ describe('SearchSelectResourceClassComponent', () => { const options = await select.getOptions(); - expect(options.length).toEqual(14); + expect(options.length).toEqual(15); expect(testHostComponent.selectResourceClass.selectedResourceClassIri).toBe(false);