spreadsheetimporter / ui5-cc-spreadsheetimporter

A UI5 Component to integrate a Spreadsheet Upload for UI5 Apps.
https://spreadsheet-importer.com/
Apache License 2.0
82 stars 16 forks source link

[Bug]: event.preventDefault() is not restricting the Backend call #475

Closed mainakaich closed 8 months ago

mainakaich commented 8 months ago

OData Version

OData V2

Draft

Yes

Scenario

Fiori Elements

Environment

BTP ABAP

UI5 Spreadsheet Component

v0_31_1

What happened?

In the spreadsheet controller custom code, I have the requirement where on click of the upload button, I don't want the automatic HTTP post calls to the OData services by the spreadsheet importer UI5 component. Instead, I want to build my own post request(deep create) myself and send it to backend. So I have developed the code like below -

        // event example to prevent uploading data to backend
        this.spreadsheetUpload.attachUploadButtonPress(function (event) {
            event.preventDefault();
        .
        .
        .

        }

My expectation is event.preventDefault(); shall prevent the automatic HTTP post calls to the backend. But still the backend call is happening which I want to stop. I am attaching the entire custom code controller file(spreadSheetController.js - changed the extension to .txt so that I can attach here spreadSheetController.js.txt ) for your reference.

Relevant log output

To be provided if required

Spreadsheet Component Init

To be provided if required

Manifest

"componentUsages": {
            "spreadsheetImporter": {
                "name": "cc.spreadsheetimporter.v0_31_1"
            }
        },
        "resourceRoots": {
            "cc.spreadsheetimporter.v0_31_1": "./thirdparty/customControl/spreadsheetImporter/v0_31_1"
        },
marianfoo commented 8 months ago

Hi @mainakaich thank you for your bug report and the good sample. I was able to reproduce it and fix it. The patch is published with version 0.31.3. Please try if that works for you

mainakaich commented 8 months ago

Hi @marianfoo

I have one more request associated with the same issue. When we have used event.preventDefault(), it is not possible to show the OData response in the UI (by using something like oEvent.getSource().addArrayToMessages( ) ). Is it possible to get any UI component from your framework so that all the error message from the OData response can be displayed on the UI component? Thanks, Mainak

marianfoo commented 8 months ago

You can attach a async function and wait for the OData response and show the error yourself. https://docs.spreadsheet-importer.com/pages/Events/#attach-async-functions-to-events

mainakaich commented 8 months ago

Hello @marianfoo

Actually we are able get the OData response. My request is, is it possible to pass our OData response to your framework so that the messages are displayed in your UI screen. E.g. if we don't use event.preventDefault(), then your framework sends and receives the OData response and displays the response in your UI screen. Can we able reuse the same UI screen by passing our OData response to your framework? This way we won't have to develop a UI screen by ourselves to display the response messages.

Thanks, Mainak

marianfoo commented 8 months ago

I fixed this and updated the docs https://docs.spreadsheet-importer.com/pages/Events/#example-2 coming with version 0.31.4