Skip to content

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

@GuillaumedesPommareSAP

Description

@GuillaumedesPommareSAP

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions