ui5-community / generator-ui5-project

Generator for UI5-based web-apps which use the official UI5 tooling and support multiple deployment targets such as the SAP Business Technology Platform
Apache License 2.0
33 stars 25 forks source link

easy-ui5 is not using the BaseController #20

Closed lboehm closed 2 years ago

lboehm commented 2 years ago

Hi,

easy-ui5 is generating a MainView.controller.js and a BaseController.js. But the BaseController.js is not used by the MainView.controller.js, so I have to change MainView.controller.js manually to make use of the BaseController.js.

Easy-Ui5 version:

C:\Users\A002220>yo easy-ui5 --plugins
Node.js: v14.16.1
home: C:\Users\*****\AppData\Roaming\npm\node_modules\generator-easy-ui5\
yeoman-environment: 3.8.1
generator-ui5-project: 0.1.0

OS/version:

Windows 10

Steps to reproduce the problem:

Generate a project like this:

? Select your generator? generator-ui5-project
? What do you want to do? Create a new OpenUI5/SAPUI5 project                          [app]
? How do you want to name this project? myUI5App
? Which namespace do you want to use? com.myorg
? On which platform would you like to host the application? SAP NetWeaver
? Which view type do you want to use? XML
? Where should your UI5 libs be served from? Content delivery network (SAPUI5)
? Would you like to create a new directory for the project? No
? Would you like to add JavaScript code assist libraries to the project? No

What is the expected result?

I would expect the MainView.controller.js to use the BaseController.js.

What happens instead?

Instead MainView.controller.js uses sap/ui/core/mvc/Controller:

sap.ui.define(
  ["sap/ui/core/mvc/Controller"],
  /**
   * @param {typeof sap.ui.core.mvc.Controller} Controller
   */
  function (Controller) {
    "use strict";

    return Controller.extend("com.myorg.myUI5App.controller.MainView", {
      onInit: function () {},
    });
  }
);

Thanks & Best regards, Lukas

lboehm commented 2 years ago

Hi @IObert,

i have found another problem that is related to this: When generating a new view, the new generated view is using the BaseController as expected. But the BaseController, that is generated when the whole project is generated, has a reference to webapp/model/formatter which doesn't exist:

sap.ui.define(
    [
        "sap/ui/core/mvc/Controller",
        "sap/ui/core/routing/History",
        "sap/ui/core/UIComponent",
        "com/myorg/myUI5App/model/formatter"
    ],
...

When trying to display the newly generated view the browser console shows this error:

Uncaught (in promise) ModuleError: Failed to resolve dependencies of 'com/myorg/myUI5App/controller/DetailView.controller.js'
 -> 'com/myorg/myUI5App/controller/BaseController.js'
  -> 'com/myorg/myUI5App/model/formatter.js': failed to load 'com/myorg/myUI5App/model/formatter.js' from ./model/formatter.js: script load error

EDIT 05.12.2021 / 2pm

Again, I did some reseach as I wanted to fix at least the issue for the missing formatter.js. Unfortunately this seems to be associated with @sap-ux/fiori-freestyle-writer as well.

The files, where the text created is blue, are created by @sap-ux/fiori-freestyle-writer, correct? If yes, I would assume, the directory /webapp/model comes from @sap-ux/fiori-freestyle-writer and there's no formatter.js.

image

Easy way would be to just remove the reference to formatter.js in the BaseController.js. But the formatter.js is quite useful, so I think that this is not the solution.


BR, Lukas

lboehm commented 2 years ago

It's me again - sorry for spamming 😃

I did some research, because I wanted to provide a pull request. I think the issue is, that generator-ui5-project uses @sap-ux/fiori-freestyle-writer and this package doesn't know anything of the BaseController.js. And the open source community can't help to fix this issue, as `@sap-ux packages are closed source, right?

Does anybody have an idea how to solve that problem?

IObert commented 2 years ago

Yep, I immediately expected that this came with the @sap-ux/fiori-freestyle-writer when you mentioned this. I'll include @vobu here as there is already another issue with this package integration. WDYT?

vobu commented 2 years ago

yep, on my list.