Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow feature moveControllerPropsToOnInit to be overriden with a local annotation, per declaration #116

Open
GuillaumedesPommareSAP opened this issue Sep 20, 2023 · 0 comments

Comments

@GuillaumedesPommareSAP
Copy link
Contributor

Hello,

In our projects we always activate the feature moveControllerPropsToOnInit=true so that controls are assigned in onInit function time so that their programmatic configuration is possible.

But some UI5 patterns, like formatters in our case, would require an exception. A formatter pattern as UI5 expects it is defined in a formatter variable defined in the controller. Of course they are other ways of defining it, but this is one of the most convenient, a lot more than core:require of functions. In TypeScript, this would look like :

@namespace("ccCockpit.tree.node.comparator.timeSlot.controller")
export default class ElseController extends DisplayBaseController {

    public formatter = {
        formatElseMessageStrip
    };

    constructor(name: string | object[]) {
        super(name);
    }
}

Control in View:
<MessageStrip text="{parts: ['Node>/property/key', {value: 'valueCategory_i18n'}], formatter: '.formatter.formatElseMessageStrip'}" />

Issue: doing so is most probably the better way of writing a formatter, it is aligned with UI5 coding conventions, samples ... but assignment code is moved to onInit and it looks to be late for UI5 binding when creating the control, and formatter remains undefined in the control's binding

So maybe a feature like:

   @movePropsToConstructor
    public formatter = {
        formatElseMessageStrip
    };

Could help in such situation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant