From 102ed403788b3a9906d405273fb3c67965b7746f Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 25 Feb 2016 10:21:10 +0100 Subject: [PATCH] Show "Remove problem acknowledgement" in multi-select views fixes #10469 --- .../RemoveAcknowledgementCommandForm.php | 60 +++++++++++++++++-- .../views/scripts/hosts/show.phtml | 2 +- .../views/scripts/services/show.phtml | 2 +- 3 files changed, 57 insertions(+), 7 deletions(-) diff --git a/modules/monitoring/application/forms/Command/Object/RemoveAcknowledgementCommandForm.php b/modules/monitoring/application/forms/Command/Object/RemoveAcknowledgementCommandForm.php index c4c4a9899..416e02e59 100644 --- a/modules/monitoring/application/forms/Command/Object/RemoveAcknowledgementCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/RemoveAcknowledgementCommandForm.php @@ -12,8 +12,40 @@ use Icinga\Web\Notification; class RemoveAcknowledgementCommandForm extends ObjectsCommandForm { /** - * (non-PHPDoc) - * @see \Zend_Form::init() For the method documentation. + * Whether to show the submit label next to the remove icon + * + * 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() { @@ -36,7 +68,7 @@ class RemoveAcknowledgementCommandForm extends ObjectsCommandForm ), 'escape' => false, 'ignore' => true, - 'label' => $this->getView()->icon('cancel'), + 'label' => $this->getSubmitLabel(), 'title' => $this->translatePlural( 'Remove problem acknowledgement', 'Remove problem acknowledgements', @@ -45,12 +77,29 @@ class RemoveAcknowledgementCommandForm extends ObjectsCommandForm 'type' => 'submit' ) ); + return $this; } /** - * (non-PHPDoc) - * @see \Icinga\Web\Form::onSuccess() For the method documentation. + * {@inheritdoc} + */ + 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() { @@ -66,6 +115,7 @@ class RemoveAcknowledgementCommandForm extends ObjectsCommandForm 'Removing problem acknowledgements..', count($this->objects) )); + return true; } } diff --git a/modules/monitoring/application/views/scripts/hosts/show.phtml b/modules/monitoring/application/views/scripts/hosts/show.phtml index a8ed104cb..683680663 100644 --- a/modules/monitoring/application/views/scripts/hosts/show.phtml +++ b/modules/monitoring/application/views/scripts/hosts/show.phtml @@ -50,7 +50,7 @@ '' . $acknowledgedCount . '' ); ?> - + setLabelEnabled(true) ?> diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml index f20a01184..8e46f2e32 100644 --- a/modules/monitoring/application/views/scripts/services/show.phtml +++ b/modules/monitoring/application/views/scripts/services/show.phtml @@ -49,7 +49,7 @@ ) ?> - + setLabelEnabled(true) ?>