Open olemartinorg opened 11 months ago
Relevant discussion with examples of readOnly
fields that should also 'reset' data back to prefill:
Relevant discussion about deleting uploaded files when the uploader itself has been hidden:
We could perhaps do that before we go to process/next
, i.e. while the user is waiting.
Relevant input, RemoveHiddenData also deletes data you don't want to remove. One example is a hidden id on a repeating group which doesn't provide any user value and hence is hidden, but should definitely be stored.
Relevant input, RemoveHiddenData also deletes data you don't want to remove. One example is a hidden id on a repeating group which doesn't provide any user value and hence is hidden, but should definitely be stored.
Yup, I believe that's covered by the first point: Reset the data back to what we originally got when loading the data model from the backend. Meaning, we only reset the changes the user made. The example here was a Dropdown that is always hidden, but used to display a text value in the repeating group table, and if that's always hidden (but maybe the backend sets data on the repeating group) there is no user changes for us to reset. However, if the user actually deletes the whole row, we have no choice to just tell the backend the user deleted the row (by removing it from the form data). If the app developer does not want it to be possible to delete entire rows, they must disable the delete button (which is already an option for repeating groups).
Removing fe-v4
label on this one, as it's not critical for that release.
Some additional information that we see in V4: If you set "Remove hidden data" to ON, hidden prefill-fields (with value) that are not shown in the app (visible to the user) will not appear in the XML sent in. This is a blocking issue I think.
@jhhssb Yes, that's a known issue with the current implementation (in the backend), and something we're planning to 'fix' with this suggestion to implement a solution (in the frontend instead). It's possible to work around the issue in apps, for example by duplicating data (when displayed in a purposely hidden component) or hiding the component using ruleHandler based ("older-style") dynamics (which the backend doesn't know about).
Jeg trudde den gamle dynamikken ikke var støttet i v4 @olemartinorg ?
Den er fortsatt støtta - og vi har ingen konkrete planer om å fjerne støtten enda (men heller ikke særlig med forbedringer, utenom at helper-objektene i RuleHandler.js nå er valgfri i v4).
Relevant (eksempel på noe som kan automatisk testes):
Dette temaet er også diskutert her:
Det ser foreløpig ut til at retningen vi ønsker å gå er å fikse på oppryddingen i datamodellen vi allerede har på backend, gjøre den raskere, og tilby en metode for at backend gjør den jobben for hver lagring - samt kjører validering basert på en ferdig rydda modell. Dette ble diskutert litt i et møte vi hadde med SSB i dag, og det ble tatt opp følgende punkter:
displayValue
. Ikke at det sikkert er kjempelurt i utgangspunktet, men siden nye uttrykksfunksjoner og komponenttyper oftest blir tilgjengelig i frontend først, betyr det jo også at man må begrense bruken av ny funksjonalitet (iallefall for hidden-uttrykk) om sletting av skjult data på backend skal brukes.component
-oppslag alltid returnerer null
dersom komponenten er skjult. Den begrensningen er nødvendigvis litt kunstig dersom uttrykkene jobber med en datamodell hvor skjult data allerede er borte (eller tilbakestillt). Et "nyttig" triks som har blitt ønsket brukt er f.eks. å sette opp en komponent som alltid skjules, mens som bare er tenkt brukt til å hente ut en verdi (enten med component
eller displayValue
, som begge bare gir null
når komponenten er skjult). Se #1669 og #1179
Description
The backend already has
RemoveHiddenDataPreview
, but this feature should be moved toapp-frontend-react
instead, and enhanced with a few improvements.When the last known component bound to a path in the data model is hidden, we should:
ProcessDataWrite
, as they will either be re-applied or they'll possibly leave unwanted side-effects.To demonstrate the point of this functionality, let's say pretend we have this form:
And the data model looks something like this:
In this example, the repeating group in the UI is using the
hiddenRow
functionality to only show rows ofSF_type = pet
(SF
in this context means shadow field). Let's pretend this persons children are fetched from official and reliable sources, but the pets are added manually (and are not verified). Verification and other shadow fields are added byProcessDataWrite
.As soon as the user changes their selection to "No" for having pets, app-fronted-react should remove the two pets from the data model, and revert the data model to the original state (i.e. removing the shadow fields along with the pets if they were added by
ProcessDataWrite
, or, if the rows were already present in the data model when we loaded it, just remove the values the user typed in, along with the ones we got from the backend). And if the user changes their selection back to "Yes", the pets should re-appear as if nothing happened.The purpose of this feature is to make it possible to use hiding of components to make the form more dynamic, without having to worry about the data model getting out of sync with the UI. It is useful for validation, as validation code can make some more assumptions about the data model being in a somewhat valid state (i.e. not having pets when the user says they don't have pets), and it also becomes a privacy feature as the user can hide data they don't want to share with the receiver of the form.
Additional Information