[open-ils-commits] r9096 - in
branches/dojo-admin/Open-ILS/web/conify: global/actor js
js/conify js/conify/fieldmapper
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Mar 19 23:46:20 EDT 2008
Author: miker
Date: 2008-03-19 23:11:56 -0400 (Wed, 19 Mar 2008)
New Revision: 9096
Added:
branches/dojo-admin/Open-ILS/web/conify/js/conify/
branches/dojo-admin/Open-ILS/web/conify/js/conify/fieldmapper/
branches/dojo-admin/Open-ILS/web/conify/js/conify/fieldmapper/addToHash.js
Removed:
branches/dojo-admin/Open-ILS/web/conify/js/fm_list2dojo.data.js
Modified:
branches/dojo-admin/Open-ILS/web/conify/global/actor/org_unit.html
Log:
getting closer ...
Modified: branches/dojo-admin/Open-ILS/web/conify/global/actor/org_unit.html
===================================================================
--- branches/dojo-admin/Open-ILS/web/conify/global/actor/org_unit.html 2008-03-20 03:00:23 UTC (rev 9095)
+++ branches/dojo-admin/Open-ILS/web/conify/global/actor/org_unit.html 2008-03-20 03:11:56 UTC (rev 9096)
@@ -3,8 +3,8 @@
<title>Confiy :: Global :: Actor :: Org Units</title>
<style type="text/css">
- @import "/conify/js/dijit/themes/tundra/tundra.css";
- @import "conify/js/dojo/resources/dojo.css";
+ @import "/conify/js/dijit/themes/tundra/tundra.css">;
+ @import "/conify/js/dojo/resources/dojo.css";
</style>
<!-- The OpenSRF API writ JS -->
@@ -20,8 +20,9 @@
<script language='javascript' src='/opac/common/js/fmgen.js' type='text/javascript'></script>
<!-- Dojo goodness -->
- <script type="text/javascript" src="/conify/js/dojo/dojo.js" djConfig="parseOnLoad: true"></script>
+ <script type="text/javascript" src="/conify/js/dojo/dojo.js.uncompressed.js" djConfig="parseOnLoad: true"></script>
<script type="text/javascript">
+ dojo.require('conify.fieldmapper.addToHash', true);
dojo.require('dojo.parser');
dojo.require('dojo.data.ItemFileReadStore');
dojo.require('dijit.Tree');
@@ -33,60 +34,65 @@
<script type="text/javascript">
var cgi = new CGI();
var cookieManager = new HTTP.Cookies();
-
var ses = cookieManager.read('ses') || cgi.param('ses');
-
var pCRUD = new OpenSRF.ClientSession('open-ils.permacrud');
+ </script>
+ </head>
+ <body class="tundra" id='pagebody'>
- var ou_list_data = {label : 'shortname', identifier : 'id' };
- var ou_list_store;
+ <div
+ dojoType="dijit.layout.SplitContainer"
+ orientation="horizontal"
+ activeSizing="true"
+ style="width: 100%; height: 100%;"
+ >
+ <div dojoType="dijit.layout.ContentPane" sizeMin="150">
+ <script type="dojo/method">
- var req = pCRUD.request({
- method : 'open-ils.permacrud.search.aou.atomic',
- params : [ses, { id : { "!=" : null } } ],
- onerror : function (r) { alert('Problem fetching org units'); },
- onresponse : function (r) {
- var _data = r.recv().content;
+ var ou_list_data = {label : 'shortname', identifier : 'id' };
+
+ var req = pCRUD.request({
+ method : 'open-ils.permacrud.search.aou.atomic',
+ timeout : 10,
+ params : [ ses, { id : { "!=" : null } } ],
+ onerror : function (r) { throw 'Problem fetching org units';},
+ });
+ req.send();
+
+ var _data = req.recv().content();
+ var ou_hash_list = [];
+ for (var i in _data) ou_hash_list.push( _data[i].toHash() );
+ var _find_root = {};
+ for (var i in ou_hash_list) _find_root[ou_hash_list[i].id] = ou_hash_list[i];
+
var item_data = [];
- for (var i in _data) {
- var ou = _data[i].toHash();
+ for (var i in ou_hash_list) {
+ var ou = ou_hash_list[i]
ou.children = [];
-
- for (var j in _data) {
- var kid = _data[i];
- if (kid.parent_ou() == ou['id'])
- ou.children.push( { _reference: kid.id() } );
+
+ for (var j in ou_hash_list) {
+ var kid = ou_hash_list[j];
+ if (kid.parent_ou == ou.id) {
+ ou.children.push({ _reference: kid.id });
+ if (_find_root[kid.id]) delete _find_root[kid.id];
+ }
}
item_data.push( ou );
}
- alert(item_data.length);
+ for (var i in _find_root) {
+ _find_root.isTop = true;
+ }
- ou_list_store.items = item_data;
- ou_list_store = new dojo.data.ItemFileReadStore({ data : ou_list_data });
+ ou_list_data.items = item_data;
+ window.ou_list_store = new dojo.data.ItemFileReadStore({ data : ou_list_data });
- var t = dojo.byId('dijit_ou_tree');
- t.setAttribute( 'store', 'ou_list_store' )
- t.setAttribute( 'dojoType', 'dijit.Tree' )
- dojo.parser.parse( t );
- }
- });
- req.send();
+ alert(js2JSON(item_data));
- </script>
- </head>
- <body>
-
- <div
- dojoType="dijit.layout.SplitContainer"
- orientation="horizontal"
- activeSizing="true"
- style="width: 100%; height: 100%;"
- >
- <div dojoType="dijit.layout.ContentPane" sizeMin="150">
- <div id="dijit_ou_tree" label="Org Units"/>
+ </script>
+ <div id="dijit_ou_tree" label="Oragnizational Units" query='{isTop:true}' dojoType="dijit.Tree" store="ou_list_store"/>
</div>
<div dojoType="dijit.layout.ContentPane">
stuff goes here
Added: branches/dojo-admin/Open-ILS/web/conify/js/conify/fieldmapper/addToHash.js
===================================================================
--- branches/dojo-admin/Open-ILS/web/conify/js/conify/fieldmapper/addToHash.js (rev 0)
+++ branches/dojo-admin/Open-ILS/web/conify/js/conify/fieldmapper/addToHash.js 2008-03-20 03:11:56 UTC (rev 9096)
@@ -0,0 +1,10 @@
+
+function _toHash () {
+ var _hash = {};
+ var _fields = fmclasses[this.classname];
+ for ( var i=0; i < _fields.length; i++) _hash[_fields[i]] = '' + this[_fields[i]]();
+ return _hash;
+}
+
+for (var i in fmclasses) window[i].prototype.toHash = _toHash;
+
Deleted: branches/dojo-admin/Open-ILS/web/conify/js/fm_list2dojo.data.js
===================================================================
--- branches/dojo-admin/Open-ILS/web/conify/js/fm_list2dojo.data.js 2008-03-20 03:00:23 UTC (rev 9095)
+++ branches/dojo-admin/Open-ILS/web/conify/js/fm_list2dojo.data.js 2008-03-20 03:11:56 UTC (rev 9096)
@@ -1,9 +0,0 @@
-
-function _toHash () {
- var _hash = {};
- for ( var i in fmclasses['aou']) _hash[i] = this[i]();
- return _hash;
-}
-
-aou.prototype.toHash = _toHash;
-
More information about the open-ils-commits
mailing list