IcingaServiceForm: cleanup, no details without type

This commit is contained in:
Thomas Gelf 2016-03-07 18:39:19 +01:00
parent c8a95f1de6
commit a42be2a6e8

View File

@ -10,6 +10,7 @@ class IcingaServiceForm extends DirectorObjectForm
{ {
$this->addObjectTypeElement(); $this->addObjectTypeElement();
if (! $this->hasObjectType()) { if (! $this->hasObjectType()) {
$this->groupObjectDefinition();
return; return;
} }
@ -29,39 +30,24 @@ class IcingaServiceForm extends DirectorObjectForm
)); ));
} }
$this->addElement('extensibleSet', 'groups', array( $groups = $this->enumServicegroups();
'label' => $this->translate('Groups'), if (! empty($groups)) {
'multiOptions' => $this->optionallyAddFromEnum($this->enumServicegroups()), $this->addElement('extensibleSet', 'groups', array(
'positional' => false, 'label' => $this->translate('Groups'),
'description' => $this->translate( 'multiOptions' => $this->optionallyAddFromEnum($groups),
'Service groups that should be directly assigned to this service. Servicegroups can be useful' 'positional' => false,
. ' for various reasons. They are helpful to provided service-type specific view in Icinga Web 2,' 'description' => $this->translate(
. ' either for custom dashboards or as an instrument to enforce restrictior. Service groups' 'Service groups that should be directly assigned to this service. Servicegroups can be useful'
. ' can be directly assigned to single services or to service templates.' . ' for various reasons. They are helpful to provided service-type specific view in Icinga Web 2,'
) . ' either for custom dashboards or as an instrument to enforce restrictior. Service groups'
)); . ' can be directly assigned to single services or to service templates.'
)
));
}
$this->addImportsElement(); $this->addImportsElement();
$this->addDisabledElement(); $this->addDisabledElement();
$this->groupObjectDefinition();
$elements = array(
'object_type',
'object_name',
'display_name',
'imports',
'host_id',
'groups',
'disabled',
);
$this->addDisplayGroup($elements, 'object_definition', array(
'decorators' => array(
'FormElements',
array('HtmlTag', array('tag' => 'dl')),
'Fieldset',
),
'order' => 20,
'legend' => $this->translate('Service properties')
));
$this->addCheckCommandElements(); $this->addCheckCommandElements();
@ -96,6 +82,29 @@ class IcingaServiceForm extends DirectorObjectForm
$this->setButtons(); $this->setButtons();
} }
protected function groupObjectDefinition()
{
$elements = array(
'object_type',
'object_name',
'display_name',
'imports',
'host_id',
'groups',
'disabled',
);
$this->addDisplayGroup($elements, 'object_definition', array(
'decorators' => array(
'FormElements',
array('HtmlTag', array('tag' => 'dl')),
'Fieldset',
),
'order' => 20,
'legend' => $this->translate('Service properties')
));
}
protected function enumHostsAndTemplates() protected function enumHostsAndTemplates()
{ {
return array( return array(