Show "Remove problem acknowledgement" in multi-select views

fixes #10469
This commit is contained in:
Eric Lippmann 2016-02-25 10:21:10 +01:00
parent 23b5777b05
commit 102ed40378
3 changed files with 57 additions and 7 deletions

View File

@ -12,8 +12,40 @@ use Icinga\Web\Notification;
class RemoveAcknowledgementCommandForm extends ObjectsCommandForm class RemoveAcknowledgementCommandForm extends ObjectsCommandForm
{ {
/** /**
* (non-PHPDoc) * Whether to show the submit label next to the remove icon
* @see \Zend_Form::init() For the method documentation. *
* The submit label is disabled in detail views but should be enabled in multi-select views.
*
* @var bool
*/
protected $labelEnabled = false;
/**
* Whether to show the submit label next to the remove icon
*
* @return bool
*/
public function isLabelEnabled()
{
return $this->labelEnabled;
}
/**
* Set whether to show the submit label next to the remove icon
*
* @param bool $labelEnabled
*
* @return $this
*/
public function setLabelEnabled($labelEnabled)
{
$this->labelEnabled = (bool) $labelEnabled;
return $this;
}
/**
* {@inheritdoc}
*/ */
public function init() public function init()
{ {
@ -36,7 +68,7 @@ class RemoveAcknowledgementCommandForm extends ObjectsCommandForm
), ),
'escape' => false, 'escape' => false,
'ignore' => true, 'ignore' => true,
'label' => $this->getView()->icon('cancel'), 'label' => $this->getSubmitLabel(),
'title' => $this->translatePlural( 'title' => $this->translatePlural(
'Remove problem acknowledgement', 'Remove problem acknowledgement',
'Remove problem acknowledgements', 'Remove problem acknowledgements',
@ -45,12 +77,29 @@ class RemoveAcknowledgementCommandForm extends ObjectsCommandForm
'type' => 'submit' 'type' => 'submit'
) )
); );
return $this; return $this;
} }
/** /**
* (non-PHPDoc) * {@inheritdoc}
* @see \Icinga\Web\Form::onSuccess() For the method documentation. */
public function getSubmitLabel()
{
$label = $this->getView()->icon('cancel');
if ($this->isLabelEnabled()) {
$label .= $this->translatePlural(
'Remove problem acknowledgement',
'Remove problem acknowledgements',
count($this->objects)
);
}
return $label;
}
/**
* {@inheritdoc}
*/ */
public function onSuccess() public function onSuccess()
{ {
@ -66,6 +115,7 @@ class RemoveAcknowledgementCommandForm extends ObjectsCommandForm
'Removing problem acknowledgements..', 'Removing problem acknowledgements..',
count($this->objects) count($this->objects)
)); ));
return true; return true;
} }
} }

View File

@ -50,7 +50,7 @@
'<b>' . $acknowledgedCount . '</b>' '<b>' . $acknowledgedCount . '</b>'
); ?> </th> ); ?> </th>
<td> <td>
<?= $removeAckForm ?> <?= $removeAckForm->setLabelEnabled(true) ?>
</td> </td>
</tr> </tr>
<?php endif ?> <?php endif ?>

View File

@ -49,7 +49,7 @@
) ?> ) ?>
</th> </th>
<td> <td>
<?= $removeAckForm ?> <?= $removeAckForm->setLabelEnabled(true) ?>
</td> </td>
</tr> </tr>
<?php endif ?> <?php endif ?>