diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 13:17:48 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 13:17:48 +0000 |
commit | e6d4dfc040bbe3cb80a2ce65b82493b557f751fc (patch) | |
tree | 40bd6366b01b06f4d96fc8638f23a772263cb5e9 /application/forms/AddToBasketForm.php | |
parent | Releasing progress-linux version 1.10.2-2~progress7.99u1. (diff) | |
download | icingaweb2-module-director-e6d4dfc040bbe3cb80a2ce65b82493b557f751fc.tar.xz icingaweb2-module-director-e6d4dfc040bbe3cb80a2ce65b82493b557f751fc.zip |
Merging upstream version 1.11.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'application/forms/AddToBasketForm.php')
-rw-r--r-- | application/forms/AddToBasketForm.php | 54 |
1 files changed, 21 insertions, 33 deletions
diff --git a/application/forms/AddToBasketForm.php b/application/forms/AddToBasketForm.php index 44b5357..36091fe 100644 --- a/application/forms/AddToBasketForm.php +++ b/application/forms/AddToBasketForm.php @@ -11,9 +11,6 @@ use Icinga\Module\Director\Web\Form\DirectorForm; class AddToBasketForm extends DirectorForm { - /** @var Basket */ - private $basket; - private $type = '(has not been set)'; private $names = []; @@ -30,7 +27,6 @@ class AddToBasketForm extends DirectorForm 'b' => 'basket_name', ])->order('basket_name')); - $names = []; $basket = null; if ($this->hasBeenSent()) { $basketName = $this->getSentValue('basket'); @@ -38,25 +34,17 @@ class AddToBasketForm extends DirectorForm $basket = Basket::load($basketName, $this->getDb()); } } - $count = 0; - $type = $this->type; + + $names = []; foreach ($this->names as $name) { - if (! empty($names)) { - $names[] = ', '; - } - if ($basket && $basket->hasObject($type, $name)) { - $names[] = Html::tag('span', [ - 'style' => 'text-decoration: line-through' - ], $name); - } else { - $count++; + if (! $basket || ! $basket->hasObject($this->type, $name)) { $names[] = $name; } } - $this->addHtmlHint((new HtmlDocument())->add([ - 'The following objects will be added: ', - $names - ])); + $this->addHtmlHint( + (new HtmlDocument()) + ->add(sprintf('The following objects will be added: %s', implode(", ", $names))) + ); $this->addElement('select', 'basket', [ 'label' => $this->translate('Basket'), 'multiOptions' => $this->optionalEnum($enum), @@ -64,10 +52,10 @@ class AddToBasketForm extends DirectorForm 'class' => 'autosubmit', ]); - if ($count > 0) { + if (! empty($names)) { $this->setSubmitLabel(sprintf( $this->translate('Add %s objects'), - $count + count($names) )); } else { $this->setSubmitLabel($this->translate('Add')); @@ -112,18 +100,18 @@ class AddToBasketForm extends DirectorForm 'Configuration objects have been added to the chosen basket "%s"' ), $basketName)); return parent::onSuccess(); - } else { - $this->addHtmlHint(Hint::error(Html::sprintf($this->translate( - 'Please check your Basket configuration, %s does not support' - . ' single "%s" configuration objects' - ), Link::create( - $basketName, - 'director/basket', - ['name' => $basketName], - ['data-base-target' => '_next'] - ), $type))); - - return false; } + + $this->addHtmlHint(Hint::error(Html::sprintf($this->translate( + 'Please check your Basket configuration, %s does not support' + . ' single "%s" configuration objects' + ), Link::create( + $basketName, + 'director/basket', + ['name' => $basketName], + ['data-base-target' => '_next'] + ), $type))); + + return false; } } |