Code

Fixed Listing temlate
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 19 May 2011 12:50:25 +0000 (12:50 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 19 May 2011 12:50:25 +0000 (12:50 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20888 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_list.inc

index de77b6eb1718aa9832ae0f449a06c724217a3982..a73f4ed093d38454bea4bebd4ebff04e1c90dc1f 100644 (file)
@@ -10,28 +10,27 @@ class TemplateWidget_list extends TemplateWidget
         $this->listWidget= new sortableListing($this->value);
         $this->listWidget->setEditable(false);
         $this->listWidget->setDeleteable(true);
+        $this->listWidget->setInstantDelete(true);
         $this->listWidget->setColspecs(array('*'));
         $this->listWidget->setWidth("100%");
         $this->listWidget->setHeight("70px");
         $this->listWidget->setAcl("");
+
+        $acls = "";
+        $acls.= ($this->writeable && $this->enabled) ? 'wdmc' : '';
+        $acls.= ($this->readable) ? 'r' : '';
+        $this->listWidget->setAcl($acls);
+        $this->listWidget->setListData($this->value);
+        $this->listWidget->update();
     }
 
 
     function render()
     {
-        $str = "";
-        $this->listWidget->setDeleteable($this->enabled);
-        $this->listWidget->setListData($this->value);
-        $this->listWidget->update();
-        $str .= $this->listWidget->render();
+        $str = $this->listWidget->render();
         $disabled = (!$this->enabled || !$this->writeable)? "disabled" : "";
         $name = (!$this->enabled || !$this->writeable)? "dummy".rand(0,10000) : $this->postName;
 
-        $acls = "";
-        $acls.= ($this->writeable && $this->enabled) ? 'w' : '';
-        $acls.= ($this->readable) ? 'r' : '';
-        $this->listWidget->setAcl($acls);
-
         $str .= "<input type='text' name='{$name}_Input' {$disabled}>";
         $str .= "<button name='{$name}_Add' {$disabled}>".msgPool::addButton()."</button>";
         return($str);
@@ -40,22 +39,16 @@ class TemplateWidget_list extends TemplateWidget
     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;
+                $this->listWidget->addEntry($input);
             }
         }
+
+        $this->value = $this->listWidget->getMaintainedData();
     }
 
     /*! \brief  Check the value entry using the provieded syntax.