Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ccailly
Copy link
Member

@ccailly ccailly commented Oct 2, 2024

Checklist before requesting a review

Please delete options that are not relevant.

  • I have read the CONTRIBUTING document.
  • I have performed a self-review of my code.
  • I have added tests that prove my fix is effective or that my feature works.

Description

  • Add a new step when importing a form to reconcile objects not available on the GLPI where the form will be imported.
  • Add an action to remove a form from the import list.

image
image
image

@ccailly ccailly self-assigned this Oct 2, 2024
@ccailly ccailly added the Forms label Oct 2, 2024
@ccailly ccailly added this to the 11.0.0 milestone Oct 2, 2024
Copy link
Contributor

@AdrienClairembault AdrienClairembault left a 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 :)

@ccailly ccailly force-pushed the feature/form-import-resolve-issues branch from 3aef9e6 to 9ade69a Compare October 9, 2024 15:23
@ccailly ccailly force-pushed the feature/form-import-resolve-issues branch from 9ade69a to 33b3e74 Compare October 14, 2024 10:15
@ccailly ccailly force-pushed the feature/form-import-resolve-issues branch from 33b3e74 to 9aa9f95 Compare October 16, 2024 07:16
Copy link
Contributor

@AdrienClairembault AdrienClairembault left a 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').

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants