iljapostnovs / VSCodeUI5Plugin

Visual Studio Code Extension for UI5 Development
Apache License 2.0
61 stars 6 forks source link

Feature request: Dynamically Generate ID for controls #357

Closed mateusz-matyjaszczyk closed 1 year ago

mateusz-matyjaszczyk commented 1 year ago

Describe the feature As we know SAP have KeyUser adaptation which can be turned on for on-prem apps as well as apps deployed to Workzone. To get this feature to work correctly we do need unique IDs on all controls within the project. I would like to request a feature that can dynamically generate IDs for the controls that does not have IDs yet. It would be great if we can somehow describe the pattern on how to generate it but default one could be something like: id="idViewNameControlType_ConsequtiveNumber" -> i.e. for a button in mainView it would be then "idMainViewButton_1", second button would have "idMainViewButton_2"

Additional context There is not really much I can add to if. If you have any questions or ideas, hints if this is achievable currently please let me know

iljapostnovs commented 1 year ago

Hi,

This is interesting one. I could add a VSCode preference entry with configurable id generation formula, because now there is id naming style linter. Default value for the preference entry would be e.g. id{MeaningAssumption}{Counter}{ControlName}, so the formula should match with linters idNamingPattern formula in order not to generate ids which will be not against the linter. {Counter} would be 0,1,2...n and it would be inserted only if such id already exists in view/fragment.

Another thing to discuss would be if Elements needs to have an id, or Controls only? E.g.

<Select>
  <c:Item/>
</Select>

Select is a Control, and Item is an Element, and I don't think that Item needs an id here.

mateusz-matyjaszczyk commented 1 year ago

I would also slight to the camp that Element doesn't need the id... nevertheless if you turn on flexEnabled on your project this is the error: CleanShot 2023-06-30 at 03 50 23 CleanShot 2023-06-30 at 03 50 34

which would imply that Element actually do need an ID. Maybe it would be a good idea to have a preference entry -> "generateIdsForElements" as a boolean.

iljapostnovs commented 1 year ago

Hmm, okay, noted. Sounds doable. I will try to implement it in v1.11.0/v1.12.0

iljapostnovs commented 1 year ago

Done. Please check.

mateusz-matyjaszczyk commented 1 year ago

Works fine. Thanks!