RelatedEntities exclude is not working for multiple properties

Hi,

i tried to create an relatedEntities component that excludes more than one property, but unfortunately when acting like described in the docs:

The exclude attribute enables excluding some of the related entities from the drop-down list. The value of the property is a list of reference attributes of the current entity, separated by commas.

No property is excluded at all.
Here’s an example:

Order → Customer
Order → City
Order → State

In the orders table i have the following relatedEntities component:


<relatedEntities exclude="city,state"
                 for="ordersTable"/>

The result is, that i can select all three attributes: “customer”, “city”, “state”.

I found that in the WebRelatedEntities a regex match is executed, but i’m not sure what to write down in the exclude attribute so that it will exclude city as well as state.

Attached you’ll find the example project.

Bye,
Mario

cuba-example-related-entities-exclude.zip (48.7K)

Hi Mario,

you can exclude two or more properties using regexp value of exclude:


<relatedEntities exclude="city|state"
                 for="ordersTable"/>

I think it is the incorrect description of “exclude” attribute in our documentation, we will fix it shortly.

Hi,
thanks for the hint. Can you give me a regex that says: exclude all but customer? I didn’t get it working (i’m pretty bad at regex, so…)

Bye,
Mario

As far as I know, you can use this tricky regex: ^(?!customer$).*$

thanks - I’ll give it a try. To give you an idea behind this somewhat weird question - here are the “five why’s”:

  1. I actually want to declare the other form: includes: “customer”
  2. The reason for that is that i actually want a shortcut for one of the associations
  3. The reason for this is, that the “related” button is too generic (for a lot of non-CS based people). Instead i would like to give the people a direct button to jump directly to one of the relations that has a specific icon & specific description - and i additionally want to reuse the feature of related entities

To achieve 3. i ended up with the following somewhat strange solution:

  • i created a button (id=“specificBtn”) with a specific icon and description
  • i created the related entites component with visible=false
  • i searched for the right action from the WebRelatedEntities component instance and set the action for the “specificBtn” with the result of the search

This does the trick, but perhaps you might already know where this is going. Personally i find that the related entities component is a really, really cool feature. But unfortunately it does not have a straight API so that it is easy to create a custom UI so that it is useable in other ways. One way is the described above, another one i wrote down here: Using related Entities component in editor - CUBA.Platform

Perhaps this is a good input for you to think about generalize this cool feature.

Bye,
Mario

Thank you for this feedback,
we will try to improve API of RelatedEntities and RelatedAction to give you ability to use it in custom windows.

Hi Yuriy,

is there any related youtrack issue on that improvement? Or information about the implementation? That would be great.

Bye
Mario

Hi,

See issue https://youtrack.cuba-platform.com/issue/PL-7938, the issue is scheduled for release 6.5.

:ticket: See the following issue in our bug tracker:

https://youtrack.cuba-platform.com/issue/PL-7938