Be able to markup fields that have been updated

:slight_smile:
We want to be able to visually see what fields have been changed (values !=) since the last “commit”
For us, we have 3 Json datas:
-The last commit,

  • the last saved (we have kind of auto save feature to refill the initial data in case of interrupted completion of the form)
  • and the current datas.
    What is the good way to do this?
    Should we keep the previous value in the datajson? In this case how to access it?
    Or should we track onchanges ? If yes, how to had the new data to json and reuse it?
    Or should we use the last commit Json to compare it to the current one in a custom renderer ? If yes, how …?

Thx!

[precision : we can’t use schema default for that… only jsons data…]

Hi @clysss
There are no mechanisms in JsonForms to automatically track changes compared to a previous state or get the previous data in a renderer.
Thus, you need a custom renderer set that can show the diff inline.

I think there are two ways to track the old data/changes.
You can either keep the previous data that you get from the onChange or you could add a middleware to track the actual changes. Personally, I wouldn’t keep the old values in the data itself.

Assuming you use React, you can use a custom React Context to pass down either the previous data or the change information to your custom renderers.

Best regards,
Lucas

Thanks Lucas,
We’ll use the 2nd option
It’s better to use context than jsonforms config ?

Hi @clysss,

At the moment the config serves as the default options for each renderer and is therefore consumed in all of them. Any change to the config object will therefore rerender the whole form. When you use React context instead, then only the consuming components will rerender.

Whether that is relevant for you depends on your use cases.