From 937dbe2c15f59132ceb12ea92a3ff47bab99f94d Mon Sep 17 00:00:00 2001 From: Matthias Jentsch 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 @@ +
+ tabs->showOnlyCloseButton() ?> +

translate('Create New Authentication Backend'); ?>

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 @@ +

+ tabs->showOnlyCloseButton() ?> +

translate('Edit Backend'); ?>

\ 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 @@ +
+ tabs->showOnlyCloseButton() ?> +

translate('Remove Backend'); ?>

\ 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 @@ +
+ tabs->showOnlyCloseButton() ?> +

translate('Create A New Resource'); ?>

translate('Resources are entities that provide data to Icinga Web 2.'); ?>

\ 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 @@ +
+ tabs->showOnlyCloseButton() ?> +

translate('Edit Existing Resource'); ?>

\ 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 @@ +
+ tabs->showOnlyCloseButton() ?> +

translate('Remove Existing Resource'); ?>

\ 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 @@ +
+ tabs->showOnlyCloseButton() ?> +
+

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 @@ +
+ tabs->showOnlyCloseButton() ?> +

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 @@ getHelper('ContactFlags') ?>
+ tabs ?>

translate('Contact details') ?>

+ tabs ?>