Add missing close buttons to views without tabs

This commit is contained in:
Matthias Jentsch 2014-10-14 17:54:52 +02:00
parent 6124f984ee
commit 937dbe2c15
11 changed files with 56 additions and 5 deletions

View File

@ -1,3 +1,6 @@
<div class="controls">
<?= $this->tabs->showOnlyCloseButton() ?>
</div>
<h4><?= $this->translate('Create New Authentication Backend'); ?></h4> <h4><?= $this->translate('Create New Authentication Backend'); ?></h4>
<p> <p>
<?= $this->translate( <?= $this->translate(

View File

@ -1,2 +1,5 @@
<div class="controls">
<?= $this->tabs->showOnlyCloseButton() ?>
</div>
<h4><?= $this->translate('Edit Backend'); ?></h4> <h4><?= $this->translate('Edit Backend'); ?></h4>
<?= $form; ?> <?= $form; ?>

View File

@ -1,2 +1,5 @@
<div class="controls">
<?= $this->tabs->showOnlyCloseButton() ?>
</div>
<h4><?= $this->translate('Remove Backend'); ?></h4> <h4><?= $this->translate('Remove Backend'); ?></h4>
<?= $form; ?> <?= $form; ?>

View File

@ -1,3 +1,6 @@
<div class="controls">
<?= $this->tabs->showOnlyCloseButton() ?>
</div>
<h4><?= $this->translate('Create A New Resource'); ?></h4> <h4><?= $this->translate('Create A New Resource'); ?></h4>
<p><?= $this->translate('Resources are entities that provide data to Icinga Web 2.'); ?></p> <p><?= $this->translate('Resources are entities that provide data to Icinga Web 2.'); ?></p>
<?= $form; ?> <?= $form; ?>

View File

@ -1,2 +1,5 @@
<div class="controls">
<?= $this->tabs->showOnlyCloseButton() ?>
</div>
<h4><?= $this->translate('Edit Existing Resource'); ?></h4> <h4><?= $this->translate('Edit Existing Resource'); ?></h4>
<?= $form; ?> <?= $form; ?>

View File

@ -1,2 +1,5 @@
<div class="controls">
<?= $this->tabs->showOnlyCloseButton() ?>
</div>
<h4><?= $this->translate('Remove Existing Resource'); ?></h4> <h4><?= $this->translate('Remove Existing Resource'); ?></h4>
<?= $form; ?> <?= $form; ?>

View File

@ -74,6 +74,13 @@ EOT;
*/ */
private $dropdownTabs = array(); 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 * Whether the tabs should contain a close-button
* *
@ -275,14 +282,19 @@ EOT;
*/ */
public function render() public function render()
{ {
if (empty($this->tabs)) { if (empty($this->tabs) || true === $this->closeButtonOnly) {
return ''; $tabs = '';
$drop = '';
} else {
$tabs = $this->renderTabs();
$drop = $this->renderDropdownTabs();
} }
$close = $this->closeTab ? $this->renderCloseTab() : '';
$html = $this->baseTpl; $html = $this->baseTpl;
$html = str_replace('{TABS}', $this->renderTabs(), $html); $html = str_replace('{TABS}', $tabs, $html);
$html = str_replace('{DROPDOWN}', $this->renderDropdownTabs(), $html); $html = str_replace('{DROPDOWN}', $drop, $html);
$html = str_replace('{CLOSE}', $this->closeTab ? $this->renderCloseTab() : '', $html); $html = str_replace('{CLOSE}', $close, $html);
return $html; return $html;
} }
@ -318,6 +330,18 @@ EOT;
return $this->tabs; 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 * Apply a Tabextension on this tabs object
* *

View File

@ -1,3 +1,7 @@
<div class="controls">
<?= $this->tabs->showOnlyCloseButton() ?>
</div>
<div class="content"> <div class="content">
<h1><?= $title ?></h1> <h1><?= $title ?></h1>
<table class="objectlist"> <table class="objectlist">

View File

@ -1,3 +1,6 @@
<div class="controls">
<?= $this->tabs->showOnlyCloseButton() ?>
</div>
<div class="content"> <div class="content">
<h1><?= $title ?></h1> <h1><?= $title ?></h1>
<?php if ((bool) $programStatus->notifications_enabled === false): ?> <?php if ((bool) $programStatus->notifications_enabled === false): ?>

View File

@ -1,5 +1,6 @@
<?php $contactHelper = $this->getHelper('ContactFlags') ?> <?php $contactHelper = $this->getHelper('ContactFlags') ?>
<div class="controls"> <div class="controls">
<?= $this->tabs ?>
<h1><?= $this->translate('Contact details') ?></h1> <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('<?= <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)) $this->href('static/gravatar', array('email' => $contact->contact_email))

View File

@ -8,6 +8,7 @@ $firstRow = !$beingExtended;
?> ?>
<?php if (!$beingExtended): ?> <?php if (!$beingExtended): ?>
<div class="controls"> <div class="controls">
<?= $this->tabs ?>
<div style="margin: 1em;" class="dontprint"> <div style="margin: 1em;" class="dontprint">
<?= $intervalBox; ?> <?= $intervalBox; ?>
</div> </div>