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/BasketUploadForm.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/BasketUploadForm.php')
-rw-r--r-- | application/forms/BasketUploadForm.php | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/application/forms/BasketUploadForm.php b/application/forms/BasketUploadForm.php index a88dc06..aa26258 100644 --- a/application/forms/BasketUploadForm.php +++ b/application/forms/BasketUploadForm.php @@ -25,10 +25,12 @@ class BasketUploadForm extends DirectorObjectForm */ public function setup() { - $this->addElement('text', 'basket_name', [ - 'label' => $this->translate('Basket Name'), - 'required' => true, - ]); + if ($this->object === null) { + $this->addElement('text', 'basket_name', [ + 'label' => $this->translate('Basket Name'), + 'required' => true, + ]); + } $this->setAttrib('enctype', 'multipart/form-data'); $this->addElement('file', 'uploaded_file', [ @@ -53,16 +55,6 @@ class BasketUploadForm extends DirectorObjectForm return '\\Icinga\\Module\\Director\\DirectorObject\\Automation\\Basket'; } - protected function setObjectSuccessUrl() - { - /** @var Basket $basket */ - $basket = $this->object(); - $this->setSuccessUrl( - 'director/basket', - ['name' => $basket->get('basket_name')] - ); - } - /** * @return bool * @throws IcingaException @@ -134,13 +126,17 @@ class BasketUploadForm extends DirectorObjectForm $basket->set('owner_type', 'user'); $basket->set('owner_value', $this->getAuth()->getUser()->getUsername()); - $basket->store($this->db); + if ($basket->hasBeenLoadedFromDb()) { + $this->setSuccessUrl('director/basket/snapshots', ['name' => $basket->get('basket_name')]); + } else { + $this->setSuccessUrl('director/basket', ['name' => $basket->get('basket_name')]); + $basket->store($this->db); + } BasketSnapshot::forBasketFromJson( $basket, $this->rawUpload )->store($this->db); - $this->setObjectSuccessUrl(); $this->beforeSuccessfulRedirect(); $this->redirectOnSuccess($this->translate('Basket has been uploaded')); } |