@@ -24,7 +24,7 @@ class CfgEditor extends \Ease\Container
2424 /**
2525 * Vytvoří editační formulář podle CFG objektu
2626 *
27- * @param IEcfg $this->ObjectEdited
27+ * @param \Icinga\Editor\Engine\Configurator $this->ObjectEdited
2828 * @param string $onlyColumn Vrací editační pole jen pro sloupec daného jména
2929 */
3030 public function __construct ($ cfgObject , $ onlyColumn = null )
@@ -51,6 +51,7 @@ public function __construct($cfgObject, $onlyColumn = null)
5151 $ this ->addItem (new \Ease \Html \InputHiddenTag ('class ' ,
5252 get_class ($ cfgObject )));
5353 }
54+ \Ease \Shared::webPage ()->includeJavaScript ('js/datasaver.js ' );
5455 }
5556
5657 /**
@@ -122,7 +123,6 @@ public function insertWidget($fieldBlock, $fieldName, $value)
122123 null , true );
123124 }
124125
125-
126126 switch ($ fType ) {
127127 case 'INT ' :
128128 case 'STRING ' :
@@ -133,13 +133,14 @@ public function insertWidget($fieldBlock, $fieldName, $value)
133133 if ($ required ) {
134134 $ fieldBlock ->addItem (new \Ease \TWB \FormGroup ($ fieldName ,
135135 new \Ease \Html \InputTextTag ($ fieldName , $ value ,
136- ['class ' => 'required form-control ' , 'title ' => $ fieldName ]),
137- $ hint , $ keywordInfo ['title ' ]));
136+ ['class ' => 'required form-control ' , 'title ' => $ fieldName ,
137+ 'OnChange ' => $ this ->onChangeCode ($ fieldName )]), $ hint ,
138+ $ keywordInfo ['title ' ]));
138139// $fieldBlock->addItem(new \Ease\Html\Div( new EaseLabeledTextInput($fieldName, $value, $keywordInfo['title'], array('class' => 'required form-control', 'title' => $fieldName))));
139140 } else {
140141 $ fieldBlock ->addItem (new \Ease \TWB \FormGroup ($ fieldName ,
141142 new \Ease \Html \InputTextTag ($ fieldName , $ value ,
142- ['title ' => $ fieldName , 'class ' => 'form-control ' ]),
143+ ['title ' => $ fieldName , 'class ' => 'form-control ' , ' OnChange ' => $ this -> onChangeCode ( $ fieldName ) ]),
143144 $ hint , $ keywordInfo ['title ' ]));
144145// $fieldBlock->addItem(new EaseLabeledTextInput($fieldName, $value, $keywordInfo['title'], array('title' => $fieldName, 'class' => 'form-control')));
145146 }
@@ -196,15 +197,16 @@ public function insertWidget($fieldBlock, $fieldName, $value)
196197 case 'TEXT ' :
197198 $ fieldBlock ->addItem (new \Ease \TWB \FormGroup ($ keywordInfo ['title ' ],
198199 new \Ease \TWB \Textarea ($ fieldName , $ value ,
199- ['style ' => 'width:100% ' ])));
200+ ['style ' => 'width:100% ' , ' OnChange ' => $ this -> onChangeCode ( $ fieldName ) ])));
200201 break ;
201202 case 'ENUM ' :
202203 $ flags = explode (', ' ,
203204 str_replace ([$ fType , "' " , '( ' , ') ' ], '' , $ fieldType ));
204205 $ selector = $ fieldBlock ->addItem (
205206 new \Ease \TWB \FormGroup ($ keywordInfo ['title ' ],
206207 new \Ease \Html \Select ($ fieldName ,
207- array_combine ($ flags , $ flags )))
208+ array_combine ($ flags , $ flags ), null , null ,
209+ ['OnChange ' => $ this ->onChangeCode ($ fieldName )]))
208210 );
209211 break ;
210212 case 'PLATFORM ' :
@@ -250,7 +252,8 @@ public function insertWidget($fieldBlock, $fieldName, $value)
250252 'ORDER BY ' .$ nameColumn , $ IDColumn );
251253
252254 $ selector = $ fieldBlock ->addItem (new \Ease \Html \Select ($ fieldName ,
253- $ value , $ keywordInfo ['title ' ]));
255+ $ value , $ keywordInfo ['title ' ],
256+ ['OnChange ' => $ this ->onChangeCode ($ fieldName )]));
254257
255258 if (!$ required ) {
256259 $ selector ->addItems (['NULL ' => _ ('Výchozí ' )]);
@@ -363,7 +366,7 @@ public function insertWidget($fieldBlock, $fieldName, $value)
363366 case 'USER ' :
364367 $ fieldBlock ->addItem (new UserSelect ($ fieldName , null ,
365368 $ this ->objectEdited ->getDataValue ($ fieldName ), null ,
366- ['style ' => 'width: 100% ' ]));
369+ ['style ' => 'width: 100% ' , ' OnChange ' => $ this -> onChangeCode ( $ fieldName ) ]));
367370 break ;
368371 default :
369372 $ fieldBlock ->addItem (new EaseLabeledTextInput ($ fieldName ,
@@ -713,4 +716,10 @@ public function optionEnabler($name)
713716 return new \Ease \Html \CheckboxTag (null , false , 1 ,
714717 ['id ' => 'useTpl ' .$ name ]);
715718 }
719+
720+ public function onChangeCode ($ fieldName )
721+ {
722+ return 'saveColumnData( \'' .str_replace ('\\' , '- ' ,
723+ get_class ($ this ->objectEdited )).'\', \'' .$ this ->objectEdited ->getMyKey ().'\', \'' .$ fieldName .'\') ' ;
724+ }
716725}
0 commit comments