-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(forms): Add a new step to the import process to solve requirements issues #17996
base: main
Are you sure you want to change the base?
feat(forms): Add a new step to the import process to solve requirements issues #17996
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The UI looks great but I have some request on the technical side.
The idea (which I should have worded directly in the specifications, my bad) was to use the existing DatabaseMapper object to add the replacements items without having to modify the code of the serializer itself.
Something like that:
$serializer = new FormSerializer();
$mapper = new DatabaseMapper(Session::getActiveEntities());
+ $replacements = $request->request->all()["replacements"] ?? [];
+ foreach ($replacements as $replacement) {
+ $mapper->addMappedItem(...);
+ }
return $this->render("pages/admin/form/import/step4_execute.html.twig", [
'title' => __("Import results"),
'menu' => ['admin', Form::getType()],
'results' => $serializer->importFormsFromJson($json, $mapper),
]);
Unless there are some technical difficulties that I am missing, this solution would avoid needing to modify the serializer methods as we reuse the data mapper parameter that was made for this use case (I hope there are no tricky edge case that would make it impossible).
If this kind of solution can work, it will make the code much simpler :)
3aef9e6
to
9ade69a
Compare
9ade69a
to
33b3e74
Compare
33b3e74
to
9aa9f95
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the removal of a form, there are two issues:
- We are searching on the form name
- We are editing the JSON
Searching on the form name may be dangerous as it is not guaranteed to be unique.
Maybe we should include some kind of unique ID for each forms into the export instead ?
Then we can exclude form using this id instead of the name.
I'd also like to avoid editing the JSON if possible.
An hidden input with the ids of the ignored forms would be simpler IMO.
Then the serializer can know that the form is ignored and we can display it on the report (Status -> 'Ignored' or 'skipped').
Checklist before requesting a review
Please delete options that are not relevant.
Description