Skip to content

Commit

Permalink
ELEMENTS-1629: fix blob removal in nuxeo-data-table
Browse files Browse the repository at this point in the history
  • Loading branch information
rahuljain-dev authored and poonamyadav252 committed Jun 13, 2023
1 parent 218fe17 commit 32022a1
Showing 1 changed file with 38 additions and 8 deletions.
46 changes: 38 additions & 8 deletions ui/actions/nuxeo-delete-blob-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ import '../nuxeo-button-styles.js';
>
</div>
</nuxeo-dialog>
<nuxeo-connection id="nx" connection-id="[[connectionId]]"></nuxeo-connection>
<nuxeo-resource id="blobRequest"></nuxeo-resource>
`;
}

Expand All @@ -87,6 +89,10 @@ import '../nuxeo-button-styles.js';

static get properties() {
return {
connectionId: {
type: String,
value: 'nx',
},
/**
* Input document.
*/
Expand Down Expand Up @@ -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,
},
}),
);
}
}

Expand Down

0 comments on commit 32022a1

Please sign in to comment.