jmix-framework / jmix

Jmix framework
https://www.jmix.io
Apache License 2.0
692 stars 124 forks source link

DefaultGenerationStrategy generates MultiValuePicker for entity composition attribute #3708

Closed KremnevDmitry closed 1 month ago

KremnevDmitry commented 1 month ago

Environment

Jmix version: 2.3.999-SNAPSHOT

Bug Description

If you try to change a composition attribute using the DataGrid inline editor, a MultiValuePicker component with the MultiValueSelectAction and ValueClearAction actions will be generated.

In this case, when the ValueClearAction is executed, no change will occur. When clearing the value, the data context of the view will not change. The data context would change if EntityClearAction was used. See related issue: https://github.com/jmix-framework/jmix/issues/3709

Current Behavior

Only component presentation value changed.

Expected Behavior

The model value must be cleared.

glebfox commented 1 month ago

We have no other suitable component for composition collection attributes except MultiValuePicker, but EntityClearAction cannot be applied to it. Also, setting EntityClearAction makes no sense, see https://github.com/jmix-framework/jmix/issues/3709#issuecomment-2377285867.

As a solution, io.jmix.flowui.component.factory.AbstractComponentGenerationStrategy#createCollectionField won't create field for a composition attribute + added io.jmix.flowui.component.UiComponentsGenerator#generateOrNull method to call it in the DataGrid editor.

For QA: Check that no component is generated for DataGrid inline editor for composition collection attribute

SergeiAksenov2 commented 1 month ago

Tested on: Jmix version: 2.4.999-SNAPSHOT Jmix Studio plugin version: 2.4.SNAPSHOT6866-242 IntelliJ version: IntelliJ IDEA 2024.2.3 (Community Edition)