From 4f94831857ce73cd08087e1a0bd8830e88aab567 Mon Sep 17 00:00:00 2001
From: senator <senator@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Date: Tue, 16 Feb 2010 15:11:37 +0000
Subject: [PATCH] Acq: POs can only be created with active providers (vendors)

Added a new feature to AutoFieldWidget to make this as simple: there's now
a searchFilter option that you can give to the constructor, enabling you
to constrain the set of objects that you'll get back for, say, a
FilteringSelect widget.


git-svn-id: svn://svn.open-ils.org/ILS/trunk@15546 dcc99617-32d9-48b4-a31d-7c20da2025e4
---
 .../web/js/dojo/openils/widget/AutoFieldWidget.js     | 19 ++++++++++++-------
 Open-ILS/web/js/ui/default/acq/common/li_table.js     |  1 +
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js b/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js
index afde4b50ff..b895e38f69 100644
--- a/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js
+++ b/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js
@@ -385,13 +385,18 @@ if(!dojo._hasResource['openils.widget.AutoFieldWidget']) {
                 oncomplete();
 
             } else {
-                new openils.PermaCrud().retrieveAll(linkClass, {   
-                    async : !this.forceSync,
-                    oncomplete : function(r) {
-                        var list = openils.Util.readResponse(r, false, true);
-                        oncomplete(list);
-                    }
-                });
+                var _cb = function(r) {
+                    oncomplete(openils.Util.readResponse(r, false, true));
+                };
+                if (this.searchFilter) {
+                    new openils.PermaCrud().search(linkClass, this.searchFilter, {
+                        async : !this.forceSync, oncomplete : _cb
+                    });
+                } else {
+                    new openils.PermaCrud().retrieveAll(linkClass, {
+                        async : !this.forceSync, oncomplete : _cb
+                    });
+                }
             }
 
             return true;
diff --git a/Open-ILS/web/js/ui/default/acq/common/li_table.js b/Open-ILS/web/js/ui/default/acq/common/li_table.js
index bed0e8fb3c..b605fecff8 100644
--- a/Open-ILS/web/js/ui/default/acq/common/li_table.js
+++ b/Open-ILS/web/js/ui/default/acq/common/li_table.js
@@ -973,6 +973,7 @@ function AcqLiTable() {
                     var widget = new openils.widget.AutoFieldWidget({
                         fmField : 'provider',
                         fmClass : 'acqpo',
+                        searchFilter: {"active": "t"},
                         parentNode : dojo.byId('acq-lit-po-provider'),
                     });
                     widget.build(
-- 
2.11.0