Fixed issue with hiding conditions not hiding containers in simple ticket view
- It fixes #847
Just to clarify: in my fresh installation (latest versions of everything), I had to place the code inside the showForTab function below the line:
$display_condition = new PluginFieldsContainerDisplayCondition();
like this:
...
$display_condition = new PluginFieldsContainerDisplayCondition();
// @akstis-typer code starts here ------
if($item->fields['type'] == "")
{
$item->fields['type'] = $params['options']['type'];
}
if($item->fields['itilcategories_id'] == "")
{
$item->fields['itilcategories_id'] = $params['options']['itilcategories_id'];
}
// @akstis-typer code ends here ------
if ($display_condition->computeDisplayContainer($item, $c_id)) {
...
Otherwise, it didn’t work properly in my environment
I've been testing this code and works correctly except for one more issue: When a custom field is shown and you edit another field (e.g. title), the custom field's alignment breaks again. My solution was to add echo "<div class='offset-md-1 col-md-8 col-xxl-6'>"; into the ajax/container.php file, inside the if ($display_condition->computeDisplayContainer($item, $containers_id)) { condition:
$display_condition = new PluginFieldsContainerDisplayCondition();
if ($display_condition->computeDisplayContainer($item, $containers_id)) {
$field_options = [
'label_class' => 'col-lg-3',
'input_class' => 'col-lg-9',
];
echo "<div class='offset-md-1 col-md-8 col-xxl-6'>";
PluginFieldsField::showDomContainer(
$containers_id,
$item,
$type,
$subtype,
$field_options
);
echo "</div>";
} else {
echo '';
}
After the showDomContainer method i close the created div with echo "</div>";
Hi @akstis-typer
can you rebase ?
Hi @akstis-typer
can you rebase ?
Hi, you mean I need to add last changes of original repository? Or something else? I'm not so good at git so I didn't get it :0
git fetch upstream (github repo)
git pull --rebase upstream main
git push --force
That should be sufficient.
I think I did it right. The next step is unit tests - how do I make them? Or can I run yours? I launched php-fixer and php-stan analyzer - this showed me that all is OK
I've done poorly last time and accidentally revert changes in twig files. Now I reverted all back how it should be and removed spaces and new lines I added.
Finally I got it
The next step is unit tests - how do I make them? Or can I run yours?
We currently have no tests on this plugin; but we will work on adding some quickly. For now, you cannot add tests for your changes; we'll ping you.
Until that, we asked feedback from several users to know if their issues are resolved by your changes.
Thanks a lot for your worK.
=
I've been testing this code and works correctly except for one more issue: When a custom field is shown and you edit another field (e.g. title), the custom field's alignment breaks again. My solution was to add
echo "<div class='offset-md-1 col-md-8 col-xxl-6'>";into theajax/container.phpfile, inside theif ($display_condition->computeDisplayContainer($item, $containers_id)) {condition:$display_condition = new PluginFieldsContainerDisplayCondition(); if ($display_condition->computeDisplayContainer($item, $containers_id)) { $field_options = [ 'label_class' => 'col-lg-3', 'input_class' => 'col-lg-9', ]; echo "<div class='offset-md-1 col-md-8 col-xxl-6'>"; PluginFieldsField::showDomContainer( $containers_id, $item, $type, $subtype, $field_options ); echo "</div>"; } else { echo ''; }After the
showDomContainermethod i close the created div withecho "</div>";
I tested it and in my environment it only worked correctly this way.
Thank you very much everyone!
It seems that there are many unrelated changes included in this PR. Translation files do not need to be committed, as we have a dedicated CI process to push and pull translations from Transifex. Also, adding conditions on the field looks more like a new feature than a fix. This should be handled in a separate PR to keep the reviews focused and easier to follow.
My bad. I'll get rid of unnecessary changes
Great, congratulations! You updated the plugin, but when I applied the update, not only did it not fix this problem, but the fix from the colleague above no longer works. Great!
Hi, @leeopereira, my fix doesn't work on the nightly version of the plugin?
Hi, @leeopereira, my fix doesn't work on the nightly version of the plugin?
Oi @akstis-typer , Unfortunately not, I had to restore a backup of the previous version of the files. When I updated, the deleted files were replaced with the originals from the new version, and the problem returned. The hide condition stopped working, and the custom fields became misaligned. :/
@leeopereira , this happened because this changes are not in the main branch of fields plugin repo, so when you update using glpi - they getting overriden by update that developers made. But, if you pull changes from this branch and merge it with updated branch - it'll still work :) I may update my branch to the nightly one, and you'll be able to pull it without problem.
@akstis-typer After updating, I tried editing the files and inserting the corrections here in the topic, but it still didn't work. I don't know if they changed something in the code that impacted the correction. But I just returned the two old edited files and it worked.