jsonforms icon indicating copy to clipboard operation
jsonforms copied to clipboard

empty data property

Open zeroamps opened this issue 3 years ago • 3 comments

Is your feature request related to a problem? Please describe.

Hi, I'd like to be able configure that If I remove some text from a control the property for that control is removed from the data object.

before editing this.data = {} some text this.data = { name: "sometext" } after removing the text from the control it stays like this this.data = { name: "" }

I'd like to have some option to tell please delete this property from an object if it's empty.

The same problem is with arrays If I delete the last item from an array it stays like this this.data = { items: [] }

Describe the solution you'd like

To have an option which tells delete or not delete an empty property from an object.

Describe alternatives you've considered

I have to do that manfully in my code at the moment.

Framework

Angular

RendererSet

Material

Additional context

No response

zeroamps avatar Apr 23 '22 05:04 zeroamps

Hi @zeroamps,

I think this definitely makes sense. String controls could just always remove their entry. For arrays this would be easy to support with an UI Schema option removeWhenEmpty which is false by default. However I'm wondering what the best way would be for objects.

sdirix avatar May 03 '22 14:05 sdirix

Do you want to contribute this for the Angular renderers?

sdirix avatar May 03 '22 14:05 sdirix

String attributes are now removed with https://github.com/eclipsesource/jsonforms/pull/1984

sdirix avatar Jul 25 '22 10:07 sdirix