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

New feature : advanced options for interactions with the plugin fields #104

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

Conversation

ArthurMinfotel
Copy link
Contributor

Replace the option raz_plugin_fields by a new option : action_plugin_fields.

The available values for this option depend on the model's type :

Uninstall : do nothing (equivalent of 0 for raz_plugin_fields), blank (equivalent of 1 for raz_plugin_fields), advanced options.
Replace : do nothing (equivalent of 0 for raz_plugin_fields), copy (will copy all values in additional fields of olditem to newitem), advanced options.

Advanced options allow the users to define the action per blocs of additional fields.
The actions available per bloc depend on the model's type :

Uninstall : do nothing, blank, per field action (choose the action for each field of the bloc individually).
Replace : do nothing, copy, per field action.

Then, per field action allow to choose among those options for the fields :

Uninstall : do nothing, blank, set value (choose a new value, unavailable for field of glpi_item type).
Replace : do nothing, copy.

@rbonser
Copy link

rbonser commented Aug 2, 2024

We are very interested in this feature! I gave the code a try and it mostly works for us in testing.
The only issue I found was the bulk actions list when selecting field blocks offered no way to change the action values. The menu only offered: Update, Unlock Items. Choosing Update gave a select dropdown that was empty. I was able to click on each block id to make the changes.

@stonebuzz
Copy link
Contributor

Hi @ArthurMinfotel
can you fix conflict ?

@ArthurMinfotel
Copy link
Contributor Author

Hi @ArthurMinfotel can you fix conflict ?

Done, I also added some fixes for a few bugs that I had missed.

@ArthurMinfotel
Copy link
Contributor Author

ArthurMinfotel commented Aug 21, 2024

One thing : I used at least one PHP 8 function in this feature (str_starts_with), so ideally the composer.json should be updated to reflect it if this is added.

…s-advanced-compatibility-new-model

# Conflicts:
#	hook.php
#	inc/model.class.php
#	inc/modelcontainer.class.php
#	inc/uninstall.class.php
…d-compatibility

# Conflicts:
#	inc/model.class.php
…lity' into plugin-fields-advanced-compatibility

# Conflicts:
#	inc/model.class.php
…d-compatibility

# Conflicts:
#	inc/model.class.php
@ArthurMinfotel ArthurMinfotel marked this pull request as draft August 21, 2024 14:55
@ArthurMinfotel
Copy link
Contributor Author

Need to do some tests to make sure the change done for the new model are bug free.

@ArthurMinfotel ArthurMinfotel marked this pull request as ready for review September 11, 2024 17:14
@ArthurMinfotel
Copy link
Contributor Author

ArthurMinfotel commented Sep 19, 2024

Fixed errors caused by wrong property name used for some field types (dropdowns and glpi_item).

Still one problem remaining with the copy of the values of field of type "dropdown-$itemtype" with the multiple option during replacement of an item :

If I log the old item's values at the beginning of the replacement, I see the following values :
image

And going further into the code, if I log every single variables that's used as arguments in $DB->updateOrInsert(), I get those values which, in order, correspond to $table, $parameters, $newitem->getID(), $type, and $container['id'] :
image

However, when I look at the result of the operations, I have a very strange result : everything was properly copied to the new item, except computers_id_ordinateurmultiplefield, whose value was actually reset to '[]' for the old item, and the value that was copied to the new item was this '[]' instead of the '["6","5"]' that I see in the parameters passed to updateOrInsert (value was NULL for the old item before the replacement).
image

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

Successfully merging this pull request may close these issues.

3 participants