]> git.andy128k.dev Git - ipf.git/commitdiff
more customizable orderable
authoravl <alex.litovchenko@gmail.com>
Wed, 25 Mar 2009 10:32:40 +0000 (12:32 +0200)
committeravl <alex.litovchenko@gmail.com>
Wed, 25 Mar 2009 10:32:40 +0000 (12:32 +0200)
ipf/admin/templates/admin/items.html
ipf/admin/views.php
ipf/orm/record.php

index 3f3b046014b44c62eabafd4262ee6be19746a349..c32ed12ca94e415d96595242dd381fffb55a565e 100644 (file)
@@ -17,7 +17,7 @@ $(document).ready(function()
        $('#items-grid').tableDnD({
         onDragClass: "ItemsDragClass",
                onDrop: function(table, row) {
-            $.post(reorder_url, {'ids': $.tableDnD.serialize()}, function(data){});
+            $.post(reorder_url, {'ids': $.tableDnD.serialize(), 'drop_id':row.id}, function(data){});
         }
        });
 });
index 16720ac95331d737562e6424041ee2842bc79620..80c5761697c970dbbf4b79f229e5625d6949b026 100644 (file)
@@ -85,9 +85,14 @@ function IPF_Admin_Views_Reorder($request, $match){
     if (!isset($request->POST['ids']))
        return new IPF_HTTP_Response_NotFound();
 
+    if (!isset($request->POST['drop_id']))
+       return new IPF_HTTP_Response_NotFound();
+    $drop_id = $request->POST['drop_id'];
+
     $lapp = $match[1];
     $lmodel = $match[2];
 
+
     foreach (IPF_Project::getInstance()->appList() as $app){
         foreach($app->modelList() as $m){
             if (strtolower($m)==$lmodel){
@@ -102,7 +107,7 @@ function IPF_Admin_Views_Reorder($request, $match){
 
                 $o = new $m();
                 $ids = split(',',(string)$request->POST['ids']);
-                $o->_reorder($ids, $ord_field);
+                $o->_reorder($ids, $ord_field, $drop_id);
                            return new IPF_HTTP_Response_Json("Ok");
             }
         }
index 42a86fb24e5010a385cd39faf098f2b846646e46..6333a3490134f2ee0d06b1e69ac31824aedc3603 100644 (file)
@@ -1296,7 +1296,7 @@ abstract class IPF_ORM_Record extends IPF_ORM_Record_Abstract implements Countab
        return null;
     }
 
-    public function _reorder($ids, $ord_field){
+    public function _reorder($ids, $ord_field, $drop_id){
         $ord = 1;
         foreach($ids as $id){
             $item = $this->getTable()->find($id);