From 71ac7c0e73c17713c901d7018ffe5e02ed790fb5 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 2 Dec 2021 15:22:32 +0100 Subject: [PATCH] Wrap widget `CustomVarTable` specifically for `collapsible.js` The widget itself isn't collapsible anymore by default. --- library/Icingadb/Widget/Detail/ObjectDetail.php | 8 +++++--- library/Icingadb/Widget/Detail/UserDetail.php | 9 ++++++--- library/Icingadb/Widget/Detail/UsergroupDetail.php | 9 ++++++--- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/library/Icingadb/Widget/Detail/ObjectDetail.php b/library/Icingadb/Widget/Detail/ObjectDetail.php index d47c3f05c..9943e503d 100644 --- a/library/Icingadb/Widget/Detail/ObjectDetail.php +++ b/library/Icingadb/Widget/Detail/ObjectDetail.php @@ -185,9 +185,11 @@ protected function createCustomVars(): array $this->fetchCustomVars(); $vars = (new CustomvarFlat())->unFlattenVars($this->object->customvar_flat); if (! empty($vars)) { - $customvarTable = new CustomVarTable($vars); - $customvarTable->setAttribute('id', $this->objectType . '-customvars'); - $content[] = $customvarTable; + $content[] = new HtmlElement('div', Attributes::create([ + 'id' => $this->objectType . '-customvars', + 'class' => 'collapsible', + 'data-visible-height' => 200 + ]), new CustomVarTable($vars, $this->object)); } else { $content[] = new EmptyState(t('No custom variables configured.')); } diff --git a/library/Icingadb/Widget/Detail/UserDetail.php b/library/Icingadb/Widget/Detail/UserDetail.php index 5ae79617e..0b7cdee15 100644 --- a/library/Icingadb/Widget/Detail/UserDetail.php +++ b/library/Icingadb/Widget/Detail/UserDetail.php @@ -10,6 +10,7 @@ use Icinga\Module\Icingadb\Hook\ExtensionHook\ObjectDetailExtensionHook; use Icinga\Module\Icingadb\Model\User; use Icinga\Module\Icingadb\Widget\EmptyState; +use ipl\Html\Attributes; use ipl\Web\Widget\HorizontalKeyValue; use Icinga\Module\Icingadb\Widget\ItemList\UsergroupList; use Icinga\Module\Icingadb\Widget\ShowMore; @@ -42,9 +43,11 @@ protected function createCustomVars(): array $vars = $this->user->customvar_flat->getModel()->unflattenVars($flattenedVars); if (! empty($vars)) { - $customvarTable = new CustomVarTable($vars); - $customvarTable->setAttribute('id', 'user-customvars'); - $content[] = $customvarTable; + $content[] = new HtmlElement('div', Attributes::create([ + 'id' => 'user-customvars', + 'class' => 'collapsible', + 'data-visible-height' => 200 + ]), new CustomVarTable($vars, $this->user)); } else { $content[] = new EmptyState(t('No custom variables configured.')); } diff --git a/library/Icingadb/Widget/Detail/UsergroupDetail.php b/library/Icingadb/Widget/Detail/UsergroupDetail.php index fd6a2f50a..39f86599d 100644 --- a/library/Icingadb/Widget/Detail/UsergroupDetail.php +++ b/library/Icingadb/Widget/Detail/UsergroupDetail.php @@ -12,6 +12,7 @@ use Icinga\Module\Icingadb\Widget\EmptyState; use Icinga\Module\Icingadb\Widget\ItemList\UserList; use Icinga\Module\Icingadb\Widget\ShowMore; +use ipl\Html\Attributes; use ipl\Html\BaseHtmlElement; use ipl\Html\HtmlElement; use ipl\Html\Text; @@ -41,9 +42,11 @@ protected function createCustomVars(): array $vars = $this->usergroup->customvar_flat->getModel()->unflattenVars($flattenedVars); if (! empty($vars)) { - $customvarTable = new CustomVarTable($vars); - $customvarTable->setAttribute('id', 'usergroup-customvars'); - $content[] = $customvarTable; + $content[] = new HtmlElement('div', Attributes::create([ + 'id' => 'usergroup-customvars', + 'class' => 'collapsible', + 'data-visible-height' => 200 + ]), new CustomVarTable($vars, $this->usergroup)); } else { $content[] = new EmptyState(t('No custom variables configured.')); }