Repository navigation
Conversation
…assive-action-multiple-tab-blocks # Conflicts: # CHANGELOG.md
Contributor
Author
|
Do the same on the V12 |
4 tasks
Rom1-B
requested changes
Oct 22, 2026
Comment on lines
+2030
to
+2054
| !in_array($item::class, PluginFieldsToolbox::decodeJSONItemtypes($data['itemtypes'])) | ||
| || !Session::haveAccessToEntity($data['entities_id'], $data['is_recursive']) | ||
| ) { | ||
| continue; | ||
| } | ||
|
|
||
| $fields = (new PluginFieldsField())->find([ | ||
| 'plugin_fields_containers_id' => $data['id'], | ||
| 'is_active' => 1, | ||
| 'type' => ['!=', 'header'], | ||
| ]); | ||
| foreach ($fields as $field) { | ||
| $input_keys = [ | ||
| $field['name'], | ||
| sprintf('plugin_fields_%sdropdowns_id', $field['name']), | ||
| sprintf('items_id_%s', $field['name']), | ||
| ]; | ||
| if (array_intersect($input_keys, array_keys($item->input)) !== []) { | ||
| $c_ids[] = (int) $data['id']; | ||
| break; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return $c_ids; |
Contributor
There was a problem hiding this comment.
One fields query for all containers instead of one per container.
Suggested change
| !in_array($item::class, PluginFieldsToolbox::decodeJSONItemtypes($data['itemtypes'])) | |
| || !Session::haveAccessToEntity($data['entities_id'], $data['is_recursive']) | |
| ) { | |
| continue; | |
| } | |
| $fields = (new PluginFieldsField())->find([ | |
| 'plugin_fields_containers_id' => $data['id'], | |
| 'is_active' => 1, | |
| 'type' => ['!=', 'header'], | |
| ]); | |
| foreach ($fields as $field) { | |
| $input_keys = [ | |
| $field['name'], | |
| sprintf('plugin_fields_%sdropdowns_id', $field['name']), | |
| sprintf('items_id_%s', $field['name']), | |
| ]; | |
| if (array_intersect($input_keys, array_keys($item->input)) !== []) { | |
| $c_ids[] = (int) $data['id']; | |
| break; | |
| } | |
| } | |
| } | |
| return $c_ids; | |
| in_array($item::class, PluginFieldsToolbox::decodeJSONItemtypes($data['itemtypes'])) | |
| && Session::haveAccessToEntity($data['entities_id'], $data['is_recursive']) | |
| ) { | |
| $c_ids[] = (int) $data['id']; | |
| } | |
| } | |
| if ($c_ids === []) { | |
| return []; | |
| } | |
| $fields = (new PluginFieldsField())->find([ | |
| 'plugin_fields_containers_id' => $c_ids, | |
| 'is_active' => 1, | |
| 'type' => ['!=', 'header'], | |
| ], 'plugin_fields_containers_id'); | |
| $submitted = []; | |
| foreach ($fields as $field) { | |
| $input_keys = [ | |
| $field['name'], | |
| sprintf('plugin_fields_%sdropdowns_id', $field['name']), | |
| sprintf('items_id_%s', $field['name']), | |
| ]; | |
| if (array_intersect($input_keys, array_keys($item->input)) !== []) { | |
| $submitted[] = (int) $field['plugin_fields_containers_id']; | |
| } | |
| } | |
| return array_values(array_unique($submitted)); |
Comment on lines
2188
to
+2195
| $c_ids = array_filter( | ||
| [self::findContainer($item::class, 'dom'), self::findContainer($item::class, 'tab')], | ||
| static fn($id) => $id !== false, | ||
| ); | ||
|
|
||
| // other tab containers whose fields are submitted (ex: massive action on a GLPI item | ||
| // dropdown field for which the core never displays the plugin field nor its c_id input) | ||
| $c_ids = array_values(array_unique(array_merge($c_ids, self::findSubmittedTabContainers($item)))); |
Contributor
There was a problem hiding this comment.
Keep the default tab container last: it should still win when several are submitted.
Suggested change
| $c_ids = array_values(array_unique(array_merge($c_ids, self::findSubmittedTabContainers($item)))); | |
| // other tab containers whose fields are submitted (ex: massive action on a GLPI item | |
| // dropdown field for which the core never displays the plugin field nor its c_id input) | |
| $c_ids = array_values(array_unique(array_filter( | |
| [ | |
| self::findContainer($item::class, 'dom'), | |
| ...self::findSubmittedTabContainers($item), | |
| self::findContainer($item::class, 'tab'), | |
| ], | |
| static fn($id) => $id !== false, | |
| ))); |
| foreach (array_keys($this->containers) as $container_key) { | ||
| $this->assertNull($this->getStoredValues($container_key, $computer), sprintf('Unexpected values stored in "%s" container', $container_key)); | ||
| } | ||
| } |
Contributor
There was a problem hiding this comment.
Can you add a test updating fields of two tab containers in a single update()?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist before requesting a review
Please delete options that are not relevant.
Description
Fixes the bulk action on a field in an “Add a Tab” block; previously, when the item had multiple blocks of this type, the value was not saved (e.g., the “Tickets” field).
Without a c_id, the plugin now also retains tab blocks for which a field is submitted, rather than just the last block.