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l?*s ze?zTXxztO1uk&ZjA)a=x8B?qg*Wd@(j&U6F814wr=%#TQw_rD?Xu%X_Vi{>Gz7=)j z3#ihkRhV&kdlq%$uTdK(a6PT>!5aM5^>gp{=0Alk#807~Dv 2=R7TQq#FL4hpAXv)z zc8tbx0?`kf-HG4ejX1N44+wKmzlLJeL2K|4?8FE>>m0{0`WG=2gDFEMM&b-CK$X4% zBXJm$Ip02~p_@%$2>PgZbr4lR_1k$URb(?p;nS#!yo5WM*N O&VlftvpX z>Ir{B?f)nG&>B6%8mYfFh$WzpE)fsn7R<%DO_U4QVjjMaN@yHa(n+ks@bzX-U^A+J z4mV>t*AK-{QR~j268`~J$ITD@f@e@0O}Y5AR&P83mB<2| zkA76b4OogtP>Bcg!IWSj-h@4_KM yNR%LFy9JR0#gR$Ag zH@NuY7)!hdr(qxJ0 Date: Thu, 28 May 2015 15:46:56 +0200 Subject: [PATCH 03/12] Visually select relation object in sortable / filterable item list inside a Lity lightbox --- item_relations_form.php | 62 +++++-- item_relations_script.js | 197 ++++++++++++++++++++ item_relations_styles.css | 12 ++ languages/de_DE.mo | Bin 29990 -> 30391 bytes languages/de_DE.po | 38 +++- languages/template.pot | 34 +++- lity/lity.css | 160 ++++++++++++++++ lity/lity.js | 373 ++++++++++++++++++++++++++++++++++++++ lity/lity.min.css | 3 + lity/lity.min.js | 4 + 10 files changed, 866 insertions(+), 17 deletions(-) create mode 100644 item_relations_script.js create mode 100644 item_relations_styles.css create mode 100644 lity/lity.css create mode 100644 lity/lity.js create mode 100644 lity/lity.min.css create mode 100644 lity/lity.min.js diff --git a/item_relations_form.php b/item_relations_form.php index 5ee0fda..a209df2 100644 --- a/item_relations_form.php +++ b/item_relations_form.php @@ -38,20 +38,56 @@ - + + + + +Item} items + LEFT JOIN {$db->Element_Texts} elementtexts on (items.id=elementtexts.id) + LEFT JOIN {$db->Item_Types} itemtypes on (items.item_type_id=itemtypes.id) + WHERE true + ORDER BY itemtypes.name ASC, text ASC"; + + $items = $db->fetchAll($sql); + + # echo " formSelect('item_relations_property_id[]', null, array('multiple' => false), $formSelectProperties); ?> -formText('item_relations_item_relation_object_item_id[]', null, array('size' => 8)); ?> -n/a ++ + +
+ []
+ formText('item_relations_item_relation_object_item_id[]', null, array('size' => 8)); ?> + + "; print_r($items); echo "\n"; # DEBUG + echo "\n"; +?> + \ No newline at end of file diff --git a/item_relations_script.js b/item_relations_script.js new file mode 100644 index 0000000..e1bcdfb --- /dev/null +++ b/item_relations_script.js @@ -0,0 +1,197 @@ +jQuery(document).ready(function () { + + var $ = jQuery; // use noConflict version of jQuery as the short $ within this block + var lightbox = lity(); // Lity lightbox for item selector "popup" + + var my_input = null; // Reference to currently active input + var allItemsSortedArr = null; // Room for a pre-sorted array + var itemTypes = null; // Room for the pre-calculated item types + var filterItemTyp = null; // Room for filter by type + var curListOrder = null; // Room for sort order + var curFilter = null; // Room for filter word + + // --- START: moved from \n"; + // --- 1. Fetch all item typs together with ther IDs and names + $sql = "SELECT id, name from {$db->Item_Types} ORDER BY id"; + $itemtypes = $db->fetchAll($sql); + $lines=array(); + $lines[]="0:'".__("[n/a]")."'"; + foreach($itemtypes as $itemtyp) { + $lines[]=$itemtyp["id"].":'".htmlspecialchars($itemtyp["name"], ENT_QUOTES)."'"; + } + // JavaScript object + echo "var itemTypes={\n". + implode(",\n",$lines)."\n". + "};\n"; + // --- 2. Fetch all items together with their IDs, titles, and item type IDs and names + $sql = "SELECT items.id, text, item_type_id, UNIX_TIMESTAMP(modified) FROM {$db->Item} items LEFT JOIN {$db->Element_Texts} elementtexts on (items.id=elementtexts.id) - LEFT JOIN {$db->Item_Types} itemtypes on (items.item_type_id=itemtypes.id) WHERE true - ORDER BY itemtypes.name ASC, text ASC"; - + ORDER BY items.item_type_id ASC, text ASC"; $items = $db->fetchAll($sql); - - # echo ""; print_r($items); echo "\n"; # DEBUG - echo "\n"; diff --git a/item_relations_script.js b/item_relations_script.js index e1bcdfb..1f37a80 100644 --- a/item_relations_script.js +++ b/item_relations_script.js @@ -5,7 +5,6 @@ jQuery(document).ready(function () { var my_input = null; // Reference to currently active input var allItemsSortedArr = null; // Room for a pre-sorted array - var itemTypes = null; // Room for the pre-calculated item types var filterItemTyp = null; // Room for filter by type var curListOrder = null; // Room for sort order var curFilter = null; // Room for filter word @@ -65,13 +64,12 @@ jQuery(document).ready(function () { $("#searchTerm").on("input",searchTermChange); $("#resetBtn").click("input",resetBtnClick); + $("#itemTypeIds").empty().append(itemTypeOptions()); $('input:radio[name=itemsListSort]').change(function() { curListOrder=this.value; updateList(); }); selectObjectSortTimestamp(); // fill item selector - // finally fill item type selector, based on item selector pre-processing - $("#itemTypeIds").empty().append(itemTypeOptions()); lightbox.open("#selectObjectId"); // and off we go @@ -99,7 +97,7 @@ jQuery(document).ready(function () { allItemsSortedArr=allItemsArr.slice(); // correct operation to copy an array allItemsSortedArr.sort(function(a,b) { // sort it via compare function var catdiff=a[2]-b[2]; // different category? then sort asc for that - return ( catdiff==0 ? (b[4]-a[4]) : catdiff ); // otherwise sort desc for timestamp + return ( catdiff==0 ? (b[3]-a[3]) : catdiff ); // otherwise sort desc for timestamp }); } $("#allItemIds").empty().append(allItemsOptions(allItemsSortedArr)); @@ -113,10 +111,7 @@ jQuery(document).ready(function () { var opencat=false; var lastcat=-1; - var fillItemTypes=(itemTypes==null); // no itemTypes array yet? - if (fillItemTypes) { itemTypes=new Array(); } - - var result=""; + var result=""; $.each(ItemsArr, function (itemIndex, item) { // all items var showThisItem=true; @@ -135,8 +130,7 @@ jQuery(document).ready(function () { opencat=false; } if (!opencat) { // no currently open group? - var groupname=( item[3]!='0' ? String(item[3]) : nATxt); - if (fillItemTypes) { itemTypes[item[2]]=groupname; } // also store group name + var groupname=itemTypes[item[2]]; result+="