An error occurred while fetching the assigned milestone of the selected merge_request.
Issue #77: Fix update form route
close #77 (closed)
unassigned @sba16
- Author Owner
- With further analysis and tests (on front-end) it was discovered that back-end actually works; in a obscure, however, way. Keep in mind this is explained by a front-end perspective by a full stack dev.
1) The back-end has a file named diffHandler.ts that's used during the update of a form. What this file does is to add, remove, swap or reenable the inputs of a form. It also can change the form's title and description.
2) How does the functions on the file does that above: it works in a "smart" way. If a form needs to have title/description changed then it's simple: just change the title/description on the JSON that'll be sent to back-end.
3) The problem starts when you want to change properties of a input: the smart way means that it can recognize if an input was changed or not, but it's not so smart as one may think. What truly happens is: all the old and new inputs are stored, if there are any new inputs with THE SAME ID as one of the old inputs than THIS QUESTION PROPERTIES ARE NOT CHANGED. That means the new input, although it can have new properties, will be DISCARDED and the OLD ONE will remain in the form.
3.1) So, how does one changes inputs? If you send a JSON with altered properties and NO ID, that is undefined, then back-end will think that's a new input. Keep in mind that step 3) still happens, so if you wanna make that old input remain enabled on the form you got to send it AS WELL as the new one. What is important here is the IDs, a undefined ID will CREATE a new input, an defined ID will just keep the old inputs (please do not "guess" the ID of an old input or some bugs may happen).
4) Let us say now that one created a form with only one input, then wants to add a new input. The JSON would have to had the old input, with an ID, and the new one with the null ID. Now, if one wants to REMOVE the first input the JSON would have to had ONLY the SECOND INPUT WITH ID and NOT THE FIRST ONE.
5) Final note: basically if you want to CREATE an input you got to send it without an ID. If you want to DELETE an input you have to send the JSON without the input (simple as that). If you want to ADD an input you have to send the JSON with the old inputs and the new input WITHOUT ID.
assigned to @sba16
merged
mentioned in commit c5265494
- You're only seeing other activity in the feed. To add a comment, switch to one of the following options.
Please register or sign in to reply