Mercurial > hg > fapweb
changeset 759:3069a13e78dd
Make compo ID changing more pleasant.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 20 Nov 2014 09:27:33 +0200 |
parents | 3b973041f6bb |
children | be0f465de86c |
files | admajax.php admin.js |
diffstat | 2 files changed, 24 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/admajax.php Thu Nov 20 09:19:16 2014 +0200 +++ b/admajax.php Thu Nov 20 09:27:33 2014 +0200 @@ -261,11 +261,30 @@ switch ($mode) { case 1: + $sql = + "SELECT compos.*, ". + "COUNT(DISTINCT entries.id) AS nentries ". + "FROM compos LEFT JOIN entries ON compos.id=entries.compo_id ". + "GROUP BY compos.id ". + "ORDER BY compos.id DESC"; + echo " <div class=\"entryCell\">". - 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(".$item["compo_id"].",".$eid.")"). + stGetFormOptionListStart($prefix."compo_id".$eid, " ", TRUE, 0); + + foreach (stExecSQL($sql) as $cdata) + { + echo stGetFormOptionListItem(" ", + $cdata["id"], + ($cdata["id"] == $item["compo_id"]), + sprintf("%-20s (%d entries)", substr($cdata["name"], 0, 20), $cdata["nentries"]) + ); + } + + echo + stGetFormOptionListEnd(" ", TRUE). + stGetFormButtonInput("update", $eid, $prefix, "Update", "updateEntry(".$item["compo_id"].",".$eid.")"). + stGetFormButtonInput("delete", $eid, $prefix, "Delete", "deleteEntry(".$item["compo_id"].",".$eid.")"). "</div>\n"; break;
--- a/admin.js Thu Nov 20 09:19:16 2014 +0200 +++ b/admin.js Thu Nov 20 09:27:33 2014 +0200 @@ -447,7 +447,7 @@ function updateEntry(cid, id) { - var args = jsMakePostArgs({"name":1, "author":1, "filename":1, "info":1, "notes":1, "compo_id":2, "evalue":2, "preview_type":4}, "en", id, true); + var args = jsMakePostArgs({"name":1, "author":1, "filename":1, "info":1, "notes":1, "compo_id":4, "evalue":2, "preview_type":4}, "en", id, true); var compo_id = lastPostArgs["compo_id"]; var msuccess = function(txt) @@ -475,7 +475,7 @@ if (args != "") { if (cid != compo_id) - jsConfirmBox("Are you sure you want to change entry #"+id+"'s compo_id from "+cid+" to "+compo_id+"?", mcb_ok, mcb_cancel); + jsConfirmBox("Are you sure you want to change entry #"+id+"'s compo from "+cid+" to "+compo_id+"?", mcb_ok, mcb_cancel); else mcb_ok(); }