Skip to content

Fixed issue with hiding conditions not hiding containers in simple ticket view #942

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

akstis-typer
Copy link

@DaviidMM
Copy link

DaviidMM commented Apr 11, 2025

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

@DaviidMM
Copy link

DaviidMM commented May 5, 2025

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>";

@stonebuzz
Copy link
Contributor

Hi @akstis-typer

can you rebase ?

@akstis-typer
Copy link
Author

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

@stonebuzz
Copy link
Contributor

git fetch upstream (github repo)
git pull --rebase upstream main
git push --force 

That should be sufficient.

@akstis-typer
Copy link
Author

akstis-typer commented May 23, 2025

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

Copy link
Contributor

@trasher trasher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You PR has lot of unrelated changes (new lines added, spacing added/removed) that must be reverted.

@akstis-typer
Copy link
Author

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.

Rebased myself to upstream main branch
Edited only two files:
-container.php that fixes formatting of field
-field.class.php that fixes issue with field not respecting hiding condition in simple view
@akstis-typer
Copy link
Author

Finally I got it

@trasher
Copy link
Contributor

trasher commented May 23, 2025

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.

@leeopereira
Copy link

=

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>";

I tested it and in my environment it only worked correctly this way.

Thank you very much everyone!

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

Successfully merging this pull request may close these issues.

Hiding fields depending on category does not work
6 participants