From 937dbe2c15f59132ceb12ea92a3ff47bab99f94d Mon Sep 17 00:00:00 2001 From: Matthias Jentsch <matthias.jentsch@netways.de> Date: Tue, 14 Oct 2014 17:54:52 +0200 Subject: [PATCH] Add missing close buttons to views without tabs --- .../config/authentication/create.phtml | 3 ++ .../config/authentication/modify.phtml | 3 ++ .../config/authentication/remove.phtml | 3 ++ .../scripts/config/resource/create.phtml | 3 ++ .../scripts/config/resource/modify.phtml | 3 ++ .../scripts/config/resource/remove.phtml | 3 ++ library/Icinga/Web/Widget/Tabs.php | 34 ++++++++++++++++--- .../views/scripts/partials/command-form.phtml | 4 +++ .../process/disable-notifications.phtml | 3 ++ .../views/scripts/show/contact.phtml | 1 + .../views/scripts/timeline/index.phtml | 1 + 11 files changed, 56 insertions(+), 5 deletions(-) diff --git a/application/views/scripts/config/authentication/create.phtml b/application/views/scripts/config/authentication/create.phtml index 52fcbceb3..427758292 100644 --- a/application/views/scripts/config/authentication/create.phtml +++ b/application/views/scripts/config/authentication/create.phtml @@ -1,3 +1,6 @@ +<div class="controls"> + <?= $this->tabs->showOnlyCloseButton() ?> +</div> <h4><?= $this->translate('Create New Authentication Backend'); ?></h4> <p> <?= $this->translate( diff --git a/application/views/scripts/config/authentication/modify.phtml b/application/views/scripts/config/authentication/modify.phtml index 19901ae5b..b01d7095a 100644 --- a/application/views/scripts/config/authentication/modify.phtml +++ b/application/views/scripts/config/authentication/modify.phtml @@ -1,2 +1,5 @@ +<div class="controls"> + <?= $this->tabs->showOnlyCloseButton() ?> +</div> <h4><?= $this->translate('Edit Backend'); ?></h4> <?= $form; ?> \ No newline at end of file diff --git a/application/views/scripts/config/authentication/remove.phtml b/application/views/scripts/config/authentication/remove.phtml index e1050db0d..424aff9a0 100644 --- a/application/views/scripts/config/authentication/remove.phtml +++ b/application/views/scripts/config/authentication/remove.phtml @@ -1,2 +1,5 @@ +<div class="controls"> + <?= $this->tabs->showOnlyCloseButton() ?> +</div> <h4><?= $this->translate('Remove Backend'); ?></h4> <?= $form; ?> \ No newline at end of file diff --git a/application/views/scripts/config/resource/create.phtml b/application/views/scripts/config/resource/create.phtml index 5a07d832e..0750a5aa9 100644 --- a/application/views/scripts/config/resource/create.phtml +++ b/application/views/scripts/config/resource/create.phtml @@ -1,3 +1,6 @@ +<div class="controls"> + <?= $this->tabs->showOnlyCloseButton() ?> +</div> <h4><?= $this->translate('Create A New Resource'); ?></h4> <p><?= $this->translate('Resources are entities that provide data to Icinga Web 2.'); ?></p> <?= $form; ?> \ No newline at end of file diff --git a/application/views/scripts/config/resource/modify.phtml b/application/views/scripts/config/resource/modify.phtml index 5fa2536bd..d355aeb4c 100644 --- a/application/views/scripts/config/resource/modify.phtml +++ b/application/views/scripts/config/resource/modify.phtml @@ -1,2 +1,5 @@ +<div class="controls"> + <?= $this->tabs->showOnlyCloseButton() ?> +</div> <h4><?= $this->translate('Edit Existing Resource'); ?></h4> <?= $form; ?> \ No newline at end of file diff --git a/application/views/scripts/config/resource/remove.phtml b/application/views/scripts/config/resource/remove.phtml index a43bcd74c..14829ab40 100644 --- a/application/views/scripts/config/resource/remove.phtml +++ b/application/views/scripts/config/resource/remove.phtml @@ -1,2 +1,5 @@ +<div class="controls"> + <?= $this->tabs->showOnlyCloseButton() ?> +</div> <h4><?= $this->translate('Remove Existing Resource'); ?></h4> <?= $form; ?> \ No newline at end of file diff --git a/library/Icinga/Web/Widget/Tabs.php b/library/Icinga/Web/Widget/Tabs.php index d79453a01..b2a34e0ec 100644 --- a/library/Icinga/Web/Widget/Tabs.php +++ b/library/Icinga/Web/Widget/Tabs.php @@ -74,6 +74,13 @@ EOT; */ private $dropdownTabs = array(); + /** + * Whether only the close-button should by rendered for this tab + * + * @var bool + */ + private $closeButtonOnly = false; + /** * Whether the tabs should contain a close-button * @@ -275,14 +282,19 @@ EOT; */ public function render() { - if (empty($this->tabs)) { - return ''; + if (empty($this->tabs) || true === $this->closeButtonOnly) { + $tabs = ''; + $drop = ''; + } else { + $tabs = $this->renderTabs(); + $drop = $this->renderDropdownTabs(); } + $close = $this->closeTab ? $this->renderCloseTab() : ''; $html = $this->baseTpl; - $html = str_replace('{TABS}', $this->renderTabs(), $html); - $html = str_replace('{DROPDOWN}', $this->renderDropdownTabs(), $html); - $html = str_replace('{CLOSE}', $this->closeTab ? $this->renderCloseTab() : '', $html); + $html = str_replace('{TABS}', $tabs, $html); + $html = str_replace('{DROPDOWN}', $drop, $html); + $html = str_replace('{CLOSE}', $close, $html); return $html; } @@ -318,6 +330,18 @@ EOT; return $this->tabs; } + /** + * Whether to hide all elements except of the close button + * + * @param bool $value + * @return Tabs fluent interface + */ + public function showOnlyCloseButton($value = true) + { + $this->closeButtonOnly = $value; + return $this; + } + /** * Apply a Tabextension on this tabs object * diff --git a/modules/monitoring/application/views/scripts/partials/command-form.phtml b/modules/monitoring/application/views/scripts/partials/command-form.phtml index 0aae10046..0e5a4777e 100644 --- a/modules/monitoring/application/views/scripts/partials/command-form.phtml +++ b/modules/monitoring/application/views/scripts/partials/command-form.phtml @@ -1,3 +1,7 @@ +<div class="controls"> + <?= $this->tabs->showOnlyCloseButton() ?> +</div> + <div class="content"> <h1><?= $title ?></h1> <table class="objectlist"> diff --git a/modules/monitoring/application/views/scripts/process/disable-notifications.phtml b/modules/monitoring/application/views/scripts/process/disable-notifications.phtml index 6b45a1f22..547b3ac37 100644 --- a/modules/monitoring/application/views/scripts/process/disable-notifications.phtml +++ b/modules/monitoring/application/views/scripts/process/disable-notifications.phtml @@ -1,3 +1,6 @@ +<div class="controls"> + <?= $this->tabs->showOnlyCloseButton() ?> +</div> <div class="content"> <h1><?= $title ?></h1> <?php if ((bool) $programStatus->notifications_enabled === false): ?> diff --git a/modules/monitoring/application/views/scripts/show/contact.phtml b/modules/monitoring/application/views/scripts/show/contact.phtml index a755266ea..cdb6af12c 100644 --- a/modules/monitoring/application/views/scripts/show/contact.phtml +++ b/modules/monitoring/application/views/scripts/show/contact.phtml @@ -1,5 +1,6 @@ <?php $contactHelper = $this->getHelper('ContactFlags') ?> <div class="controls"> + <?= $this->tabs ?> <h1><?= $this->translate('Contact details') ?></h1> <div class="circular" style="margin-top: 1em; margin-left: 2em; width: 120px; height: 120px; float: left; background-image: url('<?= $this->href('static/gravatar', array('email' => $contact->contact_email)) diff --git a/modules/monitoring/application/views/scripts/timeline/index.phtml b/modules/monitoring/application/views/scripts/timeline/index.phtml index 1d2b26ab2..a6e32ac08 100644 --- a/modules/monitoring/application/views/scripts/timeline/index.phtml +++ b/modules/monitoring/application/views/scripts/timeline/index.phtml @@ -8,6 +8,7 @@ $firstRow = !$beingExtended; ?> <?php if (!$beingExtended): ?> <div class="controls"> + <?= $this->tabs ?> <div style="margin: 1em;" class="dontprint"> <?= $intervalBox; ?> </div>