From 32022a15dc293f7e303f26cf6e596d8454d78d60 Mon Sep 17 00:00:00 2001 From: rahuljain-dev Date: Tue, 6 Jun 2023 11:04:16 +0530 Subject: [PATCH] ELEMENTS-1629: fix blob removal in nuxeo-data-table --- ui/actions/nuxeo-delete-blob-button.js | 46 +++++++++++++++++++++----- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/ui/actions/nuxeo-delete-blob-button.js b/ui/actions/nuxeo-delete-blob-button.js index 2a60f8ef4..24bd13205 100644 --- a/ui/actions/nuxeo-delete-blob-button.js +++ b/ui/actions/nuxeo-delete-blob-button.js @@ -78,6 +78,8 @@ import '../nuxeo-button-styles.js'; > + + `; } @@ -87,6 +89,10 @@ import '../nuxeo-button-styles.js'; static get properties() { return { + connectionId: { + type: String, + value: 'nx', + }, /** * Input document. */ @@ -151,14 +157,38 @@ import '../nuxeo-button-styles.js'; } _remove() { - this.$.operation.execute().then(() => { - this.dispatchEvent( - new CustomEvent('file-deleted', { - composed: true, - bubbles: true, - }), - ); - }); + const rowNo = this.xpath.split('/')[1]; + const { 'upload-batch': uploadBatch, 'upload-fileId': uploadFileId } = this.document.properties[ + 'monschema:mesdonnees' + ][rowNo].fichier; + if (uploadBatch && uploadFileId) { + this.$.blobRequest.data = {}; + this.$.blobRequest.path = `upload/${uploadBatch}/${uploadFileId}`; + this.$.blobRequest + .remove() + .then((response) => { + this._dispatchEvent('file-deleted', response); + }) + .catch((error) => { + this._dispatchEvent('error', error); + }); + } else { + this.$.operation.execute().then((response) => { + this._dispatchEvent('file-deleted', response); + }); + } + } + + _dispatchEvent(eventName, response) { + this.dispatchEvent( + new CustomEvent(eventName, { + composed: true, + bubbles: true, + detail: { + response, + }, + }), + ); } }