Skip to content

Commit

Permalink
Wrap widget CustomVarTable specifically for collapsible.js
Browse files Browse the repository at this point in the history
The widget itself isn't collapsible anymore by default.
  • Loading branch information
nilmerg committed Dec 2, 2021
1 parent c9dec38 commit 71ac7c0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
8 changes: 5 additions & 3 deletions library/Icingadb/Widget/Detail/ObjectDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.'));
}
Expand Down
9 changes: 6 additions & 3 deletions library/Icingadb/Widget/Detail/UserDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.'));
}
Expand Down
9 changes: 6 additions & 3 deletions library/Icingadb/Widget/Detail/UsergroupDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.'));
}
Expand Down

0 comments on commit 71ac7c0

Please sign in to comment.