From 737ee726511fbb395c6db96c9c6a5783126f37ee Mon Sep 17 00:00:00 2001 From: Frank Bergkemper Date: Fri, 20 Mar 2020 18:02:21 +0100 Subject: [PATCH] webui: change the construction of the restore form element "where" Use a placeholder or the "where" directive from the selected restore job instead of a fixed value during form element construction. --- .../Restore/src/Restore/Form/RestoreForm.php | 58 +++++++++++++------ 1 file changed, 39 insertions(+), 19 deletions(-) diff --git a/webui/module/Restore/src/Restore/Form/RestoreForm.php b/webui/module/Restore/src/Restore/Form/RestoreForm.php index 1ca81e16c89..6719e9c675a 100644 --- a/webui/module/Restore/src/Restore/Form/RestoreForm.php +++ b/webui/module/Restore/src/Restore/Form/RestoreForm.php @@ -408,7 +408,7 @@ public function __construct($restore_params=null, $clients=null, $filesets=null, } // Where - if(isset($this->restore_params['client'])) { + if(isset($this->restore_params['restorejob'])) { $this->add(array( 'name' => 'where', 'type' => 'text', @@ -417,31 +417,51 @@ public function __construct($restore_params=null, $clients=null, $filesets=null, ), 'attributes' => array( 'class' => 'form-control selectpicker show-tick', - 'value' => '/tmp/bareos-restores/', + 'value' => $this->determineWhereDirective($this->restore_params['restorejob']), 'id' => 'where', 'size' => '30', - 'placeholder' => _('e.g. / or /tmp/bareos-restores/') + 'placeholder' => _('e.g. / or /tmp/bareos-restores/'), + 'required' => 'required' ) ) ); } else { - $this->add(array( - 'name' => 'where', - 'type' => 'text', - 'options' => array( - 'label' => _('Restore location on client') - ), - 'attributes' => array( - 'class' => 'form-control selectpicker show-tick', - 'value' => '/tmp/bareos-restores/', - 'id' => 'where', - 'size' => '30', - 'placeholder' => _('e.g. / or /tmp/bareos-restores/'), - 'disabled' => true - ) - ) - ); + if(!empty($this->restore_params['client']) && count($this->getRestoreJobList()) > 0) { + $this->add(array( + 'name' => 'where', + 'type' => 'text', + 'options' => array( + 'label' => _('Restore location on client') + ), + 'attributes' => array( + 'class' => 'form-control selectpicker show-tick', + 'value' => @array_pop($this->getRestoreJobWhereDirectives()), + 'id' => 'where', + 'size' => '30', + 'placeholder' => _('e.g. / or /tmp/bareos-restores/'), + 'required' => 'required' + ) + ) + ); + } else { + $this->add(array( + 'name' => 'where', + 'type' => 'text', + 'options' => array( + 'label' => _('Restore location on client') + ), + 'attributes' => array( + 'class' => 'form-control selectpicker show-tick', + 'id' => 'where', + 'size' => '30', + 'placeholder' => _('e.g. / or /tmp/bareos-restores/'), + 'required' => 'required', + 'disabled' => true + ) + ) + ); + } } // JobIds hidden