[icinga-checkins] icinga.org: icingaweb2-module-director/next: SettingsForm: more comfort for v1 users

git at icinga.org git at icinga.org
Fri Nov 4 10:35:10 CET 2016


Module: icingaweb2-module-director
Branch: next
Commit: f67b71a3538a16ca0e0ab4bbabb8de916cf14a80
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=f67b71a3538a16ca0e0ab4bbabb8de916cf14a80

Author: Thomas Gelf <thomas at gelf.net>
Date:   Fri Nov  4 10:34:40 2016 +0100

SettingsForm: more comfort for v1 users

---

 application/forms/SettingsForm.php |   39 +++++++++++++++++++++---------------
 1 file changed, 23 insertions(+), 16 deletions(-)

diff --git a/application/forms/SettingsForm.php b/application/forms/SettingsForm.php
index 2881356..55724df 100644
--- a/application/forms/SettingsForm.php
+++ b/application/forms/SettingsForm.php
@@ -92,28 +92,35 @@ class SettingsForm extends QuickForm
                 . ' unsupported. There are no plans to make Director a first-'
                 . 'class configuration backends for Icinga 1.x'
             ),
+            'class' => 'autosubmit',
             'value' => $settings->getStoredValue('config_format')
         ));
 
-        if ($settings->getStoredValue('config_format') === 'v1') {
-            $this->addElement('select', 'deployment_mode_v1', array(
-                'label'        => $this->translate('Deployment mode'),
-                'multiOptions' => $this->eventuallyConfiguredEnum(
-                    'deployment_mode_v1',
-                    array(
-                        'active-passive' => $this->translate('Active-Passive'),
-                        'masterless'     => $this->translate('Master-less'),
-                    )
-                ),
-                'description'  => $this->translate(
-                    'Deployment mode for Icinga 1 configuration'
-                ),
-                'value' => $settings->getStoredValue('deployment_mode_v1')
-            ));
+        $this->setSubmitLabel($this->translate('Store'));
 
+        if ($this->hasBeenSent()) {
+            if ($this->getSentValue('config_format') !== 'v1') {
+                return;
+            }
+        } elseif ($settings->getStoredValue('config_format') !== 'v1') {
+            return;
         }
 
-        $this->setSubmitLabel($this->translate('Store'));
+        $this->addElement('select', 'deployment_mode_v1', array(
+            'label'        => $this->translate('Deployment mode'),
+            'multiOptions' => $this->eventuallyConfiguredEnum(
+                'deployment_mode_v1',
+                array(
+                    'active-passive' => $this->translate('Active-Passive'),
+                    'masterless'     => $this->translate('Master-less'),
+                )
+            ),
+            'description'  => $this->translate(
+                'Deployment mode for Icinga 1 configuration'
+            ),
+            'value' => $settings->getStoredValue('deployment_mode_v1')
+        ));
+
     }
 
     protected function eventuallyConfiguredEnum($name, $enum)



More information about the icinga-checkins mailing list