From 637315d5e2c45a996ec8392d4152b59bf033ebfe Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Mon, 30 Nov 2020 12:39:48 +0100 Subject: [PATCH] DirectorObjectForm: centralize field priority fixes #2041 --- application/forms/IcingaAddServiceForm.php | 2 +- application/forms/IcingaCommandForm.php | 2 +- application/forms/IcingaDependencyForm.php | 4 ++-- application/forms/IcingaHostForm.php | 2 +- application/forms/IcingaNotificationForm.php | 2 +- application/forms/IcingaServiceForm.php | 4 ++-- application/forms/IcingaUserForm.php | 4 ++-- application/forms/IcingaUserGroupForm.php | 2 +- .../Director/Web/Form/DirectorObjectForm.php | 18 ++++++++++++++---- .../Web/Form/IcingaObjectFieldLoader.php | 4 ++-- 10 files changed, 27 insertions(+), 17 deletions(-) diff --git a/application/forms/IcingaAddServiceForm.php b/application/forms/IcingaAddServiceForm.php index eb49cc2d..8d7fa4fd 100644 --- a/application/forms/IcingaAddServiceForm.php +++ b/application/forms/IcingaAddServiceForm.php @@ -63,7 +63,7 @@ class IcingaAddServiceForm extends DirectorObjectForm ['HtmlTag', ['tag' => 'dl']], 'Fieldset', ], - 'order' => 20, + 'order' => self::GROUP_ORDER_OBJECT_DEFINITION, 'legend' => $this->translate('Main properties') ]); diff --git a/application/forms/IcingaCommandForm.php b/application/forms/IcingaCommandForm.php index 0524f574..78d9c117 100644 --- a/application/forms/IcingaCommandForm.php +++ b/application/forms/IcingaCommandForm.php @@ -107,7 +107,7 @@ class IcingaCommandForm extends DirectorObjectForm array('HtmlTag', array('tag' => 'dl')), 'Fieldset', ), - 'order' => 80, + 'order' => self::GROUP_ORDER_CLUSTERING, 'legend' => $this->translate('Zone settings') )); diff --git a/application/forms/IcingaDependencyForm.php b/application/forms/IcingaDependencyForm.php index 14913865..ab30844c 100644 --- a/application/forms/IcingaDependencyForm.php +++ b/application/forms/IcingaDependencyForm.php @@ -57,7 +57,7 @@ class IcingaDependencyForm extends DirectorObjectForm array('HtmlTag', array('tag' => 'dl')), 'Fieldset', ), - 'order' => 80, + 'order' => self::GROUP_ORDER_CLUSTERING, 'legend' => $this->translate('Zone settings') )); @@ -264,7 +264,7 @@ class IcingaDependencyForm extends DirectorObjectForm ['HtmlTag', ['tag' => 'dl']], 'Fieldset', ], - 'order' => 25, + 'order' => self::GROUP_ORDER_RELATED_OBJECTS, 'legend' => $this->translate('Related Objects') ]); diff --git a/application/forms/IcingaHostForm.php b/application/forms/IcingaHostForm.php index c33905a9..91747254 100644 --- a/application/forms/IcingaHostForm.php +++ b/application/forms/IcingaHostForm.php @@ -131,7 +131,7 @@ class IcingaHostForm extends DirectorObjectForm ['HtmlTag', ['tag' => 'dl']], 'Fieldset', ], - 'order' => 80, + 'order' => self::GROUP_ORDER_CLUSTERING, 'legend' => $this->translate('Icinga Agent and zone settings') ]); diff --git a/application/forms/IcingaNotificationForm.php b/application/forms/IcingaNotificationForm.php index 8c934570..0fca6b8e 100644 --- a/application/forms/IcingaNotificationForm.php +++ b/application/forms/IcingaNotificationForm.php @@ -61,7 +61,7 @@ class IcingaNotificationForm extends DirectorObjectForm array('HtmlTag', array('tag' => 'dl')), 'Fieldset', ), - 'order' => 80, + 'order' => self::GROUP_ORDER_CLUSTERING, 'legend' => $this->translate('Zone settings') )); diff --git a/application/forms/IcingaServiceForm.php b/application/forms/IcingaServiceForm.php index 3760efa1..b1eb7e6d 100644 --- a/application/forms/IcingaServiceForm.php +++ b/application/forms/IcingaServiceForm.php @@ -165,7 +165,7 @@ class IcingaServiceForm extends DirectorObjectForm ['HtmlTag', ['tag' => 'dl']], 'DtDdWrapper', ], - 'order' => 1000, + 'order' => self::GROUP_ORDER_BUTTONS, ]); } } @@ -686,7 +686,7 @@ class IcingaServiceForm extends DirectorObjectForm array('HtmlTag', array('tag' => 'dl')), 'Fieldset', ), - 'order' => 40, + 'order' => self::GROUP_ORDER_CLUSTERING, 'legend' => $this->translate('Icinga Agent and zone settings') )); diff --git a/application/forms/IcingaUserForm.php b/application/forms/IcingaUserForm.php index 856a0161..bff22525 100644 --- a/application/forms/IcingaUserForm.php +++ b/application/forms/IcingaUserForm.php @@ -72,7 +72,7 @@ class IcingaUserForm extends DirectorObjectForm array('HtmlTag', array('tag' => 'dl')), 'Fieldset', ), - 'order' => 80, + 'order' => self::GROUP_ORDER_CLUSTERING, 'legend' => $this->translate('Zone settings') )); @@ -190,7 +190,7 @@ class IcingaUserForm extends DirectorObjectForm array('HtmlTag', array('tag' => 'dl')), 'Fieldset', ), - 'order' => 20, + 'order' => self::GROUP_ORDER_OBJECT_DEFINITION, 'legend' => $this->translate('User properties') )); } diff --git a/application/forms/IcingaUserGroupForm.php b/application/forms/IcingaUserGroupForm.php index d93cc56d..d9706b4e 100644 --- a/application/forms/IcingaUserGroupForm.php +++ b/application/forms/IcingaUserGroupForm.php @@ -38,7 +38,7 @@ class IcingaUserGroupForm extends DirectorObjectForm ['HtmlTag', ['tag' => 'dl']], 'Fieldset', ], - 'order' => 80, + 'order' => self::GROUP_ORDER_CLUSTERING, 'legend' => $this->translate('Zone settings') ]); diff --git a/library/Director/Web/Form/DirectorObjectForm.php b/library/Director/Web/Form/DirectorObjectForm.php index 4118d4f6..5477ee88 100644 --- a/library/Director/Web/Form/DirectorObjectForm.php +++ b/library/Director/Web/Form/DirectorObjectForm.php @@ -23,6 +23,16 @@ use Zend_Form_Element_Select as ZfSelect; abstract class DirectorObjectForm extends DirectorForm { + const GROUP_ORDER_OBJECT_DEFINITION = 20; + const GROUP_ORDER_RELATED_OBJECTS = 25; + const GROUP_ORDER_ASSIGN = 30; + const GROUP_ORDER_CUSTOM_FIELDS = 50; + const GROUP_ORDER_CUSTOM_FIELD_CATEGORIES = 60; + const GROUP_ORDER_EVENT_FILTERS = 700; + const GROUP_ORDER_EXTRA_INFO = 750; + const GROUP_ORDER_CLUSTERING = 800; + const GROUP_ORDER_BUTTONS = 1000; + /** @var IcingaObject */ protected $object; @@ -572,7 +582,7 @@ abstract class DirectorObjectForm extends DirectorForm array('HtmlTag', array('tag' => 'dl')), 'Fieldset', ), - 'order' => 20, + 'order' => self::GROUP_ORDER_OBJECT_DEFINITION, 'legend' => $this->translate('Main properties') )); @@ -1551,7 +1561,7 @@ abstract class DirectorObjectForm extends DirectorForm array('HtmlTag', array('tag' => 'dl')), 'Fieldset', ), - 'order' => 75, + 'order' => self::GROUP_ORDER_EXTRA_INFO, 'legend' => $this->translate('Additional properties') )); @@ -1584,7 +1594,7 @@ abstract class DirectorObjectForm extends DirectorForm array('HtmlTag', array('tag' => 'dl')), 'Fieldset', ), - 'order' => 30, + 'order' => self::GROUP_ORDER_ASSIGN, 'legend' => $this->translate('Assign where') )); @@ -1653,7 +1663,7 @@ abstract class DirectorObjectForm extends DirectorForm array('HtmlTag', array('tag' => 'dl')), 'Fieldset', ), - 'order' =>70, + 'order' => self::GROUP_ORDER_EVENT_FILTERS, 'legend' => $this->translate('State and transition type filters') )); diff --git a/library/Director/Web/Form/IcingaObjectFieldLoader.php b/library/Director/Web/Form/IcingaObjectFieldLoader.php index 3c529881..1c041bbe 100644 --- a/library/Director/Web/Form/IcingaObjectFieldLoader.php +++ b/library/Director/Web/Form/IcingaObjectFieldLoader.php @@ -255,14 +255,14 @@ class IcingaObjectFieldLoader $form->addElementsToGroup( [$element], 'custom_fields:' . $category->get('category_name'), - 51 + $prioIdx[$key], + DirectorObjectForm::GROUP_ORDER_CUSTOM_FIELD_CATEGORIES + $prioIdx[$key], $category->get('category_name') ); } else { $form->addElementsToGroup( [$element], 'custom_fields', - 50, + DirectorObjectForm::GROUP_ORDER_CUSTOM_FIELDS, $form->translate('Custom properties') ); }