openui5 icon indicating copy to clipboard operation
openui5 copied to clipboard

Missing typedef for `sap.m.Token.data()`

Open neoruien opened this issue 1 year ago • 2 comments

SAPUI5 version: 1.123.2 (though we will be upgrading to 1.127.7 soon)

sap.ui.comp.valuehelpdialog.ValueHelpDialog.setTokens

I read the description of ValueHelpDialog.setTokens() and I realised that sap.m.Token has a data() method for getting Value Help rangeKeyFields information.

sap.m.Token

However, the sap.m.Token.data() method was not documented. It seems to have 2 parameters: a string parameter and an object parameter of shape { exclude: boolean, operation: sap.ui.comp.valuehelpdialog.ValueHelpRangeOperation, keyField: string, value1: any, value2: any }.

I request documentation of the sap.m.Token.data() method, including the various options for the string parameter and a TypeScript interface for the object parameter.


Screenshot: Image

neoruien avatar Feb 21 '25 06:02 neoruien

Hello @neoruien,

The .data() method is part of the jQuery library and is a way to assign internally some properties to the tokens inside a ValueHelpDialog. The data is assigned to the tokens for operations related to range tokens. It is not intended to be used from the outside neither this method is part of the class public API.

You can explain in more detail what you want to achieve so we can help you with other approaches.

Kind regards, Nikoleta

nikoletavnv avatar Feb 22 '25 12:02 nikoletavnv

Hello @nikoletavnv,

I wish to convert the range tokens into filters.

tokens
      .map((token) => token.data('range') as TokenRangeProperties)
      .map((properties) => new Filter({
            path: properties.keyField,
            operator: properties.operation,
            value1: properties.value1
      }));

Note that I created a custom type TokenRangeProperties as I am using Typescript. I defined it with this shape:

{
      exclude: boolean,
      operation: sap.ui.model.FilterOperator,
      keyField: string,
      value1: unknown,
      value2: unknown
}

neoruien avatar Feb 25 '25 15:02 neoruien