From a1582e51c99f59e8afabb8d3e319301a9cf5ea04 Mon Sep 17 00:00:00 2001 From: Lebbeous Fogle-Weekley Date: Mon, 26 Mar 2012 15:28:26 -0400 Subject: [PATCH] :wq;lsdkfjpasdhflajhf Signed-off-by: Lebbeous Fogle-Weekley --- Open-ILS/src/templates/conify/flattener_test.tt2 | 52 ++++++++++++--- Open-ILS/web/js/dojo/openils/FlattenerStore.js | 2 +- .../web/js/dojo/openils/widget/FlattenerGrid.js | 73 ++++++++++++++++++++-- 3 files changed, 113 insertions(+), 14 deletions(-) diff --git a/Open-ILS/src/templates/conify/flattener_test.tt2 b/Open-ILS/src/templates/conify/flattener_test.tt2 index ffc6613a97..85fe5a989d 100644 --- a/Open-ILS/src/templates/conify/flattener_test.tt2 +++ b/Open-ILS/src/templates/conify/flattener_test.tt2 @@ -1,9 +1,13 @@ [% WRAPPER base.tt2 %] [% ctx.page_title = 'Flattener Test' %] + query="{__id: '*'}" + > - - - - - + + + + +
Part NumberMinimum TemperatureMaximum TemperatureTypeThicknessBarcodeCirculation Library NameCirculation LibraryCall NumberTCN
diff --git a/Open-ILS/web/js/dojo/openils/FlattenerStore.js b/Open-ILS/web/js/dojo/openils/FlattenerStore.js index 7e763c2fd4..6922642b53 100644 --- a/Open-ILS/web/js/dojo/openils/FlattenerStore.js +++ b/Open-ILS/web/js/dojo/openils/FlattenerStore.js @@ -124,7 +124,7 @@ if (!dojo._hasResource["openils.FlattenerStore"]) { if (typeof something != "object" || something === null) return false; - var fields = + var fields = []; for (var i = 0; i < _autosuggest_fields.length; i++) { var cur = _autosuggest_fields[i]; diff --git a/Open-ILS/web/js/dojo/openils/widget/FlattenerGrid.js b/Open-ILS/web/js/dojo/openils/widget/FlattenerGrid.js index eb1b563e66..0ff31b964d 100644 --- a/Open-ILS/web/js/dojo/openils/widget/FlattenerGrid.js +++ b/Open-ILS/web/js/dojo/openils/widget/FlattenerGrid.js @@ -1,14 +1,79 @@ -if (!dojo._hasResource["openils.widget.FlatGrid"]) { +if (!dojo._hasResource["openils.widget.FlattenerGrid"]) { dojo.provide("openils.widget.FlattenerGrid"); - dojo.require("dijit.form.Button"); - dojo.require("dijit.layout.ContentPane"); dojo.require("dojox.grid.DataGrid"); + dojo.require("openils.FlattenerStore"); dojo.declare( "openils.widget.FlattenerGrid", [dojox.grid.DataGrid], { - "nothing": null + "columnReordering": true, + + "_generate_map": function() { + var map = this.mapClause = {}; + var fields = this.structure[0].cells[0]; + /* XXX TODO remove column from grid (or hide? or what?) + * when display is false */ + dojo.forEach( + fields, + function(field) { + if (field.fpath) { + if ("fdisplay" in field || + "fsort" in field || + "ffilter" in field) { + map[field.field] = { + "display": (field.fdisplay || false), + "filter": (field.ffilter || false), + "sort": (field.fsort || false) + }; + } else { + map[field.field] = { + "path": field.fpath, + "sort": true, + "filter": true, + "display": true + }; + } + } + } + ); + + return map; + }, + + "startup": function() { + if (!this.store) { + this.store = new openils.FlattenerStore({ + "fmClass": this.fmClass, + "mapClause": (this.mapClause || this._generate_map()) + }); + } + } } ); + + /* monkey patch so we can get more attributes from each column in the + * markup that specifies grid columns (table->thead->tr->[td,...]) + */ + (function() { + var b = dojox.grid.cells._Base; + var orig_mf = b.markupFactory; + + b.markupFactory = function(node, cellDef) { + orig_mf(node, cellDef); + + dojo.forEach( + ["fpath", "fdisplay", "fsort", "ffilter"], + function(a) { + var value = dojo.attr(node, a); + if (value) + cellDef[a] = value; + } + ); + }; + })(); + + /* the secret to successfully subclassing dojox.grid.DataGrid */ + openils.widget.FlattenerGrid.markupFactory = + dojox.grid.DataGrid.markupFactory; } -- 2.11.0