This fixes an issue where clicking quickly on several "Remove row"
buttons on a repetition field results in autosave errors.
This is because the N+1 autosave request is correctly sent after the
Nth response from the server, but _before_ the row element is actually
removed from the DOM. So the N+1 request actually sends the fields for
the deleted row, which makes the server raise an error.
With this fix, the row gets properly removed when the server responds,
and before the next request is started.
Before, when autosaving a draft, removing a repetition row would
send `_destroy` inputs to the controller – but not remove the row
from the DOM. This led to the `_destroy` inputs being sent again
on the next autosave request, which made the controller raise
(because the row fields were already deleted before).
To fix this, we let the controller response remove the deleted
row(s) from the DOM.
Doing it using a controller response avoids the need to keep track
of operations on the Javascript side: the controller can easily
know which row was just deleted, and emit the relevant changes for
the DOM. This keeps the autosave requests robust: even if a request
is skipped (e.g. because of a network interruption), the next request
will still contain the relevant informations to succeed, and not let the
form in an unstable state.
Fix#5470
After clicking on a radio button option, it is impossible to revert to
the "None of the values selected" state.
However on non-mandatory fields, reverting to the no-selection value
should be possible.
To fix this, add an explicit "N/A" option.
Rails : les relations `belongs_to` sont maintenant requises par défaut. (Pour une relation optionnelle, mentionner explicitement `belongs_to :table, optional: true`)
- Make `type_de_champ.procedure` a requirement;
- Move the procedure_id assignation to `before_validation` (otherwise
the record is invalid, and never gets saved);
- Make `champ.dossier` a requirement;
- Move the dossier_id assignation to `before_validation` (otherwise
the record is invalid, and never gets saved);
- Allow specs to only build the champ (instead of saving it to the
database), which bypasses the requirement to have a dossier.
Rationale:
- `lib/` is supposed to contain code mostly independant from Rails;
- By default, Rails doesn't eager-load `lib/` anymore (this used to be
the case, but since a few releases).
If this commits triggers some errors, then these errors should be fixed
(rather that `lib/` being added again to the load path).