spreadsheetimporter / ui5-cc-spreadsheetimporter

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

[Bug]: Adaptation Project Sample #513

Closed MARCxGAMBIT closed 3 months ago

MARCxGAMBIT commented 4 months ago

OData Version

OData V2

Draft

Yes

Scenario

Fiori Adaptation Project

Environment

VSCode

UI5 Spreadsheet Component

0.33.1

What happened?

I was not able to run

https://github.com/spreadsheetimporter/sample-adaptation-banks

and I was not able to add the control to my own adaptation according to the steps in this blog

https://community.sap.com/t5/technology-blogs-by-members/how-to-add-excel-upload-to-any-standard-sap-fiori-app-tutorial-with-app/ba-p/13578225.

The control is being loaded from ../resources.

Uncaught (in promise) ModuleError: failed to load 'cc/spreadsheetimporter/v0_33_1/Component.js' from ../resources/cc/spreadsheetimporter/v0_33_1/Component.js: script load error
    at se (http://localhost:8082/resources/sap-ui-core.js:10:7148)
    at ne.failWith (http://localhost:8082/resources/sap-ui-core.js:10:4989)
    at HTMLScriptElement.i (http://localhost:8082/resources/sap-ui-core.js:10:10946)
Caused by: Error: script load error
    at HTMLScriptElement.i (http://localhost:8082/resources/sap-ui-core.js:10:10988)

To fix it I had to hardcode the path

const oComponent = this.base.getView().getController().getOwnerComponent();
oComponent.runAsOwner(async () => {
    this.spreadsheetUpload = await Component.create({
        usage: "customer.spreadsheetImporter",
        async: true,
        componentData: {
            context: this,
            fieldMatchType: "label",
            createActiveEntity: true,
        },
        url: "/sap/bc/ui5_ui5/sap/Z_XUP_v0_33_1",
        name: "cc.spreadsheetimporter.v0_33_1"
    });
    this.spreadsheetUpload.openSpreadsheetUploadDialog();
    this.getView().setBusy(false);
});

Do you know if there is a better way to tell the app where the control should be loaded from?

Relevant log output

Uncaught (in promise) ModuleError: failed to load 'cc/spreadsheetimporter/v0_33_1/Component.js' from ../resources/cc/spreadsheetimporter/v0_33_1/Component.js: script load error
    at se (http://localhost:8082/resources/sap-ui-core.js:10:7148)
    at ne.failWith (http://localhost:8082/resources/sap-ui-core.js:10:4989)
    at HTMLScriptElement.i (http://localhost:8082/resources/sap-ui-core.js:10:10946)
Caused by: Error: script load error
    at HTMLScriptElement.i (http://localhost:8082/resources/sap-ui-core.js:10:10988)

Spreadsheet Component Init

Not working:


const spreadsheetUploadComponent = await this.base.getView().getController().getOwnerComponent().createComponent({
    usage: "customer.spreadsheetImporter",
    async: true,
    componentData: {
        context: this,
        fieldMatchType: "label",
        createActiveEntity: true,
    }
})
spreadsheetUploadComponent.openSpreadsheetUploadDialog();

Manifest

{
  "fileName": "id_1710140995700",
  "namespace": "apps/cus.sd.custmat.manage/appVariants/customer.cus.sd.custmat.manage/changes",
  "layer": "CUSTOMER_BASE",
  "fileType": "change",
  "creation": "2024-03-11T07:09:55.700Z",
  "packageName": "$TMP",
  "reference": "customer.cus.sd.custmat.manage",
  "support": {
    "generator": "add-sapui5-component-usage-generator"
  },
  "changeType": "appdescr_ui5_addComponentUsages",
  "content": {
    "componentUsages": {
      "customer.spreadsheetImporter": {
        "name": "cc.spreadsheetimporter.v0_33_1",
        "lazy": false,
        "settings": {},
        "componentData": {}
      }
    }
  }
}
marianfoo commented 4 months ago

You wrote Environment: VSCode. Did you try to deploy it? I think i can remember that it did not work there but when i deployed it it worked. Your workaround should also work when deployed.

marianfoo commented 4 months ago

Well, i wrote in the blog post that the preview works :/ So i dont know the reason exactly, but it maybe works in BAS?

marianfoo commented 3 months ago

Hi @MARCxGAMBIT can i still help you here? Currently dont have a system to try adaption project.

MARCxGAMBIT commented 3 months ago

My workaround works locally and deployed so it's all good for me. It's more of an FYI for you to maybe update your samples.

marianfoo commented 3 months ago

Yes, thank you. I've only had one try with the adaptions so far. There are still a few special features with the use of components. There is currently still an open SAP ticket for this, so I need to improve the documentation. Unfortunately, none of this has anything to do with my specific component, but with the general handling of resue components in the SAP system.

I will leave the issue open until I have improved the documentation.