From ae3e199391c862a9014ff4d5908c0ba519156bbb Mon Sep 17 00:00:00 2001 From: erickson Date: Thu, 20 Aug 2009 16:04:35 +0000 Subject: [PATCH] beginning of a filter dialog for pcrud requests. users select columns and values from autofieldwidgets. the eventual goal is to provide filter options for autogrid git-svn-id: svn://svn.open-ils.org/ILS/trunk@13903 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../js/dojo/openils/widget/PCrudFilterDialog.js | 80 ++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 Open-ILS/web/js/dojo/openils/widget/PCrudFilterDialog.js diff --git a/Open-ILS/web/js/dojo/openils/widget/PCrudFilterDialog.js b/Open-ILS/web/js/dojo/openils/widget/PCrudFilterDialog.js new file mode 100644 index 0000000000..6fbd645b37 --- /dev/null +++ b/Open-ILS/web/js/dojo/openils/widget/PCrudFilterDialog.js @@ -0,0 +1,80 @@ + +if(!dojo._hasResource['openils.widget.PCrudFilterDialog']) { + dojo.provide('openils.widget.PCrudFilterDialog'); + dojo.require('openils.widget.AutoFieldWidget'); + dojo.require('dijit.form.FilteringSelect'); + dojo.require('dojo.data.ItemFileReadStore'); + dojo.require('dijit.Dialog'); + dojo.require('openils.Util'); + + /** + * Given a fieldmapper object, this builds a pop-up dialog used for editing the object + */ + + dojo.declare( + 'openils.widget.PCrudFilterDialog', + [dijit.Dialog, openils.widget.AutoWidget], + { + + constructor : function(args) { + for(var k in args) + this[k] = args[k]; + }, + + /** + * Builds a basic table of key / value pairs. Keys are IDL display labels. + * Values are dijit's, when values set + */ + startup : function() { + this.inherited(arguments); + this.initAutoEnv(); + var realFieldList = this.sortedFieldList.filter( + function(item) { return !item.virtual; }); + this.fieldStore = new dojo.data.ItemFileReadStore({ + data : { + identifier : 'name', + name : 'label', + items : realFieldList.map( + function(item) { + return {label:item.label, name:item.name}; + } + ) + } + }); + + dojo.place( // TODO i18n/CSS + dojo.create( + 'div', + {innerHTML:'Filter Selector', style:'text-align:center;width:100%;padding:10px;'} + ), this.domNode); + + this.table = dojo.place(dojo.create('table'), this.domNode); + openils.Util.addCSSClass(this.table, 'oils-fm-edit-dialog'); + this.insertFieldSelector(); + }, + + insertFieldSelector : function() { + var selector = new dijit.form.FilteringSelect({labelAttr:'label', store:this.fieldStore}); + var row = dojo.place(dojo.create('tr'), this.table); + var selectorTd = dojo.place(dojo.create('td'), row); + var valueTd = dojo.place(dojo.create('td'), row); + dojo.place(selector.domNode, selectorTd); + + var self = this; + dojo.connect(selector, 'onChange', + function(value) { + if(valueTd.childNodes[0]) + valueTd.removeChild(valueTd.childNodes[0]); + var widget = new openils.widget.AutoFieldWidget({ + fmClass : self.fmClass, + fmField : value, + parentNode : dojo.place(dojo.create('div'), valueTd) + }); + widget.build(); + } + ); + } + } + ); +} + -- 2.11.0