From 21cc0391e980b7f3e9188bfae204eefb6d6bc964 Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 1 Oct 2010 15:42:23 +0000 Subject: [PATCH] Added new widget which display a list with a selectbox which shown predifined selectable items git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19890 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../goto/Config/class_DeviceConfig.inc | 2 +- .../Config/class_TemplateWidget_fixedList.inc | 86 +++++++++++++++++++ .../goto/admin/systems/goto/Config/puppet.tpl | 2 + 3 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 gosa-plugins/goto/admin/systems/goto/Config/class_TemplateWidget_fixedList.inc diff --git a/gosa-plugins/goto/admin/systems/goto/Config/class_DeviceConfig.inc b/gosa-plugins/goto/admin/systems/goto/Config/class_DeviceConfig.inc index 4e8a19342..4b7951793 100644 --- a/gosa-plugins/goto/admin/systems/goto/Config/class_DeviceConfig.inc +++ b/gosa-plugins/goto/admin/systems/goto/Config/class_DeviceConfig.inc @@ -139,7 +139,7 @@ class DeviceConfig extends management $allValuesSet = TRUE; foreach($this->itemConfig[$type]['options'] as $oName => $oValue){ if(!isset($values[$oName])){ - $values[$oName] = $oValue; + $values[$oName] = (isset($oValue['default']))?$oValue['default']:""; } } diff --git a/gosa-plugins/goto/admin/systems/goto/Config/class_TemplateWidget_fixedList.inc b/gosa-plugins/goto/admin/systems/goto/Config/class_TemplateWidget_fixedList.inc new file mode 100644 index 000000000..0f9809728 --- /dev/null +++ b/gosa-plugins/goto/admin/systems/goto/Config/class_TemplateWidget_fixedList.inc @@ -0,0 +1,86 @@ +listWidget= new sortableListing($this->value); + $this->listWidget->setEditable(false); + $this->listWidget->setDeleteable(true); + $this->listWidget->setColspecs(array('*')); + $this->listWidget->setWidth("100%"); + $this->listWidget->setHeight("70px"); + $this->listWidget->setAcl("rwcdm"); + } + + function getAvailableOptions() + { + $tmp = array(); + foreach($this->values as $key => $name){ + if(!in_array($key, $this->value)){ + $tmp[$key]=$name; + } + } + return($tmp); + } + + function render() + { + $str = ""; + + // Build up list data + $data = $this->value; + foreach($this->value as $key => $name){ + $lData[$key] = array('data' => array($this->values[$name])); + } + $this->listWidget->setListData($data, $lData); + $this->listWidget->update(); + $str .= $this->listWidget->render(); + $str .= ""; + $str .= ""; + return($str); + } + + function save_object() + { + $this->listWidget->save_object(); + $action = $this->listWidget->getAction(); + if($action['action'] == 'delete'){ + $id = $this->listWidget->getKey($action['targets'][0]); + unset($this->value[$id]); + $this->value = array_values($this->value); + } + + if(isset($_POST["{$this->postName}_Add"]) && isset($_POST["{$this->postName}_Input"])){ + $input = get_post("{$this->postName}_Input"); + + if(!empty($input) && !empty($this->syntax) && !preg_match("/".$this->syntax."/", $input)){ + msg_dialog::displayChecks(array(msgPool::invalid($this->display, $input, "/".$this->syntax."/"))); + }elseif(!empty($input)){ + $this->value[] = $input; + } + } + } + + /*! \brief Check the value entry using the provieded syntax. + * @return Array Returns a list of errors + */ + function check() + { + if($this->required && empty($this->value)){ + return(array(msgPool::required($this->display))); + } + return(array()); + } +} + + +?> diff --git a/gosa-plugins/goto/admin/systems/goto/Config/puppet.tpl b/gosa-plugins/goto/admin/systems/goto/Config/puppet.tpl index 067afd91a..799343e28 100644 --- a/gosa-plugins/goto/admin/systems/goto/Config/puppet.tpl +++ b/gosa-plugins/goto/admin/systems/goto/Config/puppet.tpl @@ -24,6 +24,8 @@ + {$fixedList} + {$fixedListName} {/if} {if $type == 'PuppetTemplate'} -- 2.30.2