From 7c789ed66812b4cfe64598774f4c5cb61622b3e7 Mon Sep 17 00:00:00 2001 From: erickson Date: Tue, 2 Nov 2010 03:00:57 +0000 Subject: [PATCH] AutoFieldWidget linked class autoloaders, etc. * leave linked selector disabled until entries are fetched; * added support for applying default linked class object loaders; * added default loader for acq providers, since large sets of providers can take an excessive amount of time w/ direct pcrud call. git-svn-id: svn://svn.open-ils.org/ILS/trunk@18572 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../web/js/dojo/openils/widget/AutoFieldWidget.js | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js b/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js index e6ec7c917..3fff2b14d 100644 --- a/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js +++ b/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js @@ -413,8 +413,10 @@ if(!dojo._hasResource['openils.widget.AutoFieldWidget']) { this.widget = new dijit.form.FilteringSelect(this.dijitArgs, this.parentNode); this.widget.searchAttr = this.widget.labelAttr = vfield.selector || vfield.name; this.widget.valueAttr = vfield.name; + this.widget.attr('disabled', true); var oncomplete = function(list) { + self.widget.attr('disabled', false); if(self.labelFormat) self.widget.labelAttr = '_label'; @@ -477,6 +479,9 @@ if(!dojo._hasResource['openils.widget.AutoFieldWidget']) { } else { + if(!this.dataLoader && openils.widget.AutoFieldWidget.defaultLinkedDataLoader[linkClass]) + this.dataLoader = openils.widget.AutoFieldWidget.defaultLinkedDataLoader[linkClass]; + if(this.dataLoader) { // caller provided an external function for retrieving the data @@ -651,5 +656,30 @@ if(!dojo._hasResource['openils.widget.AutoFieldWidget']) { openils.widget.AutoFieldWidget.localeStrings = dojo.i18n.getLocalization("openils.widget", "AutoFieldWidget"); openils.widget.AutoFieldWidget.cache = {}; + openils.widget.AutoFieldWidget.defaultLinkedDataLoader = {}; + + /* Custom provider-as-link-class fetcher. Fitler is ignored. + * All viewable providers are retrieved. + */ + openils.widget.AutoFieldWidget.defaultLinkedDataLoader.acqpro = + function(linkClass, fitler, oncomplete) { + + fieldmapper.standardRequest( + ['open-ils.acq', 'open-ils.acq.provider.org.retrieve'], + { + async : true, + params : [openils.User.authtoken], + oncomplete : function(r) { + var resp; + var list = []; + while(resp = r.recv()) { + var pro = resp.content(); + if(pro) list.push(pro); + } + oncomplete(list); + } + } + ); + } } -- 2.11.0