[open-ils-commits] r9171 -
branches/dojo-admin/Open-ILS/web/conify/js/fieldmapper
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Apr 1 00:14:20 EDT 2008
Author: miker
Date: 2008-03-31 23:38:15 -0400 (Mon, 31 Mar 2008)
New Revision: 9171
Added:
branches/dojo-admin/Open-ILS/web/conify/js/fieldmapper/dojoData.js
Removed:
branches/dojo-admin/Open-ILS/web/conify/js/fieldmapper/addFromStoreItem.js
Log:
dojo-ification
Deleted: branches/dojo-admin/Open-ILS/web/conify/js/fieldmapper/addFromStoreItem.js
===================================================================
--- branches/dojo-admin/Open-ILS/web/conify/js/fieldmapper/addFromStoreItem.js 2008-04-01 03:37:51 UTC (rev 9170)
+++ branches/dojo-admin/Open-ILS/web/conify/js/fieldmapper/addFromStoreItem.js 2008-04-01 03:38:15 UTC (rev 9171)
@@ -1,104 +0,0 @@
-if(!dojo._hasResource['fieldmapper.dojoData']){
-
- dojo._hasResource['fieldmapper.dojoData'] = true;
- dojo.provide('fieldmapper.dojoData');
- dojo.require('fieldmapper.Fieldmapper');
- dojo.require('fieldmapper.hash');
-
-
- function _fromStoreItem (data) {
- this.fromHash(data);
-
- for (var i in this._ignore_fields)
- this[this._ignore_fields[i]](null);
-
- var _fields = fmclasses[this.classname];
- for ( var i=0; i < _fields.length; i++) {
- if (dojo.isArray( this[_fields[i]]() ))
- this[_fields[i]]( this[_fields[i]]()[0] );
- }
- return this;
- }
-
- function _toStoreData (list, label, params) {
-
- if (!params) params = {};
-
- // a sane default
- if (!params.identifier) params.identifier = 'id';
- if (!label) label = params.label;
- if (!label) label = params.identifier;
-
- var data = { label : label, identifier : params.identifier, items : [] };
-
- for (var i in list) data.items.push( list[i].toHash() );
-
- if (params.children && params.parent) {
- var _hash_list = data.items;
-
- var _find_root = {};
- for (var i in _hash_list) {
- _find_root[_hash_list[i][params.identifier]] = _hash_list[i];
- }
-
- var item_data = [];
- for (var i in _hash_list) {
- var obj = _hash_list[i]
- obj[params.children] = [];
-
- for (var j in _hash_list) {
- 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 );
- }
-
- for (var j in _find_root) {
- _find_root[j]['_top'] = 'true';
- if (!_find_root[j][params.parent])
- _find_root[j]['_trueRoot'] = 'true';
- }
-
- data.items = item_data;
- }
-
- return data;
- }
-
- for (var i in fmclasses) window[i].prototype.fromStoreItem = _fromStoreItem;
-
- aou.prototype._ignore_fields = ['children'];
- aout.prototype._ignore_fields = ['children'];
- pgt.prototype._ignore_fields = ['children'];
-
- // set up the defaults
- for (var i in fmclasses) window[i].toStoreData = _toStoreData;
-
- aou.toStoreData = function (list, label) {
- if (!label) label = 'shortname';
- return _toStoreData(list, label, { 'parent' : 'parent_ou', 'children' : 'children' });
- }
-
- aout.toStoreData = function (list, label) {
- if (!label) label = 'name';
- return _toStoreData(list, label, { 'parent' : 'parent', 'children' : 'children' });
- }
-
- pgt.toStoreData = function (list, label) {
- if (!label) label = 'name';
- return _toStoreData(list, label, { 'parent' : 'parent', 'children' : 'children' });
- }
-
- /*
- ppl.toStoreData = function (list, label) {
- if (!label) label = 'code';
- return _toStoreData(list, label, {});
- }
- */
-
-}
Copied: branches/dojo-admin/Open-ILS/web/conify/js/fieldmapper/dojoData.js (from rev 9169, branches/dojo-admin/Open-ILS/web/conify/js/fieldmapper/addFromStoreItem.js)
===================================================================
--- branches/dojo-admin/Open-ILS/web/conify/js/fieldmapper/dojoData.js (rev 0)
+++ branches/dojo-admin/Open-ILS/web/conify/js/fieldmapper/dojoData.js 2008-04-01 03:38:15 UTC (rev 9171)
@@ -0,0 +1,104 @@
+if(!dojo._hasResource['fieldmapper.dojoData']){
+
+ dojo._hasResource['fieldmapper.dojoData'] = true;
+ dojo.provide('fieldmapper.dojoData');
+ dojo.require('fieldmapper.Fieldmapper');
+ dojo.require('fieldmapper.hash');
+
+
+ function _fromStoreItem (data) {
+ this.fromHash(data);
+
+ for (var i in this._ignore_fields)
+ this[this._ignore_fields[i]](null);
+
+ var _fields = fmclasses[this.classname];
+ for ( var i=0; i < _fields.length; i++) {
+ if (dojo.isArray( this[_fields[i]]() ))
+ this[_fields[i]]( this[_fields[i]]()[0] );
+ }
+ return this;
+ }
+
+ function _toStoreData (list, label, params) {
+
+ if (!params) params = {};
+
+ // a sane default
+ if (!params.identifier) params.identifier = 'id';
+ if (!label) label = params.label;
+ if (!label) label = params.identifier;
+
+ var data = { label : label, identifier : params.identifier, items : [] };
+
+ for (var i in list) data.items.push( list[i].toHash() );
+
+ if (params.children && params.parent) {
+ var _hash_list = data.items;
+
+ var _find_root = {};
+ for (var i in _hash_list) {
+ _find_root[_hash_list[i][params.identifier]] = _hash_list[i];
+ }
+
+ var item_data = [];
+ for (var i in _hash_list) {
+ var obj = _hash_list[i]
+ obj[params.children] = [];
+
+ for (var j in _hash_list) {
+ 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 );
+ }
+
+ for (var j in _find_root) {
+ _find_root[j]['_top'] = 'true';
+ if (!_find_root[j][params.parent])
+ _find_root[j]['_trueRoot'] = 'true';
+ }
+
+ data.items = item_data;
+ }
+
+ return data;
+ }
+
+ for (var i in fmclasses) window[i].prototype.fromStoreItem = _fromStoreItem;
+
+ aou.prototype._ignore_fields = ['children'];
+ aout.prototype._ignore_fields = ['children'];
+ pgt.prototype._ignore_fields = ['children'];
+
+ // set up the defaults
+ for (var i in fmclasses) window[i].toStoreData = _toStoreData;
+
+ aou.toStoreData = function (list, label) {
+ if (!label) label = 'shortname';
+ return _toStoreData(list, label, { 'parent' : 'parent_ou', 'children' : 'children' });
+ }
+
+ aout.toStoreData = function (list, label) {
+ if (!label) label = 'name';
+ return _toStoreData(list, label, { 'parent' : 'parent', 'children' : 'children' });
+ }
+
+ pgt.toStoreData = function (list, label) {
+ if (!label) label = 'name';
+ return _toStoreData(list, label, { 'parent' : 'parent', 'children' : 'children' });
+ }
+
+ /*
+ ppl.toStoreData = function (list, label) {
+ if (!label) label = 'code';
+ return _toStoreData(list, label, {});
+ }
+ */
+
+}
More information about the open-ils-commits
mailing list