cancel
Showing results for 
Search instead for 
Did you mean: 

UploadSet Remove item confirmation popup sync to Odata

0 Kudos

Hi All,

I have used uplodSet to upload attachments in my custom UI5 app. When I click remove icon I am calling my custom OData to delete file from tables.

But the problem is frame work calls a standard confirmation popup which is not in sync with my OData call, I tried few different ways but none gave me a luck, my code should call on after users confirmation from popup.

Any suggestions much helpful.

Thanks

Margot
Product and Topic Expert
Product and Topic Expert

Can you share your the ways you already tried, including your code to realise it? Otherwise it's hard to figure out what might be the issue.

0 Kudos

_launchRemoveAttachDialog(owner, guid, selectedAttachment) { var that = this; if (!this.oRemoveAttachDialog) { this.oRemoveAttachDialog = new sap.m.Dialog({ type: MessageType.Message, title: "Confirm", content: new sap.m.Text({ text: "Do you really want to remove selected attachment?" }), beginButton: new sap.m.Button({ type: ButtonType.Emphasized, text: "Yes", press: function () { that._deleteAttachment(owner, guid, selectedAttachment); this.oRemoveAttachDialog.close(); }.bind(this) }), endButton: new sap.m.Button({ text: "Cancel", press: function () { this.oRemoveAttachDialog.close(); }.bind(this) }) }); }
this.oRemoveAttachDialog.open(); }, _deleteAttachment: function (owner, guid,attachment) { let that = this; const oUploadSet = this.getView().byId("idAttach"); const loggedUser = sap.ushell.Container.getService("UserInfo").getUser().getId(); if (loggedUser === owner) { const sPath = "/PR_AttachmentSet('" + guid + "')"; sap.ui.core.BusyIndicator.show(); this.mainService.remove(sPath, { success: (oData) => { that._showToast("File removed successfully"); oUploadSet.removeItem(attachment); sap.ui.core.BusyIndicator.hide(); }, error: (oError) => { that._showToast("Error while deleting the file"); sap.ui.core.BusyIndicator.hide(); } }); } else { that._showToast("File can't be removed, you are not the owner of the selected file"); } }, onRemovePressed: function (oEvent) { //prevent SAPs standard event chain oEvent.preventDefault(); // launch confirmation dialog for user decision const fileOwner = (oEvent.getSource().getStatuses()[0]).getText(); const fileGUID = (oEvent.getSource().getUrl()).split("'")[1]; const oItem = oEvent.getParameter("item"); this._launchRemoveAttachDialog(fileOwner, fileGUID, oItem);
},

@margot.wollny above the code I implemented but some times it behaves vert weird same file it won't upload and no errors and when I remove a uploaded file and redo .i.e. upload any other file it errors a duplicate ID.

Thanks

Rajesh

gregorw
Active Contributor

Hi Rajesh,

please edit your comment and check the formatting. As an alternative provide a public Git repository.

Best Regards
Gregor

0 Kudos

Hi Gergor,

Below is my public Git, not sure what wrong I am doing to past my code in SDN I am still using code format from the text composer.


https://github.com/rajeshkelam/uploadset.git

Thanks

Rajesh

Accepted Solutions (0)

Answers (1)

Answers (1)

dusa
Explorer

Hi Rajesh,

I had similar problem and my solution was following:
There is removePressed Event in UploadSetItem. I defined my own function onRemovePressed to be called on removePressed event and the first thing in the function I call oEvent.preventDefault();

The popup is prevented from displaying. If you need some confirmation popup, you could write your own in the same function.

onRemovePressed: function(oEvent) {
oEvent.preventDefault();
// your code here
}
HI Dusan Sacha,

Yes done the same earlier, but it seems UplodSet is like a half baked product from SAP...things not working as it supposed.

Thanks

Rajesh