SAP / openui5

OpenUI5 lets you build enterprise-ready web applications, responsive to all devices, running on almost any browser of your choice.
http://openui5.org
Apache License 2.0
2.95k stars 1.24k forks source link

StandardTile set ID #1252

Closed ghost closed 7 years ago

ghost commented 7 years ago

Hi all

Please allow to set on StandardTile an Identification, because it is easier to handle, which Tile was clicked, for example:

<StandardTile
          icon="sap-icon://{launch>icon}"
          title="{launch>title}"
          press="handleTilePress"
          />

Now I can handle only over icon request:

handleTilePress: function (oEvent) {
      var oTile = oEvent.getSource();
      var sIcon = oTile.getIcon()
      /*switch (oTile.getIcon()) {
      }*/
      console.log(oTile.getIcon());
    }

But over an identification is more elegant.

Thanks

akudev commented 7 years ago

What about

<StandardTile
          id="tile1"
          icon="sap-icon://{launch>icon}"
          title="{launch>title}"
          press="handleTilePress"
          />

and

handleTilePress: function (oEvent) {
      var oTile = oEvent.getSource();
      /*switch (oTile.getId()) {
      }*/
      console.log(oTile.getId());
    }

?

Regards Andreas

ghost commented 7 years ago

It will generate automatically id property? When you look at https://openui5.hana.ondemand.com/1.40.3/docs/api/symbols/sap.m.StandardTile.html#constructor I can not find any id property

Thanks

ghost commented 7 years ago

My TileContainer looks like:

          <TileContainer
        id="apps"
        tiles="{launch>/Tiles}">
      <StandardTile
          id="{launch>id}"
          icon="sap-icon://{launch>icon}"
          title="{launch>title}"
          press="handleTilePress"
          />
    </TileContainer>

As you can see, the TileContainer is bound on datasource that looks as follow:

{
  "Tiles": [
    {
      "id": "calendar",
      "icon": "calendar",
      "title": "Assign user calendar"
    },
    {
      "id": "characteristics",
      "icon": "activity-individual",
      "title": "Assign inspection characteristics"
    },
    {
      "id": "terminal",
      "icon": "laptop",
      "title": "Assign terminal"
    },
    {
      "id": "inspection",
      "icon": "approvals",
      "title": "Assign inspection value"
    }
  ]
}

I've got following error: 09-12-_2016_09-39-53

Thanks

codeworrior commented 7 years ago

It is not possible to bind the "id" property, it can only be declared with a static (hardcoded) value, so it is no solution for your problem. But you might add custom data:

<StandardTile xmlns:z="http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1"
          z:myid="{launch>id}"
          icon="sap-icon://{launch>icon}"
          title="{launch>title}"
          press="handleTilePress"
          />

At runtime, you can access custom data with

   oEvent.getSource().data("myid")

Reg. documentation: properties are documented with the class that introduces them. Documentation for StandardTile therefore contains the hint

In addition, all settings applicable to the base type sap.m.Tile can be used as well.

sap.m.Tile then points to Control, Control to Element and Element to ManagedObject. That maybe not optimal when searching for properties, but adding all inherited stuff would make the documentation even more verbose and noisy than it is already. We are working on that and will improve it.

ghost commented 7 years ago

@codeworrior How do you know that? I was searching everywhere. Thanks so much.

ShtiliyanUzunov commented 7 years ago

Here you can see the documentation for custom data: https://openui5.hana.ondemand.com/#docs/guide/91f0c3ee6f4d1014b6dd926db0e91070.html

RobertoMalatesta commented 7 years ago

Hi @codeworrior : @kostonstyle 's issue is one of the symptoms of the fact thet #UI5 documentation lacks programmatic documentation and examples. I opened a general issue #1254 since it is a serious drawback for the whole platform.

Just my 2 EuroCents.

--R

codeworrior commented 7 years ago

I'm a friend of the programmatic documentation (parents should try to be a friend to their children, shouldn't they?). But don't you think that the Explored App can help developers to a similar extend?

I understand that the easy editing + run in a single page is missing. But on the other hand, the samples can be much more complex now and closer to a real world scenario (they can consist of multiple files likes views + controllers, components + manifest, Opa tests, mock data etc.). And there is a rich set of those examples.

Personally, I sometimes miss the explanatory texts - if they are not added as comments in the sample sources.

AFAIK, the colleagues responsible for documentation did interviews with different user groups and as a result decided to focus on the Explored App and to abandon (deprecate) the old, single page programmatic documentation. This decision was surely taken under the impression, that the Explored App can give the same or even better benefit to developers.

I assume that the colleagues are highly interested in feedback to the samples and to the Explored App in general. Maybe you (and others) want to add such feedback to #1254.

Kind Regards, Frank

RobertoMalatesta commented 7 years ago

A small quick note to say thanks @codeworrior . I addressed my note to you since I noted that you care about UI5. Expect a more detailed message in the days to come.

--R