From 2809bd260565adcde6063b8b8324585b64ee328e Mon Sep 17 00:00:00 2001 From: cajus Date: Fri, 8 Jan 2010 17:21:16 +0000 Subject: [PATCH] Updated sortableListing git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15131 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/html/include/dragdrop.js | 2 +- gosa-core/html/themes/default/style.css | 9 -- gosa-core/include/class_sortableListing.inc | 139 +++++++++++++++++--- 3 files changed, 125 insertions(+), 25 deletions(-) diff --git a/gosa-core/html/include/dragdrop.js b/gosa-core/html/include/dragdrop.js index 07c98e2bd..e51439e38 100644 --- a/gosa-core/html/include/dragdrop.js +++ b/gosa-core/html/include/dragdrop.js @@ -972,4 +972,4 @@ Element.findChildren = function(element, only, recursive, tagName) { Element.offsetSize = function (element, type) { return element['offset' + ((type=='vertical' || type=='height') ? 'Height' : 'Width')]; -}; \ No newline at end of file +}; diff --git a/gosa-core/html/themes/default/style.css b/gosa-core/html/themes/default/style.css index 695ecbecb..74282e289 100644 --- a/gosa-core/html/themes/default/style.css +++ b/gosa-core/html/themes/default/style.css @@ -1956,12 +1956,3 @@ table.sortableListTable { border: 0px; } -div.dropmarker { - height:1px; - border-top:1px solid #A00; - color: #fff; - z-index:1000; - margin : 0 0 0 0; -} - - diff --git a/gosa-core/include/class_sortableListing.inc b/gosa-core/include/class_sortableListing.inc index 53c61c34e..d023584cf 100644 --- a/gosa-core/include/class_sortableListing.inc +++ b/gosa-core/include/class_sortableListing.inc @@ -31,6 +31,14 @@ class sortableListing { private $data= array(); private $columns= 0; + private $deletable= false; + private $editable= false; + private $instantDelete= true; + private $action; + private $targets; + private $mapping; + private $current_mapping; + private $active_index; function sortableListing($data= array()) { @@ -54,6 +62,9 @@ class sortableListing { // Transfer information $this->data= $data; + // Create initial mapping + $this->mapping= array_keys($data); + // Find the number of coluns reset($this->data); $first= current($this->data); @@ -62,7 +73,6 @@ class sortableListing { } else { $this->columns= 1; } - } @@ -72,6 +82,24 @@ class sortableListing { } + function setInstantDelete($flag) + { + $this->instantDelete= $flag; + } + + + function setEditable($flag) + { + $this->editable= $flag; + } + + + function setDeleteable($flag) + { + $this->deleteable= $flag; + } + + function setHeight($height) { $this->height= $height; @@ -98,8 +126,11 @@ class sortableListing { function render() { - $result= "
\n"; + $result= "
\n"; $result.= "cssclass)?" class='".$this->cssclass."'":"").">\n"; + $action_width= 0; + $edit_image= $this->editable?"":""; + $delete_image= $this->deleteable?"":""; // Do we need colspecs? if ($this->colspecs) { @@ -107,6 +138,12 @@ class sortableListing { for ($i= 0; $i<$this->columns; $i++) { $result.= " \n"; } + + // Extend by another column if we've actions specified + $action_width= ($this->editable?20:0) + ($this->deleteable?20:0); + if ($action_width) { + $result.= " \n"; + } $result.= " \n"; } @@ -114,36 +151,41 @@ class sortableListing { if ($this->header) { $result.= " \n \n"; for ($i= 0; $i<$this->columns; $i++) { - $result.= " \n"; + $result.= " "; } - $result.= " \n \n"; + if ($action_width) { + $result.= ""; + } + $result.= "\n \n \n"; } // Render table body $result.= " \n"; - foreach ($this->data as $nr => $row) { - $result.= " \n"; - foreach ($row as $column) { + foreach ($this->mapping as $nr => $row) { + $result.= " \n"; + foreach ($this->data[$row] as $column) { $result.= " \n"; } + if ($action_width) { + $result.= ""; + } $result.= " \n"; } $result.= " \n
".(isset($this->header[$i])?$this->header[$i]:"")."".(isset($this->header[$i])?$this->header[$i]:"")."
 
".htmlentities($column)."".str_replace('%ID', "edit_".$this->id."_$nr", $edit_image). + str_replace('%ID', "del_".$this->id."_$nr", $delete_image)."
\n
\n"; - $result.= "