mirror of
				https://github.com/Icinga/icingaweb2-module-director.git
				synced 2025-10-31 03:14:33 +01:00 
			
		
		
		
	IcingaObjectFieldForm: improve usability
This commit is contained in:
		
							parent
							
								
									07db0034dc
								
							
						
					
					
						commit
						077d46d7dd
					
				| @ -49,6 +49,8 @@ class IcingaObjectFieldForm extends DirectorObjectForm | |||||||
|         // TODO: extract vars from command line (-> dummy)
 |         // TODO: extract vars from command line (-> dummy)
 | ||||||
|         // TODO: do not suggest chosen ones
 |         // TODO: do not suggest chosen ones
 | ||||||
|         $argumentVars = array(); |         $argumentVars = array(); | ||||||
|  |         $argumentVarDescriptions = array(); | ||||||
|  | 
 | ||||||
|         if ($this->icingaObject->supportsArguments()) { |         if ($this->icingaObject->supportsArguments()) { | ||||||
|             foreach ($this->icingaObject->arguments() as $arg) { |             foreach ($this->icingaObject->arguments() as $arg) { | ||||||
|                 if ($arg->argument_format === 'string') { |                 if ($arg->argument_format === 'string') { | ||||||
| @ -63,6 +65,7 @@ class IcingaObjectFieldForm extends DirectorObjectForm | |||||||
|                                 unset($existingFields[$id]); |                                 unset($existingFields[$id]); | ||||||
|                             } else { |                             } else { | ||||||
|                                 $argumentVars[$val] = $val; |                                 $argumentVars[$val] = $val; | ||||||
|  |                                 $argumentVarDescriptions[$val] = $arg->description; | ||||||
|                             } |                             } | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
| @ -108,8 +111,17 @@ class IcingaObjectFieldForm extends DirectorObjectForm | |||||||
|                 'label'       => $this->translate('Caption'), |                 'label'       => $this->translate('Caption'), | ||||||
|                 'required'    => true, |                 'required'    => true, | ||||||
|                 'ignore'      => true, |                 'ignore'      => true, | ||||||
|  |                 'value'       => trim($id, '$'), | ||||||
|                 'description' => $this->translate('The caption which should be displayed') |                 'description' => $this->translate('The caption which should be displayed') | ||||||
|             )); |             )); | ||||||
|  | 
 | ||||||
|  |             $this->addElement('textarea', 'description', array( | ||||||
|  |                 'label'       => $this->translate('Description'), | ||||||
|  |                 'description' => $this->translate('A description about the field'), | ||||||
|  |                 'ignore'      => true, | ||||||
|  |                 'value'       => array_key_exists($id, $argumentVarDescriptions) ? $argumentVarDescriptions[$id] : null, | ||||||
|  |                 'rows'        => '3', | ||||||
|  |             )); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         $this->addElement('select', 'is_required', array( |         $this->addElement('select', 'is_required', array( | ||||||
| @ -139,18 +151,19 @@ class IcingaObjectFieldForm extends DirectorObjectForm | |||||||
|     public function onSuccess() |     public function onSuccess() | ||||||
|     { |     { | ||||||
|         $fieldId = $this->getValue('datafield_id'); |         $fieldId = $this->getValue('datafield_id'); | ||||||
|         if (! ctype_digit($fieldId)) { |  | ||||||
| 
 | 
 | ||||||
|  |         if (! ctype_digit($fieldId)) { | ||||||
|             $field = DirectorDatafield::create(array( |             $field = DirectorDatafield::create(array( | ||||||
|                 'varname'     => trim($fieldId, '$'), |                 'varname'     => trim($fieldId, '$'), | ||||||
|                 'caption'     => $this->getValue('caption'), |                 'caption'     => $this->getValue('caption'), | ||||||
|  |                 'description' => $this->getValue('description'), | ||||||
|                 'datatype'    => 'Icinga\Module\Director\DataType\DataTypeString' |                 'datatype'    => 'Icinga\Module\Director\DataType\DataTypeString' | ||||||
|             )); |             )); | ||||||
|             $field->store($this->getDb()); |             $field->store($this->getDb()); | ||||||
|             $this->setElementValue('datafield_id', $field->id); |             $this->setElementValue('datafield_id', $field->id); | ||||||
|             $this->object()->datafield_id = $field->id; |             $this->object()->datafield_id = $field->id; | ||||||
| 
 |  | ||||||
|         } |         } | ||||||
|  | 
 | ||||||
|         return parent::onSuccess(); |         return parent::onSuccess(); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user