[open-ils-commits] r19733 - branches/rel_2_1/Open-ILS/web/js/dojo/fieldmapper (dbs)
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Mar 14 00:47:15 EDT 2011
Author: dbs
Date: 2011-03-14 00:47:12 -0400 (Mon, 14 Mar 2011)
New Revision: 19733
Modified:
branches/rel_2_1/Open-ILS/web/js/dojo/fieldmapper/Fieldmapper.js
branches/rel_2_1/Open-ILS/web/js/dojo/fieldmapper/IDL.js
branches/rel_2_1/Open-ILS/web/js/dojo/fieldmapper/OrgUtils.js
Log:
Pure whitespace (tabs to spaces) for dojo.fieldmapper
Modified: branches/rel_2_1/Open-ILS/web/js/dojo/fieldmapper/Fieldmapper.js
===================================================================
--- branches/rel_2_1/Open-ILS/web/js/dojo/fieldmapper/Fieldmapper.js 2011-03-14 04:46:28 UTC (rev 19732)
+++ branches/rel_2_1/Open-ILS/web/js/dojo/fieldmapper/Fieldmapper.js 2011-03-14 04:47:12 UTC (rev 19733)
@@ -16,60 +16,60 @@
*/
if(!dojo._hasResource["fieldmapper.Fieldmapper"]){
- dojo._hasResource["fieldmapper.Fieldmapper"] = true;
+ dojo._hasResource["fieldmapper.Fieldmapper"] = true;
- dojo.provide("fieldmapper.Fieldmapper");
- dojo.require("DojoSRF");
+ dojo.provide("fieldmapper.Fieldmapper");
+ dojo.require("DojoSRF");
/* generate fieldmapper javascript classes. This expects a global variable
- called 'fmclasses' to be fleshed with the classes we need to build */
+ called 'fmclasses' to be fleshed with the classes we need to build */
- function FMEX(message) { this.message = message; }
+ function FMEX(message) { this.message = message; }
FMEX.toString = function() { return "FieldmapperException: " + this.message + "\n"; };
- dojo.declare( "fieldmapper.Fieldmapper", null, {
+ dojo.declare( "fieldmapper.Fieldmapper", null, {
- constructor : function (initArray) {
- if (initArray) {
- if (dojo.isArray(initArray)) {
- this.a = initArray;
- } else {
- this.a = [];
- }
- }
- },
+ constructor : function (initArray) {
+ if (initArray) {
+ if (dojo.isArray(initArray)) {
+ this.a = initArray;
+ } else {
+ this.a = [];
+ }
+ }
+ },
- _isfieldmapper : true,
+ _isfieldmapper : true,
- clone : function() {
- var obj = new this.constructor();
+ clone : function() {
+ var obj = new this.constructor();
- for( var i in this.a ) {
- var thing = this.a[i];
+ for( var i in this.a ) {
+ var thing = this.a[i];
if(thing === null) continue;
- if( thing._isfieldmapper ) {
- obj.a[i] = thing.clone();
- } else {
+ if( thing._isfieldmapper ) {
+ obj.a[i] = thing.clone();
+ } else {
- if(dojo.isArray(thing)) {
+ if(dojo.isArray(thing)) {
obj.a[i] = [];
- for( var j in thing ) {
+ for( var j in thing ) {
- if( thing[j]._isfieldmapper )
- obj.a[i][j] = thing[j].clone();
- else
- obj.a[i][j] = thing[j];
- }
- } else {
- obj.a[i] = thing;
- }
- }
- }
- return obj;
- },
+ if( thing[j]._isfieldmapper )
+ obj.a[i][j] = thing[j].clone();
+ else
+ obj.a[i][j] = thing[j];
+ }
+ } else {
+ obj.a[i] = thing;
+ }
+ }
+ }
+ return obj;
+ },
RequiredField : function (f) {
if (!f) return;
@@ -89,15 +89,15 @@
return;
}
- });
+ });
fieldmapper.vivicateClass = function (cl) {
- dojo.provide( cl );
- dojo.declare( cl , fieldmapper.Fieldmapper, {
- constructor : function () {
- if (!this.a) this.a = [];
- this.classname = this.declaredClass;
+ dojo.provide( cl );
+ dojo.declare( cl , fieldmapper.Fieldmapper, {
+ constructor : function () {
+ if (!this.a) this.a = [];
+ this.classname = this.declaredClass;
this._fields = [];
var p, f;
@@ -107,23 +107,23 @@
for (f in fieldmapper.IDL.fmclasses[this.classname].fields) {
var field = fieldmapper.IDL.fmclasses[this.classname].fields[f];
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.push( field.name );
+ this[field.name]=new Function('n', 'if(arguments.length==1)this.a['+p+']=n;return this.a['+p+'];');
}
} else {
- this._fields = fmclasses[this.classname];
+ this._fields = fmclasses[this.classname];
- for( var pos = 0; pos < this._fields.length; pos++ ) {
+ for( var pos = 0; pos < this._fields.length; 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+'];');
- }
+ this[f]=new Function('n', 'if(arguments.length==1)this.a['+p+']=n;return this.a['+p+'];');
+ }
}
- }
- });
+ }
+ });
- fieldmapper[cl] = window[cl]; // alias into place
+ fieldmapper[cl] = window[cl]; // alias into place
if (fieldmapper.IDL && fieldmapper.IDL.loaded)
fieldmapper[cl].Identifier = fieldmapper.IDL.fmclasses[cl].pkey;
@@ -139,24 +139,24 @@
fieldmapper[cl].fromHash = _fromHash;
};
- fieldmapper._request = function ( meth, staff, params ) {
- var ses = OpenSRF.CachedClientSession( meth[0] );
- if (!ses) return null;
+ fieldmapper._request = function ( meth, staff, params ) {
+ var ses = OpenSRF.CachedClientSession( meth[0] );
+ if (!ses) return null;
- var result = null;
- var args = {};
+ var result = null;
+ var args = {};
- if (dojo.isArray(params)) {
- args.params = params;
- } else {
+ if (dojo.isArray(params)) {
+ args.params = params;
+ } else {
- if (dojo.isObject(params)) {
- args = params;
- } else {
+ if (dojo.isObject(params)) {
+ args = params;
+ } else {
args.params = [].splice.call(arguments, 2, arguments.length - 2);
- }
+ }
- }
+ }
if (!args.async && !args.timeout) args.timeout = 10;
@@ -172,150 +172,150 @@
};
}
- if (!args.onerror) {
- args.onerror = function (r) {
- throw new Error('Request error encountered! ' + r);
+ 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();
+ 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';
+ args.method = meth[1];
+ if (staff && meth[2]) args.method += '.staff';
- ses.request(args).send();
+ ses.request(args).send();
- return result;
- };
+ return result;
+ };
fieldmapper.standardRequest = function (meth, params) { return fieldmapper._request(meth, false, params); };
- fieldmapper.Fieldmapper.prototype.standardRequest = fieldmapper.standardRequest;
+ fieldmapper.Fieldmapper.prototype.standardRequest = fieldmapper.standardRequest;
fieldmapper.staffRequest = function (meth, params) { return fieldmapper._request(meth, true, params); };
- fieldmapper.Fieldmapper.prototype.staffRequest = fieldmapper.staffRequest;
+ fieldmapper.Fieldmapper.prototype.staffRequest = fieldmapper.staffRequest;
- fieldmapper.OpenSRF = {};
+ fieldmapper.OpenSRF = {};
- /* Methods are defined as [ service, method, have_staff ]
- An optional 3rd component is when a method is followed by true, such methods
- have a staff counterpart and should have ".staff" appended to the method
- before the method is called when in XUL mode */
- fieldmapper.OpenSRF.methods = {
- FETCH_ORG_BY_SHORTNAME : ['open-ils.actor','open-ils.actor.org_unit.retrieve_by_shortname'],
- FETCH_ORG_SETTING : ['open-ils.actor','open-ils.actor.ou_setting.ancestor_default'],
- FETCH_ORG_SETTING_BATCH : ['open-ils.actor','open-ils.actor.ou_setting.ancestor_default.batch']
- };
+ /* Methods are defined as [ service, method, have_staff ]
+ An optional 3rd component is when a method is followed by true, such methods
+ have a staff counterpart and should have ".staff" appended to the method
+ before the method is called when in XUL mode */
+ fieldmapper.OpenSRF.methods = {
+ FETCH_ORG_BY_SHORTNAME : ['open-ils.actor','open-ils.actor.org_unit.retrieve_by_shortname'],
+ FETCH_ORG_SETTING : ['open-ils.actor','open-ils.actor.ou_setting.ancestor_default'],
+ FETCH_ORG_SETTING_BATCH : ['open-ils.actor','open-ils.actor.ou_setting.ancestor_default.batch']
+ };
//** FROM HASH **/
- function _fromHash (_hash) {
- for ( var i=0; i < this._fields.length; i++) {
+ function _fromHash (_hash) {
+ for ( var i=0; i < this._fields.length; i++) {
if (_hash[this._fields[i]] !== null)
- this[this._fields[i]]( _hash[this._fields[i]] );
- }
- return this;
- }
+ this[this._fields[i]]( _hash[this._fields[i]] );
+ }
+ return this;
+ }
- function _toHash (includeNulls, virtFields) {
- var _hash = {};
+ function _toHash (includeNulls, virtFields) {
+ var _hash = {};
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]]();
+ _hash[this._fields[i]] = '' + this[this._fields[i]]();
}
- }
+ }
- if (virtFields && virtFields.length > 0) {
+ if (virtFields && virtFields.length > 0) {
for (i = 0; i < virtFields.length; i++) {
- if (!_hash[virtFields[i]])
- _hash[virtFields[i]] = null;
- }
- }
+ if (!_hash[virtFields[i]])
+ _hash[virtFields[i]] = null;
+ }
+ }
- return _hash;
- }
+ return _hash;
+ }
//** FROM HASH **/
/** FROM dojoData **/
- function _fromStoreItem (data) {
- this.fromHash(data);
+ function _fromStoreItem (data) {
+ this.fromHash(data);
var i;
for (i = 0; this._ignore_fields && i < this._ignore_fields.length; i++)
- this[this._ignore_fields[i]](null);
+ this[this._ignore_fields[i]](null);
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] );
- }
- return this;
- }
+ if (dojo.isArray( this[this._fields[i]]() ))
+ this[this._fields[i]]( this[this._fields[i]]()[0] );
+ }
+ return this;
+ }
function _initStoreData(label, params) {
- if (!params) params = {};
- if (!params.identifier) params.identifier = this.Identifier;
- if (!label) label = params.label;
- if (!label) label = params.identifier;
- return { label : label, identifier : params.identifier, items : [] };
+ if (!params) params = {};
+ if (!params.identifier) params.identifier = this.Identifier;
+ if (!label) label = params.label;
+ if (!label) label = params.identifier;
+ return { label : label, identifier : params.identifier, items : [] };
}
function _toStoreItem(fmObj, params) {
- if (!params) params = {};
+ if (!params) params = {};
return fmObj.toHash(true, params.virtualFields);
}
- function _toStoreData (list, label, params) {
- if (!params) params = {};
+ function _toStoreData (list, label, params) {
+ if (!params) params = {};
var data = this.initStoreData(label, params);
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;
+ if (params.children && params.parent) {
+ var _hash_list = data.items;
- var _find_root = {};
+ var _find_root = {};
for (i = 0; _hash_list && i < _hash_list.length; i++) {
- _find_root[_hash_list[i][params.identifier]] = _hash_list[i];
- }
+ _find_root[_hash_list[i][params.identifier]] = _hash_list[i];
+ }
- var item_data = [];
+ var item_data = [];
for (i = 0; _hash_list && i < _hash_list.length; i++) {
var obj = _hash_list[i];
- obj[params.children] = [];
+ obj[params.children] = [];
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] } );
- kid._iskid = true;
- if (_find_root[kid[params.identifier]]) delete _find_root[kid[params.identifier]];
- }
- }
+ var kid = _hash_list[j];
+ if (kid[params.parent] == obj[params.identifier]) {
+ obj[params.children].push( { _reference : kid[params.identifier] } );
+ kid._iskid = true;
+ if (_find_root[kid[params.identifier]]) delete _find_root[kid[params.identifier]];
+ }
+ }
- item_data.push( obj );
- }
+ item_data.push( obj );
+ }
for (j in _find_root) {
- _find_root[j]['_top'] = 'true';
- if (!_find_root[j][params.parent])
- _find_root[j]['_trueRoot'] = 'true';
- }
+ _find_root[j]['_top'] = 'true';
+ if (!_find_root[j][params.parent])
+ _find_root[j]['_trueRoot'] = 'true';
+ }
- data.items = item_data;
- }
+ data.items = item_data;
+ }
- return data;
- }
+ return data;
+ }
/** FROM dojoData **/
@@ -361,23 +361,23 @@
/** FROM dojoData **/
/* set up some known class attributes */
- if (fieldmapper.aou) fieldmapper.aou.prototype._ignore_fields = ['children'];
- if (fieldmapper.aout) fieldmapper.aout.prototype._ignore_fields = ['children'];
- if (fieldmapper.pgt) fieldmapper.pgt.prototype._ignore_fields = ['children'];
+ if (fieldmapper.aou) fieldmapper.aou.prototype._ignore_fields = ['children'];
+ if (fieldmapper.aout) fieldmapper.aout.prototype._ignore_fields = ['children'];
+ if (fieldmapper.pgt) fieldmapper.pgt.prototype._ignore_fields = ['children'];
- fieldmapper.aou.toStoreData = function (list, label) {
- if (!label) label = 'shortname';
- return _toStoreData.call(this, list, label, { 'parent' : 'parent_ou', 'children' : 'children' });
+ 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.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' });
+ fieldmapper.pgt.toStoreData = function (list, label) {
+ if (!label) label = 'name';
+ return _toStoreData.call(this, list, label, { 'parent' : 'parent', 'children' : 'children' });
};
/** FROM dojoData **/
Modified: branches/rel_2_1/Open-ILS/web/js/dojo/fieldmapper/IDL.js
===================================================================
--- branches/rel_2_1/Open-ILS/web/js/dojo/fieldmapper/IDL.js 2011-03-14 04:46:28 UTC (rev 19732)
+++ branches/rel_2_1/Open-ILS/web/js/dojo/fieldmapper/IDL.js 2011-03-14 04:47:12 UTC (rev 19733)
@@ -161,13 +161,13 @@
var obj = {
field : field,
- name : name,
+ name : name,
label : fieldmapper._getAttributeNS(field,this.NS_REPORTS,'label'),
datatype : fieldmapper._getAttributeNS(field,this.NS_REPORTS,'datatype'),
primitive : fieldmapper._getAttributeNS(field,this.NS_PERSIST,'primitive'),
selector : fieldmapper._getAttributeNS(field,this.NS_REPORTS,'selector'),
array_position : position++,
- type : 'field',
+ type : 'field',
virtual : (fieldmapper._getAttributeNS(fields[i],this.NS_PERSIST, 'virtual') == 'true'),
required : (fieldmapper._getAttributeNS(fields[i],this.NS_OBJ, 'required') == 'true'),
i18n : (fieldmapper._getAttributeNS(fields[i],this.NS_PERSIST, 'i18n') == 'true')
Modified: branches/rel_2_1/Open-ILS/web/js/dojo/fieldmapper/OrgUtils.js
===================================================================
--- branches/rel_2_1/Open-ILS/web/js/dojo/fieldmapper/OrgUtils.js 2011-03-14 04:46:28 UTC (rev 19732)
+++ branches/rel_2_1/Open-ILS/web/js/dojo/fieldmapper/OrgUtils.js 2011-03-14 04:47:12 UTC (rev 19733)
@@ -17,193 +17,193 @@
if(!dojo._hasResource["fieldmapper.OrgUtils"]){
- dojo._hasResource["fieldmapper.OrgUtils"] = true;
- dojo.provide("fieldmapper.OrgUtils");
- dojo.require("fieldmapper.Fieldmapper");
- dojo.require("fieldmapper.OrgTree", true);
- dojo.require("fieldmapper.OrgLasso", true);
+ dojo._hasResource["fieldmapper.OrgUtils"] = true;
+ dojo.provide("fieldmapper.OrgUtils");
+ dojo.require("fieldmapper.Fieldmapper");
+ dojo.require("fieldmapper.OrgTree", true);
+ dojo.require("fieldmapper.OrgLasso", true);
- fieldmapper.aou.slim_ok = true;
- fieldmapper.aou.globalOrgTree = {};
- fieldmapper.aou.OrgCache = {};
- fieldmapper.aou.OrgCacheSN = {};
- fieldmapper.aout.OrgTypeCache = {};
+ fieldmapper.aou.slim_ok = true;
+ fieldmapper.aou.globalOrgTree = {};
+ fieldmapper.aou.OrgCache = {};
+ fieldmapper.aou.OrgCacheSN = {};
+ fieldmapper.aout.OrgTypeCache = {};
- fieldmapper.aout.LoadOrgTypes = function () {
- var i;
- for (i in fieldmapper.aout.OrgTypeCache) {
- return;
- }
+ fieldmapper.aout.LoadOrgTypes = function () {
+ var i;
+ for (i in fieldmapper.aout.OrgTypeCache) {
+ return;
+ }
- var types = fieldmapper.standardRequest(['open-ils.actor','open-ils.actor.org_types.retrieve']);
+ var types = fieldmapper.standardRequest(['open-ils.actor','open-ils.actor.org_types.retrieve']);
- for (i = 0; i < types.length; i++) {
- fieldmapper.aout.OrgTypeCache[types[i].id()] = {
- loaded : true,
- type : types[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;
- var slim_o = fieldmapper.aou.OrgCache[id];
+ fieldmapper.aou.LoadOrg = function (id, 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))
- return fieldmapper.aou.OrgCache[id].org;
+ if (slim_o && (slim_ok || slim_o.loaded))
+ return fieldmapper.aou.OrgCache[id].org;
- var o = fieldmapper.standardRequest(['open-ils.actor','open-ils.actor.org_unit.retrieve'],[null,id]);
+ var o = fieldmapper.standardRequest(['open-ils.actor','open-ils.actor.org_unit.retrieve'],[null,id]);
if(!(o && o.id)) {
throw new Error("fieldmapper.aou.LoadOrg(): No org unit found with ID " + id);
}
- 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;
+ 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 = 0; i < _l.length; i++) {
- fieldmapper.aou.OrgCache[_l[i][0]] = {
- loaded: false,
- org : new fieldmapper.aou().fromHash({
- id : _l[i][0],
- ou_type : _l[i][1],
- parent_ou : _l[i][2],
- name : _l[i][3],
- opac_visible : _l[i][4],
- shortname : _l[i][5]
- })
- };
+ if (window._l) {
+ for (var i = 0; i < _l.length; i++) {
+ fieldmapper.aou.OrgCache[_l[i][0]] = {
+ loaded: false,
+ org : new fieldmapper.aou().fromHash({
+ id : _l[i][0],
+ ou_type : _l[i][1],
+ parent_ou : _l[i][2],
+ name : _l[i][3],
+ opac_visible : _l[i][4],
+ shortname : _l[i][5]
+ })
+ };
- }
+ }
- for (var i in fieldmapper.aou.OrgCache) {
- var x = fieldmapper.aou.OrgCache[i].org;
- if (x.parent_ou() === null || x.parent_ou() === '') {
- fieldmapper.aou.globalOrgTree = x;
- continue;
- }
+ for (var i in fieldmapper.aou.OrgCache) {
+ var x = fieldmapper.aou.OrgCache[i].org;
+ if (x.parent_ou() === null || x.parent_ou() === '') {
+ fieldmapper.aou.globalOrgTree = x;
+ continue;
+ }
- var par = fieldmapper.aou.findOrgUnit(x.parent_ou(),true);
- if (!par.children()) par.children([]);
- par.children().push(x);
- fieldmapper.aou.OrgCache[x.id()].treePtr = x;
- }
+ var par = fieldmapper.aou.findOrgUnit(x.parent_ou(),true);
+ if (!par.children()) par.children([]);
+ par.children().push(x);
+ fieldmapper.aou.OrgCache[x.id()].treePtr = x;
+ }
- for (var i = 0; i < globalOrgTypes.length; i++) {
- fieldmapper.aout.OrgTypeCache[globalOrgTypes[i].id()] = {
- loaded : true,
- type : globalOrgTypes[i]
- };
- }
- }
+ for (var i = 0; i < globalOrgTypes.length; i++) {
+ fieldmapper.aout.OrgTypeCache[globalOrgTypes[i].id()] = {
+ loaded : true,
+ type : globalOrgTypes[i]
+ };
+ }
+ }
/* ---------------------------------------------------------------------- */
- fieldmapper.aou.prototype.fetchOrgSettingDefault = function (name) {
- return this.standardRequest( fieldmapper.OpenSRF.methods.FETCH_ORG_SETTING, [this.id(), name] );
- };
+ 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.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.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.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.aout.findOrgType = function (id) {
+ fieldmapper.aout.LoadOrgTypes();
+ return fieldmapper.aout.OrgTypeCache[id].type;
+ };
- fieldmapper.aou.prototype.findOrgDepth = function (id) {
- if (!id) id = this.id;
- if (!id) return null;
+ fieldmapper.aou.prototype.findOrgDepth = function (id) {
+ if (!id) id = this.id;
+ if (!id) return null;
- var org = fieldmapper.aou.findOrgUnit(id);
- return fieldmapper.aout.findOrgType(
- fieldmapper.aou.findOrgUnit(id).ou_type()
- ).depth();
- };
- fieldmapper.aou.findOrgDepth = fieldmapper.aou.prototype.findOrgDepth;
+ var org = fieldmapper.aou.findOrgUnit(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;
- 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.aout.findOrgTypeFromDepth = function (depth) {
+ 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;
- var org = fieldmapper.aou.OrgCacheSN[sn];
- if (!org) {
- for (var i in fieldmapper.aou.OrgCache) {
- var o = fieldmapper.aou.OrgCache[i];
- if (o.org.shortname() == sn) {
- fieldmapper.aou.OrgCacheSN[o.org.shortname()] = o;
- org = o;
- }
- }
+ fieldmapper.aou.findOrgUnitSN = function (sn, 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) {
+ var o = fieldmapper.aou.OrgCache[i];
+ if (o.org.shortname() == sn) {
+ fieldmapper.aou.OrgCacheSN[o.org.shortname()] = o;
+ org = o;
+ }
+ }
- if (!slim_ok && !fieldmapper.aou.OrgCache[org.id()].loaded) {
- org = fieldmapper.standardRequest(fieldmapper.OpenSRF.methods.FETCH_ORG_BY_SHORTNAME, sn);
+ if (!slim_ok && !fieldmapper.aou.OrgCache[org.id()].loaded) {
+ org = fieldmapper.standardRequest(fieldmapper.OpenSRF.methods.FETCH_ORG_BY_SHORTNAME, sn);
- org.children = fieldmapper.aou.OrgCache[org.id()].children;
- fieldmapper.aou.OrgCache[org.id()] = { loaded : true, org : org };
- fieldmapper.aou.OrgCacheSN[org.shortname()] = { loaded : true, org : org };
- }
+ org.children = fieldmapper.aou.OrgCache[org.id()].children;
+ fieldmapper.aou.OrgCache[org.id()] = { loaded : true, org : org };
+ fieldmapper.aou.OrgCacheSN[org.shortname()] = { loaded : true, org : org };
+ }
- }
+ }
- return org;
- };
+ return org;
+ };
- fieldmapper.aou.prototype.orgNodeTrail = function(node, asId) {
- if (!node) node = this;
- if (!node) return [];
+ fieldmapper.aou.prototype.orgNodeTrail = function(node, asId) {
+ if (!node) node = this;
+ if (!node) return [];
- var na = [];
+ var na = [];
- while( node ) {
- na.push(node);
- if (node.parent_ou())
- node = fieldmapper.aou.findOrgUnit(node.parent_ou());
- else
- node = null;
- }
+ while( node ) {
+ na.push(node);
+ if (node.parent_ou())
+ node = fieldmapper.aou.findOrgUnit(node.parent_ou());
+ else
+ node = null;
+ }
- na.reverse();
- if (asId) return na.map(function(o) { return o.id(); });
- else return na;
- };
- fieldmapper.aou.orgNodeTrail = fieldmapper.aou.prototype.orgNodeTrail;
+ 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 (this._isfieldmapper) {
- org = me;
- me = this;
- }
+ fieldmapper.aou.prototype.orgIsMine = function (me, org) {
+ if (this._isfieldmapper) {
+ org = me;
+ me = this;
+ }
- if(!me || !org) return false;
+ if(!me || !org) return false;
- if(me.id() == org.id()) return true;
+ if(me.id() == org.id()) return true;
- for( var i in me.children() ) {
- if(me.children()[i].orgIsMine(org)) return true;
- }
- return false;
- };
+ for( var i in me.children() ) {
+ 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 */
@@ -236,20 +236,20 @@
return orgList.map( function(node) { return node.id(); } );
};
- dojo.addOnUnload( function () {
- for (var i in fieldmapper.aou.OrgCache) {
- x=fieldmapper.aou.OrgCache[i].treePtr;
- if (!x) continue;
+ dojo.addOnUnload( function () {
+ for (var i in fieldmapper.aou.OrgCache) {
+ x=fieldmapper.aou.OrgCache[i].treePtr;
+ if (!x) continue;
- x.children(null);
- x.parent_ou(null);
- fieldmapper.aou.OrgCache[i]=null;
- }
- fieldmapper.aou.globalOrgTree = null;
- fieldmapper.aou.OrgCache = null;
- fieldmapper.aou.OrgCacheSN = null;
- fieldmapper.aout.OrgTypeCache = null;
- });
+ x.children(null);
+ x.parent_ou(null);
+ fieldmapper.aou.OrgCache[i]=null;
+ }
+ fieldmapper.aou.globalOrgTree = null;
+ fieldmapper.aou.OrgCache = null;
+ fieldmapper.aou.OrgCacheSN = null;
+ fieldmapper.aout.OrgTypeCache = null;
+ });
}
More information about the open-ils-commits
mailing list