| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
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? |
Sorry, something went wrong.
|
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? |
Sorry, something went wrong.
|
It is also possible to update fields from the fields plugin during ticket update. PUT {{URL_GLPI}} /Ticket/5 |
Sorry, something went wrong.
|
Yes, it works Just include the block ID in the field name, like: |
Sorry, something went wrong.
|
Hello, do you have time to review the PR ? |
Sorry, something went wrong.
|
I applied the changes for PHPStan 🤞 |
Sorry, something went wrong.
|
I don't understand @trasher With php 7.4 : |
Sorry, something went wrong.
|
A syntax error, it was slipped in after applying the suggestion 😅 |
Sorry, something went wrong.
|
Are we good this time ? 😅🤞 |
Sorry, something went wrong.
|
Hi, what's the next step ? |
Sorry, something went wrong.
|
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 findContainers
Unit Tests for Hooks
Unit Tests for populateData
Unit Tests for showForTab
Unit Tests for API
Unit Tests for rights |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
|
Hi, @JeremieMercier. Edit: I've done some research and found Postman, as a tool to send HTTP requests and creating API tests |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
|
Hello, |
Sorry, something went wrong.
Hello @CorentinS6, From my side everything seems good, it remains to be seen if a developer of the project can finalize the tests |
Sorry, something went wrong.
|
And code generated by AI ? |
Sorry, something went wrong.
Hello, All the logic is 100% mine, however for the tests, it's another story, I used AI to learn and understand the use of the tests in addition to videos like this one from Grafikart, but as I said, I'm not an expert..., the tests can also be redone by a more competent person if necessary knowing that basically, there were no tests set up on the plugin. |
Sorry, something went wrong.
|
@stonebuzz , is this work good enough for the merge now? |
Sorry, something went wrong.
|
This will be very useful, now I can only add one block to all entities, I need one per entity and this seems to solve the problem, is there something I can help with? |
Sorry, something went wrong.
|
Hi, |
Sorry, something went wrong.
Provide the ability to define multiple 'dom' blocks for the same item
based on its entity.
- New PluginFieldsContainer::findContainers() returning all active 'dom'
containers applicable to an item and its entity (with parent entity
handling via getAncestorsOf(), recursivity and profile rights checks).
- Hooks (pre_item_add, pre_item_update, post_item_add) handle multiple
containers through the _plugin_fields_data_multi array.
- populateData() extracts input values from per-container prefixed keys
(plugin_fields_{container_id}_...), with fallback to unprefixed keys.
- fields.html.twig prefixes input names with the container id.
- container.form.php strips the container prefix before calling
updateFieldsValues(), enabling domtab containers saving.
- showForTab() renders every applicable container, each with its own
scoped refresh script.
- Add PHPUnit coverage: findContainers (subtypes, entity recursion),
multi-container hooks, populateData prefix and multi-selection
handling, showForTab display and rights.
Closes pluginsGLPI#744, pluginsGLPI#789, pluginsGLPI#834
|
I originally opened this PR because it was an internal feature request for how we use the GLPI plugin. In the end, we managed without it, so I kind of let it drop especially with the commit lag and conflicts to deal with. Anyway, I've decided to pick it back up: even though we don't need the feature ourselves anymore, it could still be useful to others since it's quite heavily requested ^^ |
Sorry, something went wrong.
There was a problem hiding this comment.
Several errors in the CI
Sorry, something went wrong.
- populateData(): accept bare field names (API/external callers) as fallback of the new prefixed input names - populateData(): treat null input values as not provided (isset semantics), fixes SQL error on empty dropdown submitted from a form destination - preItem(): restore explicit c_id support (tab forms, form destinations) - findContainers(): JSON-encode itemtype for JSON_CONTAINS to support namespaced itemtypes on strict MySQL - richtext companion inputs stored under the column-based key expected by addRichTextFiles() - tests: multiple dom containers per itemtype are now expected to be allowed - tests: do not leak $_REQUEST['massiveaction'] between test files
…m-blocks # Conflicts: # CHANGELOG.md
| Back | FazBrowse Home | New Git URL |
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