called 'fmclasses' to be fleshed with the classes we need to build */
function FMEX(message) { this.message = message; }
- FMEX.toString = function() { return "FieldmapperException: " + this.message + "\n"; }
+ FMEX.toString = function() { return "FieldmapperException: " + this.message + "\n"; };
dojo.declare( "fieldmapper.Fieldmapper", null, {
for( var i in this.a ) {
var thing = this.a[i];
- if(thing == null) continue;
+ if(thing === null) continue;
if( thing._isfieldmapper ) {
obj.a[i] = thing.clone();
} else {
if(dojo.isArray(thing)) {
- obj.a[i] = new Array();
+ obj.a[i] = [];
for( var j in thing ) {
this.classname = this.declaredClass;
this._fields = [];
+ var p, f;
if (fieldmapper.IDL && fieldmapper.IDL.loaded) {
- this.Structure = fieldmapper.IDL.fmclasses[this.classname]
+ this.Structure = fieldmapper.IDL.fmclasses[this.classname];
- for (var f in fieldmapper.IDL.fmclasses[this.classname].fields) {
+ for (f in fieldmapper.IDL.fmclasses[this.classname].fields) {
var field = fieldmapper.IDL.fmclasses[this.classname].fields[f];
- var p = field.array_position;
+ p = field.array_position;
this._fields.push( field.name );
this[field.name]=new Function('n', 'if(arguments.length==1)this.a['+p+']=n;return this.a['+p+'];');
}
this._fields = fmclasses[this.classname];
for( var pos = 0; pos < this._fields.length; pos++ ) {
- var p = parseInt(pos);
- var f = this._fields[pos];
+ p = parseInt(pos, 10);
+ f = this._fields[pos];
this[f]=new Function('n', 'if(arguments.length==1)this.a['+p+']=n;return this.a['+p+'];');
}
}
fieldmapper[cl].prototype.fromStoreItem = _fromStoreItem;
fieldmapper[cl].toStoreData = _toStoreData;
fieldmapper[cl].toStoreItem = _toStoreItem;
- fieldmapper[cl].prototype.toStoreItem = function ( args ) { return _toStoreItem(this, args) };
+ fieldmapper[cl].prototype.toStoreItem = function ( args ) { return _toStoreItem(this, args); };
fieldmapper[cl].initStoreData = _initStoreData;
fieldmapper[cl].prototype.toHash = _toHash;
fieldmapper[cl].toHash = _toHash;
if(!args.onmethoderror) {
args.onmethoderror = function(r, stat, stat_text) {
throw new Error('Method error: ' + r.stat + ' : ' + stat_text);
+ };
}
- }
if(!args.ontransporterror) {
args.ontransporterror = function(xreq) {
throw new Error('Transport error method='+args.method+', status=' + xreq.status);
+ };
}
- }
if (!args.onerror) {
args.onerror = function (r) {
throw new Error('Request error encountered! ' + r);
+ };
}
- }
if (!args.oncomplete) {
args.oncomplete = function (r) {
var x = r.recv();
if (x) result = x.content();
+ };
}
- }
args.method = meth[1];
if (staff && meth[2]) args.method += '.staff';
return result;
};
- fieldmapper.standardRequest = function (meth, params) { return fieldmapper._request(meth, false, params) };
+ fieldmapper.standardRequest = function (meth, params) { return fieldmapper._request(meth, false, params); };
fieldmapper.Fieldmapper.prototype.standardRequest = fieldmapper.standardRequest;
- fieldmapper.staffRequest = function (meth, params) { return fieldmapper._request(meth, true, params) };
+ fieldmapper.staffRequest = function (meth, params) { return fieldmapper._request(meth, true, params); };
fieldmapper.Fieldmapper.prototype.staffRequest = fieldmapper.staffRequest;
fieldmapper.OpenSRF = {};
//** FROM HASH **/
function _fromHash (_hash) {
for ( var i=0; i < this._fields.length; i++) {
- if (_hash[this._fields[i]] != null)
+ if (_hash[this._fields[i]] !== null)
this[this._fields[i]]( _hash[this._fields[i]] );
}
return this;
function _toHash (includeNulls, virtFields) {
var _hash = {};
- for ( var i=0; i < this._fields.length; i++) {
- if (includeNulls || this[this._fields[i]]() != null) {
- if (this[this._fields[i]]() == null)
+ var i;
+ for (i=0; i < this._fields.length; i++) {
+ if (includeNulls || this[this._fields[i]]() !== null) {
+ if (this[this._fields[i]]() === null)
_hash[this._fields[i]] = null;
else
_hash[this._fields[i]] = '' + this[this._fields[i]]();
}
if (virtFields && virtFields.length > 0) {
- for (var i = 0; i < virtFields.length; i++) {
+ for (i = 0; i < virtFields.length; i++) {
if (!_hash[virtFields[i]])
_hash[virtFields[i]] = null;
}
function _fromStoreItem (data) {
this.fromHash(data);
- for (var i = 0; this._ignore_fields && i < this._ignore_fields.length; i++)
+ var i;
+ for (i = 0; this._ignore_fields && i < this._ignore_fields.length; i++)
this[this._ignore_fields[i]](null);
- for (var i = 0; this._fields && i < this._fields.length; i++) {
+ for (i = 0; this._fields && i < this._fields.length; i++) {
if (dojo.isArray( this[this._fields[i]]() ))
this[this._fields[i]]( this[this._fields[i]]()[0] );
}
if (!params) params = {};
var data = this.initStoreData(label, params);
- for (var i = 0; list && i < list.length; i++) data.items.push( list[i].toHash(true, params.virtualFields) );
+ var i, j;
+ for (i = 0; list && i < list.length; i++) data.items.push( list[i].toHash(true, params.virtualFields) );
if (params.children && params.parent) {
var _hash_list = data.items;
var _find_root = {};
- for (var i = 0; _hash_list && i < _hash_list.length; i++) {
+ for (i = 0; _hash_list && i < _hash_list.length; i++) {
_find_root[_hash_list[i][params.identifier]] = _hash_list[i];
}
var item_data = [];
- for (var i = 0; _hash_list && i < _hash_list.length; i++) {
- var obj = _hash_list[i]
+ for (i = 0; _hash_list && i < _hash_list.length; i++) {
+ var obj = _hash_list[i];
obj[params.children] = [];
- for (var j = 0; _hash_list && j < _hash_list.length; j++) {
+ for (j = 0; _hash_list && j < _hash_list.length; j++) {
var kid = _hash_list[j];
if (kid[params.parent] == obj[params.identifier]) {
obj[params.children].push( { _reference : kid[params.identifier] } );
item_data.push( obj );
}
- for (var j in _find_root) {
+ for (j in _find_root) {
_find_root[j]['_top'] = 'true';
if (!_find_root[j][params.parent])
_find_root[j]['_trueRoot'] = 'true';
fieldmapper.aou.toStoreData = function (list, label) {
if (!label) label = 'shortname';
return _toStoreData.call(this, list, label, { 'parent' : 'parent_ou', 'children' : 'children' });
- }
+ };
fieldmapper.aout.toStoreData = function (list, label) {
if (!label) label = 'name';
return _toStoreData.call(this, list, label, { 'parent' : 'parent', 'children' : 'children' });
- }
+ };
fieldmapper.pgt.toStoreData = function (list, label) {
if (!label) label = 'name';
return _toStoreData.call(this, list, label, { 'parent' : 'parent', 'children' : 'children' });
- }
+ };
/** FROM dojoData **/
fieldmapper.IDL.fmclasses[c] = window._preload_fieldmapper_IDL[c];
window.fmclasses[c] = [];
- dojo.forEach(fieldmapper.IDL.fmclasses[c].fields, function(obj){ window.fmclasses[c].push(obj.name) });
+ dojo.forEach(fieldmapper.IDL.fmclasses[c].fields, function(obj){ window.fmclasses[c].push(obj.name); });
if (classlist && classlist.length)
classlist = dojo.filter(classlist, function(x){return x != c;});
};
window.fmclasses = {};
- fieldmapper.IDL.load = function (list) { if (!list) list = []; return new fieldmapper.IDL(list); };
+ fieldmapper.IDL.load = function (list) {
+ if (!list) list = [];
+ return new fieldmapper.IDL(list);
+ };
fieldmapper.IDL.loaded = false;
JSON2js.fallbackObjectifier = function (arg, key_name, val_name) {
console.log("Firing IDL loader for " + arg[key_name]);
fieldmapper.IDL.load([arg[key_name]]);
return decodeJS(arg);
- }
+ };
}
fieldmapper.aout.OrgTypeCache = {};
fieldmapper.aout.LoadOrgTypes = function () {
- for (var i in fieldmapper.aout.OrgTypeCache) {
+ var i;
+ for (i in fieldmapper.aout.OrgTypeCache) {
return;
}
var types = fieldmapper.standardRequest(['open-ils.actor','open-ils.actor.org_types.retrieve']);
- for (var i = 0; i < types.length; i++) {
+ for (i = 0; i < types.length; i++) {
fieldmapper.aout.OrgTypeCache[types[i].id()] = {
loaded : true,
type : types[i]
};
}
- }
+ };
fieldmapper.aou.LoadOrg = function (id, slim_ok) {
- if (slim_ok == null) slim_ok = fieldmapper.aou.slim_ok;
+ if (slim_ok === null) slim_ok = fieldmapper.aou.slim_ok;
var slim_o = fieldmapper.aou.OrgCache[id];
if (slim_o && (slim_ok || slim_o.loaded))
o.children = fieldmapper.aou.OrgCache[o.id()].children;
fieldmapper.aou.OrgCache[o.id()] = { loaded : true, org : o };
return o;
- }
+ };
fieldmapper.aou.findOrgUnit = fieldmapper.aou.LoadOrg;
if (window._l) {
for (var i in fieldmapper.aou.OrgCache) {
var x = fieldmapper.aou.OrgCache[i].org;
- if (x.parent_ou() == null || x.parent_ou() == '') {
+ if (x.parent_ou() === null || x.parent_ou() === '') {
fieldmapper.aou.globalOrgTree = x;
continue;
}
fieldmapper.aou.prototype.fetchOrgSettingDefault = function (name) {
return this.standardRequest( fieldmapper.OpenSRF.methods.FETCH_ORG_SETTING, [this.id(), name] );
- }
+ };
fieldmapper.aou.prototype.fetchOrgSettingBatch = function (nameList) {
return this.standardRequest( fieldmapper.OpenSRF.methods.FETCH_ORG_SETTING_BATCH, [this.id(), nameList] );
- }
+ };
fieldmapper.aou.fetchOrgSettingDefault = function (orgId, name) {
return fieldmapper.standardRequest( fieldmapper.OpenSRF.methods.FETCH_ORG_SETTING, [orgId, name] );
- }
+ };
fieldmapper.aou.fetchOrgSettingBatch = function (orgId, nameList) {
return fieldmapper.standardRequest( fieldmapper.OpenSRF.methods.FETCH_ORG_SETTING_BATCH, [orgId, nameList] );
- }
+ };
fieldmapper.aout.findOrgType = function (id) {
fieldmapper.aout.LoadOrgTypes();
return fieldmapper.aout.OrgTypeCache[id].type;
- }
+ };
fieldmapper.aou.prototype.findOrgDepth = function (id) {
if (!id) id = this.id;
return fieldmapper.aout.findOrgType(
fieldmapper.aou.findOrgUnit(id).ou_type()
).depth();
- }
+ };
fieldmapper.aou.findOrgDepth = fieldmapper.aou.prototype.findOrgDepth;
fieldmapper.aout.findOrgTypeFromDepth = function (depth) {
- if( depth == null ) return null;
+ if( depth === null ) return null;
fieldmapper.aout.LoadOrgTypes();
for( var i in fieldmapper.aout.OrgTypeCache ) {
var t = fieldmapper.aout.OrgTypeCache[i].type;
if( t.depth() == depth ) return t;
}
return null;
- }
+ };
fieldmapper.aou.findOrgUnitSN = function (sn, slim_ok) {
- if (slim_ok == null) slim_ok = fieldmapper.aou.slim_ok;
+ if (slim_ok === null) slim_ok = fieldmapper.aou.slim_ok;
var org = fieldmapper.aou.OrgCacheSN[sn];
if (!org) {
for (var i in fieldmapper.aou.OrgCache) {
}
return org;
- }
+ };
fieldmapper.aou.prototype.orgNodeTrail = function(node, asId) {
if (!node) node = this;
na.reverse();
if (asId) return na.map(function(o) { return o.id(); });
else return na;
- }
+ };
fieldmapper.aou.orgNodeTrail = fieldmapper.aou.prototype.orgNodeTrail;
fieldmapper.aou.prototype.orgIsMine = function (me, org) {
if(me.children()[i].orgIsMine(org)) return true;
}
return false;
- }
+ };
/** Given an org id, returns an array of org units including
* the org for the ID provided and all descendant orgs */
}
addNode(fieldmapper.aou.findOrgUnit(orgId));
return list;
- }
+ };
fieldmapper.aou.fullPath = function(orgId, asId) {
var orgList = fieldmapper.aou.orgNodeTrail(fieldmapper.aou.findOrgUnit(orgId));
orgList.pop(); // prevent dupes
- orgList = orgList.concat(fieldmapper.aou.descendantNodeList(orgId))
+ orgList = orgList.concat(fieldmapper.aou.descendantNodeList(orgId));
if(!asId) return orgList;
return orgList.map( function(node) { return node.id(); } );
- }
+ };
dojo.addOnUnload( function () {
for (var i in fieldmapper.aou.OrgCache) {
function _fromStoreItem (data) {
this.fromHash(data);
- for (var i = 0; this._ignore_fields && i < this._ignore_fields.length; i++)
+ var i;
+ for (i = 0; this._ignore_fields && i < this._ignore_fields.length; i++)
this[this._ignore_fields[i]](null);
- for (var i = 0; this._fields && i < this._fields.length; i++) {
+ for (i = 0; this._fields && i < this._fields.length; i++) {
if (dojo.isArray( this[this._fields[i]]() ))
this[this._fields[i]]( this[this._fields[i]]()[0] );
}
if (!params) params = {};
var data = this.initStoreData(label, params);
- for (var i = 0; list && i < list.length; i++) data.items.push( list[i].toHash(true, params.virtualFields) );
+ var i, j;
+ for (i = 0; list && i < list.length; i++) data.items.push( list[i].toHash(true, params.virtualFields) );
if (params.children && params.parent) {
var _hash_list = data.items;
var _find_root = {};
- for (var i = 0; _hash_list && i < _hash_list.length; i++) {
+ for (i = 0; _hash_list && i < _hash_list.length; i++) {
_find_root[_hash_list[i][params.identifier]] = _hash_list[i];
}
var item_data = [];
- for (var i = 0; _hash_list && i < _hash_list.length; i++) {
- var obj = _hash_list[i]
+ for (i = 0; _hash_list && i < _hash_list.length; i++) {
+ var obj = _hash_list[i];
obj[params.children] = [];
- for (var j = 0; _hash_list && j < _hash_list.length; j++) {
+ for (j = 0; _hash_list && j < _hash_list.length; j++) {
var kid = _hash_list[j];
if (kid[params.parent] == obj[params.identifier]) {
obj[params.children].push( { _reference : kid[params.identifier] } );
item_data.push( obj );
}
- for (var j in _find_root) {
+ for (j in _find_root) {
_find_root[j]['_top'] = 'true';
if (!_find_root[j][params.parent])
_find_root[j]['_trueRoot'] = 'true';
fieldmapper[i].prototype.fromStoreItem = _fromStoreItem;
fieldmapper[i].toStoreData = _toStoreData;
fieldmapper[i].toStoreItem = _toStoreItem;
- fieldmapper[i].prototype.toStoreItem = function ( args ) { return _toStoreItem(this, args) };
+ fieldmapper[i].prototype.toStoreItem = function ( args ) { return _toStoreItem(this, args); };
fieldmapper[i].initStoreData = _initStoreData;
}
fieldmapper.aou.toStoreData = function (list, label) {
if (!label) label = 'shortname';
return _toStoreData.call(this, list, label, { 'parent' : 'parent_ou', 'children' : 'children' });
- }
+ };
fieldmapper.aout.toStoreData = function (list, label) {
if (!label) label = 'name';
return _toStoreData.call(this, list, label, { 'parent' : 'parent', 'children' : 'children' });
- }
+ };
fieldmapper.pgt.toStoreData = function (list, label) {
if (!label) label = 'name';
return _toStoreData.call(this, list, label, { 'parent' : 'parent', 'children' : 'children' });
- }
+ };
/*
ppl.toStoreData = function (list, label) {
/* XXX Content loaded in Fieldmapper */
/* XXX deprecate this file **/
+ var i;
function _fromHash (_hash) {
- for ( var i=0; i < this._fields.length; i++) {
- if (_hash[this._fields[i]] != null)
+ for (i = 0; i < this._fields.length; i++) {
+ if (_hash[this._fields[i]] !== null)
this[this._fields[i]]( _hash[this._fields[i]] );
}
return this;
function _toHash (includeNulls, virtFields) {
var _hash = {};
- for ( var i=0; i < this._fields.length; i++) {
- if (includeNulls || this[this._fields[i]]() != null) {
- if (this[this._fields[i]]() == null)
+ for (i = 0; i < this._fields.length; i++) {
+ if (includeNulls || this[this._fields[i]]() !== null) {
+ if (this[this._fields[i]]() === null)
_hash[this._fields[i]] = null;
else
_hash[this._fields[i]] = '' + this[this._fields[i]]();
}
if (virtFields && virtFields.length > 0) {
- for (var i = 0; i < virtFields.length; i++) {
+ for (i = 0; i < virtFields.length; i++) {
if (!_hash[virtFields[i]])
_hash[virtFields[i]] = null;
}