From ca8358451624c8b8af4a3a58051b3f60140378eb Mon Sep 17 00:00:00 2001 From: mdelez <60604010+mdelez@users.noreply.github.com> Date: Wed, 1 Dec 2021 10:15:58 +0100 Subject: [PATCH] chore(lists): adds changes required for lists to work due to the change in js-lib (#599) --- package-lock.json | 14 +++++------ package.json | 2 +- .../edit-list-item.component.ts | 24 ++++++++++--------- .../list-item-form.component.ts | 2 +- 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9c1d0d4535..2ecb2d6c3b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,7 @@ "@angular/platform-browser-dynamic": "^12.2.13", "@angular/router": "^12.2.13", "@ckeditor/ckeditor5-angular": "^2.0.2", - "@dasch-swiss/dsp-js": "^4.2.0", + "@dasch-swiss/dsp-js": "^5.0.0", "@datadog/browser-rum": "^3.7.0", "@ngx-translate/core": "^12.1.2", "@ngx-translate/http-loader": "5.0.0", @@ -2459,9 +2459,9 @@ } }, "node_modules/@dasch-swiss/dsp-js": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/@dasch-swiss/dsp-js/-/dsp-js-4.2.0.tgz", - "integrity": "sha512-6NT53Gfq20gkavOlbOsJAXSptgICve1iSN0H4lRw6s2/MUkZER2AxMZe3qkLBFvIa4A67Dh30AWSPMfaIxzC1w==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@dasch-swiss/dsp-js/-/dsp-js-5.0.0.tgz", + "integrity": "sha512-TLX5l4H3tf60aMiIedurB7ypeo8acIv45ZaZs01OpdUXJTvxzGA4HRblZ6tZ1HSWOnKgD/j55lTunKZFZuTQ7g==", "dependencies": { "@babel/helper-compilation-targets": "^7.14.5", "@types/jsonld": "^1.5.0", @@ -22373,9 +22373,9 @@ "dev": true }, "@dasch-swiss/dsp-js": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/@dasch-swiss/dsp-js/-/dsp-js-4.2.0.tgz", - "integrity": "sha512-6NT53Gfq20gkavOlbOsJAXSptgICve1iSN0H4lRw6s2/MUkZER2AxMZe3qkLBFvIa4A67Dh30AWSPMfaIxzC1w==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@dasch-swiss/dsp-js/-/dsp-js-5.0.0.tgz", + "integrity": "sha512-TLX5l4H3tf60aMiIedurB7ypeo8acIv45ZaZs01OpdUXJTvxzGA4HRblZ6tZ1HSWOnKgD/j55lTunKZFZuTQ7g==", "requires": { "@babel/helper-compilation-targets": "^7.14.5", "@types/jsonld": "^1.5.0", diff --git a/package.json b/package.json index 903b92938a..fcc53c8b0e 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "@angular/platform-browser-dynamic": "^12.2.13", "@angular/router": "^12.2.13", "@ckeditor/ckeditor5-angular": "^2.0.2", - "@dasch-swiss/dsp-js": "^4.2.0", + "@dasch-swiss/dsp-js": "^5.0.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/project/list/list-item-form/edit-list-item/edit-list-item.component.ts b/src/app/project/list/list-item-form/edit-list-item/edit-list-item.component.ts index af531b73af..a5a94b23f2 100644 --- a/src/app/project/list/list-item-form/edit-list-item/edit-list-item.component.ts +++ b/src/app/project/list/list-item-form/edit-list-item/edit-list-item.component.ts @@ -73,15 +73,17 @@ export class EditListItemComponent implements OnInit { ngOnInit(): void { this.loading = true; - // get the project data from cache - this._cache.get(this.projectCode).subscribe( - (response: ReadProject) => { - this.projectIri = response.id; - }, - (error: ApiResponseError) => { - this._errorHandler.showMessage(error); - } - ); + // get the project iri from cache if the project code was provided + if (this.projectCode) { + this._cache.get(this.projectCode).subscribe( + (response: ReadProject) => { + this.projectIri = response.id; + }, + (error: ApiResponseError) => { + this._errorHandler.showMessage(error); + } + ); + } // if updating a node, get the existing node info if (this.mode === 'update') { @@ -157,7 +159,7 @@ export class EditListItemComponent implements OnInit { childNodeUpdateData.projectIri = this.projectIri; childNodeUpdateData.listIri = this.iri; childNodeUpdateData.labels = this.labels; - childNodeUpdateData.comments = this.comments.length > 0 ? this.comments : []; + childNodeUpdateData.comments = this.comments.length > 0 ? this.comments : undefined; this._dspApiConnection.admin.listsEndpoint.updateChildNode(childNodeUpdateData).subscribe( (response: ApiResponseData) => { @@ -181,7 +183,7 @@ export class EditListItemComponent implements OnInit { createChildNodeRequest.name = this.projectCode + '-' + Math.random().toString(36).substr(2) + Math.random().toString(36).substr(2); createChildNodeRequest.parentNodeIri = this.parentIri; createChildNodeRequest.labels = this.labels; - createChildNodeRequest.comments = this.comments.length > 0 ? this.comments : []; + createChildNodeRequest.comments = this.comments.length > 0 ? this.comments : undefined; createChildNodeRequest.projectIri = this.projectIri; createChildNodeRequest.position = this.position; diff --git a/src/app/project/list/list-item-form/list-item-form.component.ts b/src/app/project/list/list-item-form/list-item-form.component.ts index c77a2158dc..54f852529f 100644 --- a/src/app/project/list/list-item-form/list-item-form.component.ts +++ b/src/app/project/list/list-item-form/list-item-form.component.ts @@ -157,7 +157,7 @@ export class ListItemFormComponent implements OnInit { childNode.labels[i].value = l.value; i++; } - childNode.comments = []; // --> TODO comments are not yet implemented in the template + // childNode.comments = []; // --> TODO comments are not yet implemented in the template // init data to emit to parent const listNodeOperation: ListNodeOperation = new ListNodeOperation();