From 5b97b2637c79d6b7a18de3e24aff20b16f513d64 Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 3 Mar 2010 20:25:44 +0000 Subject: [PATCH] finished support for lableFormat for auto-widgets that use filtering selects git-svn-id: svn://svn.open-ils.org/ILS/trunk@15684 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../web/js/dojo/openils/widget/AutoFieldWidget.js | 42 ++-------------------- 1 file changed, 3 insertions(+), 39 deletions(-) diff --git a/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js b/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js index 4ffca5b8d..158628058 100644 --- a/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js +++ b/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js @@ -377,52 +377,16 @@ if(!dojo._hasResource['openils.widget.AutoFieldWidget']) { this.widget.searchAttr = this.widget.labelAttr = vfield.selector || vfield.name; this.widget.valueAttr = vfield.name; - /* - var setLabelFunc = function(linkedObjectStore) { - self.widget.labelFunc = function(val) { return 'FOO'} ; - return; - if(self.labelFormat) { - self.widget.labelFunc = function(val) { - - try { - - // find the linked item in the remote object store - var query = {}; - var linkedItem; - query[fieldmapper.IDL.fmclasses[linkClass].pkey] = ''+self.widgetValue; - - // find the linked object whose pkey == this widget's value - linkedObjectStore.fetch({ - query: query, - onComplete: function(list) { linkedItem = list[0]; } - }); - - // find the values from the linked item in the remote object store - var format = self.labelFormat[0]; - var values = []; - for(var i = 1; i< self.labelFormat.length; i++) - values.push(linkedObjectStore.getValue(linkedItem, self.labelFormat[i])); - - // format the label string w/ the extracted linked object values - return dojo.string.substitute(format, values); - - } catch (E) { - throw new Error('AutoFieldWidget: bad label format [' + format + ':' + values + '] ' + E); - } - }; - } - } - */ - var oncomplete = function(list) { if(self.labelFormat) - self.widget.labelAttr = '_label'; + self.widget.labelAttr = self.widget.searchAttr = '_label'; if(list) { var storeData = {data:fieldmapper[linkClass].toStoreData(list)}; if(self.labelFormat) { + // set the label for each value in the store based on the provide label format var format = self.labelFormat[0]; dojo.forEach(storeData.data.items, @@ -433,7 +397,6 @@ if(!dojo._hasResource['openils.widget.AutoFieldWidget']) { item._label = dojo.string.substitute(format, values); } ); - console.log(js2JSON(storeData)); } self.widget.store = new dojo.data.ItemFileReadStore(storeData); @@ -441,6 +404,7 @@ if(!dojo._hasResource['openils.widget.AutoFieldWidget']) { } else { self.widget.store = self.cache[self.auth].list[linkClass]; } + self.widget.startup(); self._widgetLoaded(); }; -- 2.11.0