if (!dojo._hasResource["openils.AutoSuggestStore"]) {
dojo._hasResource["openils.AutoSuggestStore"] = true;
+
dojo.provide("openils.AutoSuggestStore");
+
+ dojo.require("dojo.cookie");
+ dojo.require("DojoSRF");
dojo.require("openils.Util");
/* Here's an exception class specific to openils.AutoSuggestStore */
TermString.prototype.substr=function(){return this.str.substr(arguments);};
var _autosuggest_fields = ["id", "match", "term", "field"];
- var _cmf_cache, _cmc_cache;
dojo.declare(
"openils.AutoSuggestStore", null, {
if (this.cm_cache[key]) return oncomplete();
/* now try talking to fielder ourselves, and cache the result */
- (new OpenSRF.ClientSession("open-ils.fielder"))({
+ var pkey = field_list[0];
+ var query = {};
+ query[pkey] = {"!=": null};
+
+ (new OpenSRF.ClientSession("open-ils.fielder")).request({
"method": "open-ils.fielder." + key + ".atomic",
- "params": [
- {"query": {"id": {"!=": null}, "fields": field_list}}
- ],
+ "params": [{"query": query, "fields": field_list}],
"async": true,
"oncomplete": function(r) {
/* XXX check for failure? */
self.cm_cache[key] = {};
dojo.forEach(
result_arr,
- function(o) { self.cm_cache[key][o.id] = o; }
+ function(o) { self.cm_cache[key][o[pkey]] = o; }
);
dojo.cookie(
"OILS_AS" + key, dojo.toJson(self.cm_cache[key])
);
- console.log("finished fetching " + key + " from fielder");
oncomplete();
}
}).send();
var field_lists = {
"cmf": ["id", "field_class", "name", "label"],
- "cmc": ["id", "name", "label"]
+ "cmc": ["name", "label"]
};
var class_list = openils.Util.objectProperties(field_lists);
- var _is_done = function(k) { return Boolean(self.cm_cache[k]); };
+ var is_done = function(k) { return Boolean(self.cm_cache[k]); };
dojo.forEach(
class_list, function(key) {
self._setup_config_metabib_cache(
key, field_lists[key], function() {
- if (dojo.every(class_list, _is_done)) {
- self.cm_cache._is_done = true;
+ if (dojo.every(class_list, is_done)) {
+ self.cm_cache.is_done = true;
}
}
)
// callback to the *req* object for the caller's use, but
// the one we provide does nothing but issue an alert().
- if (!this.cm_cache._is_done) {
+ if (!this.cm_cache.is_done) {
if (typeof req.onComplete == "function")
req.onComplete.call(callback_scope, [], req);
return;
}
-
this._current_items = {};
var callback_scope = req.scope || dojo.global;