changeset 289:b91e92f18cac

Make changing of entry's compo_id to work in a somewhat more userfriendly manner.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 25 Nov 2013 00:25:29 +0200
parents 58d28d5d6b9f
children 3640f2311e1c
files admajax.php admin.php
diffstat 2 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/admajax.php	Mon Nov 25 00:16:48 2013 +0200
+++ b/admajax.php	Mon Nov 25 00:25:29 2013 +0200
@@ -117,7 +117,7 @@
     "   <td>".
     stGetFormButtonInput("delete", $eid, $prefix, "Del", "deleteEntry(".$item["compo_id"].",".$eid.")").
     stGetFormTextInput(3, 3, "compo_id", $eid, $prefix, $item["compo_id"]).
-    stGetFormButtonInput("update", $eid, $prefix, "Upd", "updateEntry(".$eid.")").
+    stGetFormButtonInput("update", $eid, $prefix, "Upd", "updateEntry(".$item["compo_id"].",".$eid.")").
     "</td>\n";
 }
 
--- a/admin.php	Mon Nov 25 00:16:48 2013 +0200
+++ b/admin.php	Mon Nov 25 00:25:29 2013 +0200
@@ -347,18 +347,26 @@
 
   if (args != "")
     sendPOSTRequest("action=add&type=entry&compo_id="+id+"&"+args, msuccess);
+
   return false;
 }
 
 
-function updateEntry(id)
+function updateEntry(cid, id)
 {
   var args = makePostArgs({"name":1, "author":1, "filename":1, "info":1, "compo_id":2}, "en", id);
+  var compo_id = lastPostArgs["compo_id"];
 
   var msuccess = function(txt)
   {
-    // Full update needed, because of possibly changed compo_id
-    setTimeout("refreshCMEntry("+ id +");", 50);
+    if (cid != compo_id)
+    {
+      var nitem = document.getElementById("entry"+ id);
+      if (nitem)
+        nitem.style.display = "none";
+    }
+    else
+      setTimeout("refreshCMEntry("+ id +");", 50);
   }
 
   if (args != "")