-
Notifications
You must be signed in to change notification settings - Fork 71
[Feature] Allow multiple "Insertion in the form" (dom) blocks per entity #941
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
base: main
Are you sure you want to change the base?
[Feature] Allow multiple "Insertion in the form" (dom) blocks per entity #941
Conversation
I am questioning the plugin's ability to reconcile the correct container during API calls, an issue we have encountered in the past. For example, when updating a ticket and including the "fields" in the payload, could you verify this point? |
Hi @stonebuzz, I retrieve the block row ID like this: Then, I update the field using the following method: So I haven’t encountered any issue with the API — unless I misunderstood how you're updating the fields via the API? |
It is also possible to update fields from the fields plugin during ticket update.
|
Hello, do you have time to review the PR ? |
I applied the changes for PHPStan 🤞 |
I don't understand @trasher With php 7.4 : |
A syntax error, it was slipped in after applying the suggestion 😅 |
Are we good this time ? 😅🤞 |
Hi, what's the next step ? |
The feature you are proposing is substantial and introduces significant changes. To ensure its smooth integration and functionality, we must be extremely vigilant. This means we need to "lock down" our testing to guarantee that everything works as expected. It is important to acknowledge that the plugin is already complex to maintain, especially with the new features introduced in GLPI. Given this complexity, we must approach any additional features with caution to ensure they do not further complicate maintenance and support. To ensure the proper functioning of this PR, here is a concise list of unit tests that should be added: Unit Tests for
|
Hi @stonebuzz Thanks for the message I fully understand the concerns and the importance of thorough testing. While working on the tests already partially in place, I’ve been able to identify and fix some issues especially related to "dropdown" field handling and container restriction management. I’ll keep updating here as I progress. |
Hi, @JeremieMercier. Edit: I've done some research and found Postman, as a tool to send HTTP requests and creating API tests |
I’ve added all the requested unit tests (except the API ones):
Please note I’m not a testing expert, so the tests may not follow every usual best practice. Feel free to share any feedback so I can improve. The API tests still need to be written by whoever is willing to tackle them. |
9090d78
to
536a7cf
Compare
Created a new method findContainers() (based on findContainer()) that returns all 'dom' containers for an item based on its entity (with parent entity handling via getAncestorsOf()). Adapted hooks (pre_item_add, pre_item_update, post_item_add, post_item_update) to manage multiple containers using the _plugin_fields_data_multi array. Updated the populateData() function to extract input values by stripping the prefix, ensuring that data is saved into the correct columns of the injection table. Modified the container.form.php file to "clean" the form data (by removing the prefix) before calling updateFieldsValues(), thereby enabling the saving of domtab containers. This PR provides the ability to define multiple "Insertion in the form" blocks for the same item based on its entity by leveraging the new findContainers() method and adapting the save process.
…oving the prefix) before calling updateFieldsValues(), thereby enabling the saving of domtab containers.
- Added missing @var annotation for global $DB - Replaced empty() on $entityIds with count() - Removed redundant is_array() check on $entityRestriction - Simplified isset() condition by removing unnecessary !== null check
Note: PHPStan still reports a type error on DB::request() (expects array<string>|string), but this issue already exists elsewhere in the file and was not introduced by this change.
update: showForTab method fix: dropdown field
• New phpunit.xml and bootstrap for the Fields plugin • PluginFieldsContainerTest covers: - Creating / reading containers - Filtering containers by entity, subtype, recursion - Hooks: preItem, postItemAdd, preItemUpdate - populateData (single + multi-dropdown) - showForTab rendering and rights checks
051fcd8
to
cf0f71f
Compare
This PR provides the ability to define multiple "Insertion in the form" blocks for the same item based on its entity
Please test these modifications and verify that everything works as expected for all object types supported by the Fields plugin. Note that my tests were successful, although I focused exclusively on 'Ticket' type objects for my use case.
Checklist before requesting a review
Please delete options that are not relevant.
Issues : #744, #789, #834