[open-ils-commits] r9172 - in
branches/dojo-admin/Open-ILS/web/conify: global/actor
global/permission js/fieldmapper
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Apr 1 03:01:52 EDT 2008
Author: miker
Date: 2008-04-01 02:25:45 -0400 (Tue, 01 Apr 2008)
New Revision: 9172
Added:
branches/dojo-admin/Open-ILS/web/conify/js/fieldmapper/Fieldmapper.js
Removed:
branches/dojo-admin/Open-ILS/web/conify/js/fieldmapper/addToHash.js
branches/dojo-admin/Open-ILS/web/conify/js/fieldmapper/addToStoreData.js
Modified:
branches/dojo-admin/Open-ILS/web/conify/global/actor/org_unit.html
branches/dojo-admin/Open-ILS/web/conify/global/actor/org_unit.js
branches/dojo-admin/Open-ILS/web/conify/global/actor/org_unit_type.js
branches/dojo-admin/Open-ILS/web/conify/global/permission/grp_tree.js
branches/dojo-admin/Open-ILS/web/conify/global/permission/perm_list.html
branches/dojo-admin/Open-ILS/web/conify/global/permission/perm_list.js
branches/dojo-admin/Open-ILS/web/conify/js/fieldmapper/dojoData.js
branches/dojo-admin/Open-ILS/web/conify/js/fieldmapper/hash.js
Log:
dojo-ification; org_unit.html is acting up, but otherwise we are good
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-04-01 03:38:15 UTC (rev 9171)
+++ branches/dojo-admin/Open-ILS/web/conify/global/actor/org_unit.html 2008-04-01 06:25:45 UTC (rev 9172)
@@ -64,12 +64,16 @@
params : [ ses, { id : { "!=" : null } }, { order_by : { aou : 'shortname' } } ],
onerror : function (r) { throw 'Problem fetching org units';},
oncomplete : function (r) {
- window.ou_list_store = new dojo.data.ItemFileWriteStore({ data : aou.toStoreData( r.recv().content() ) });
+ window._ou_list = r.recv().content();
+ window._ou_data = aou.toStoreData( window._ou_list );
+ window.ou_list_store = new dojo.data.ItemFileWriteStore({ data : window._ou_data });
+
window.ou_list_store.onSet = function (item, attr, n, o) {
if (attr == 'ischanged') return;
if (n == o) return;
this.setValue( item, 'ischanged', 1);
};
+
dojo.addOnUnload( function (event) {
ou_list_store.fetch({
@@ -97,6 +101,18 @@
}
}).send();
+ pCRUD.request({
+ method : 'open-ils.permacrud.search.aout.atomic',
+ timeout : 10,
+ params : [ ses, { id : { "!=" : null } }, { order_by : { aout : 'name' } } ],
+ onerror : function (r) { status_update('Problem fetching types') },
+ oncomplete : function (r) {
+ window._ou_type_list = r.recv().content();
+ window._ou_type_data = aout.toStoreData( window._ou_type_list );
+ window.ou_type_store = new dojo.data.ItemFileReadStore({ data : window._ou_type_data });
+ }
+ }).send();
+
</script>
<div
id="ou_tree"
Modified: branches/dojo-admin/Open-ILS/web/conify/global/actor/org_unit.js
===================================================================
--- branches/dojo-admin/Open-ILS/web/conify/global/actor/org_unit.js 2008-04-01 03:38:15 UTC (rev 9171)
+++ branches/dojo-admin/Open-ILS/web/conify/global/actor/org_unit.js 2008-04-01 06:25:45 UTC (rev 9172)
@@ -1,7 +1,4 @@
-dojo.require('conify.fieldmapper.addToHash', true);
-dojo.require('conify.fieldmapper.addFromHash', true);
-dojo.require('conify.fieldmapper.addToStoreData', true);
-dojo.require('conify.fieldmapper.addFromStoreItem', true);
+dojo.require('fieldmapper.dojoData');
dojo.require('dojo.parser');
dojo.require('dojo.data.ItemFileWriteStore');
dojo.require('dojo.date.stamp');
@@ -27,7 +24,7 @@
var current_ou, current_ou_hoo;
var virgin_ou_id = -1;
-var ou_type_store = new dojo.data.ItemFileWriteStore({ data : aout.toStoreData( globalOrgTypes ) });
+//var ou_type_store = new dojo.data.ItemFileWriteStore({ data : aout.toStoreData( globalOrgTypes ) });
var highlighter = {};
Modified: branches/dojo-admin/Open-ILS/web/conify/global/actor/org_unit_type.js
===================================================================
--- branches/dojo-admin/Open-ILS/web/conify/global/actor/org_unit_type.js 2008-04-01 03:38:15 UTC (rev 9171)
+++ branches/dojo-admin/Open-ILS/web/conify/global/actor/org_unit_type.js 2008-04-01 06:25:45 UTC (rev 9172)
@@ -1,7 +1,4 @@
-dojo.require('conify.fieldmapper.addToHash', true);
-dojo.require('conify.fieldmapper.addFromHash', true);
-dojo.require('conify.fieldmapper.addToStoreData', true);
-dojo.require('conify.fieldmapper.addFromStoreItem', true);
+dojo.require('fieldmapper.dojoData');
dojo.require('dojo.parser');
dojo.require('dojo.data.ItemFileWriteStore');
dojo.require('dojo.date.stamp');
Modified: branches/dojo-admin/Open-ILS/web/conify/global/permission/grp_tree.js
===================================================================
--- branches/dojo-admin/Open-ILS/web/conify/global/permission/grp_tree.js 2008-04-01 03:38:15 UTC (rev 9171)
+++ branches/dojo-admin/Open-ILS/web/conify/global/permission/grp_tree.js 2008-04-01 06:25:45 UTC (rev 9172)
@@ -1,7 +1,4 @@
-dojo.require('conify.fieldmapper.addToHash', true);
-dojo.require('conify.fieldmapper.addFromHash', true);
-dojo.require('conify.fieldmapper.addToStoreData', true);
-dojo.require('conify.fieldmapper.addFromStoreItem', true);
+dojo.require('fieldmapper.dojoData');
dojo.require('dojo.parser');
dojo.require('dojo.data.ItemFileWriteStore');
dojo.require('dojo.date.stamp');
Modified: branches/dojo-admin/Open-ILS/web/conify/global/permission/perm_list.html
===================================================================
--- branches/dojo-admin/Open-ILS/web/conify/global/permission/perm_list.html 2008-04-01 03:38:15 UTC (rev 9171)
+++ branches/dojo-admin/Open-ILS/web/conify/global/permission/perm_list.html 2008-04-01 06:25:45 UTC (rev 9172)
@@ -81,9 +81,8 @@
window.perm_grid_layout = [
{ cells : [
[
- { name : "ID", field : "id", width : "5em", noresize : true },
- { name : "Code", field : "code", width : "300px", editor : dojox.grid.editors.Dijit },
- { name : "Description", field : "description", width : "100%", editor : dojox.grid.editors.Editor }
+ { name : "Code", field : "code", width : "300px", editor : dojox.grid.editors.Dijit },
+ { name : "Description", field : "description", width : "auto", editor : dojox.grid.editors.Editor }
]
]
}
@@ -147,6 +146,7 @@
var new_item_hash = res.content().toHash();
perm_store.newItem( new_item_hash );
status_update( 'New ' + new_item_hash.code + ' permission created' );
+ perm_grid.model.sort(-1);
highlighter.green.play();
} else {
highlighter.red.play();
@@ -161,7 +161,7 @@
</div>
<div dojoType="dijit.layout.ContentPane" style="width:100%; height:100%;" layoutAlign="client">
- <div dojoType="dojox.grid.data.DojoData" id="perm_data_model"jsId="perm_data_model" rowsPerPage="20" store="perm_store" query="{ code : '*' }"></div>
+ <div dojoType="dojox.grid.data.DojoData" id="perm_data_model"jsId="perm_data_model" store="perm_store" query="{ code : '*' }"></div>
<div id="perm_grid" dojoType="dojox.Grid" model="perm_data_model" structure="perm_grid_layout" jsId="perm_grid">
<!!--
<script type="dojo/connect" event="onSet" args="item,attr,oldVal,newVal">
@@ -172,81 +172,64 @@
<div dojoType="dijit.layout.ContentPane" orientation="horizontal" style="margin-bottom: 5px;" layoutAlign="bottom">
- <button jsId="save_ppl_button" dojoType="dijit.form.Button" label="Save Changes" onClick="save_them_all()">
- </button>
+ <button jsId="save_ppl_button" dojoType="dijit.form.Button" label="Save Changes" onClick="save_them_all()"></button>
<button jsId="delete_ppl_button" dojoType="dijit.form.Button" label="Delete Selected">
<script type="dojo/connect" event="onClick">
+
+ var selected_rows = perm_grid.selection.getSelected();
- if (perm_store.getValue( current_perm, '_trueRoot' ) == 'true') {
- highlighter.red.play();
- status_update( 'Cannot delete' + perm_store.getValue( current_perm, 'code' ) + ', you need at least one.' );
- return false;
- }
-
- if ( current_perm.children ) {
- var kids = current_perm.children;
- if (!dojo.isArray(kids)) kids = [kids];
-
- var existing_kids = dojo.filter(
- kids,
- function(kid){ return kid.isdeleted[0] != 1 }
+ var selected_items = [];
+ for (var i in selected_rows) {
+ selected_items.push(
+ perm_grid.model.getRow( selected_rows[i] ).__dojo_data_item
);
- if ( existing_kids.length > 0) {
- highlighter.red.play();
- status_update( 'Cannot delete' + perm_store.getValue( current_perm, 'code' ) + ', ' + existing_kids.length + ' subordinates still exist.' );
- return;
- }
}
+
+ perm_grid.selection.clear();
+
+ for (var i in selected_items) {
+ current_perm = selected_items[i];
+
+ if ( confirm('Are you sure you want to delete ' + perm_store.getValue( current_perm, 'code' ) + '?')) {
+
+ perm_store.setValue( current_perm, 'isdeleted', 1 );
+
+ var modified_ppl = new ppl().fromStoreItem( current_perm );
+ modified_ppl.isdeleted( 1 );
+
+ pCRUD.request({
+ method : 'open-ils.permacrud.delete.ppl',
+ timeout : 10,
+ params : [ ses, modified_ppl ],
+ onerror : function (r) {
+ highlighter.red.play();
+ status_update( 'Problem deleting ' + perm_store.getValue( current_perm, 'code' ) );
+ },
+ oncomplete : function (r) {
+ var res = r.recv();
+ if ( res && res.content() ) {
+
+ var old_name = perm_store.getValue( current_perm, 'code' );
- if ( confirm('Are you sure you want to delete ' + current_perm.name + '?')) {
- perm_store.setValue( current_perm, 'isdeleted', 1 );
-
- var modified_ppl = new ppl().fromStoreItem( current_perm );
- modified_ppl.isdeleted( 1 );
-
- pCRUD.request({
- method : 'open-ils.permacrud.delete.ppl',
- timeout : 10,
- params : [ ses, modified_ppl ],
- onerror : function (r) {
- highlighter.red.play();
- status_update( 'Problem deleting ' + perm_store.getValue( current_perm, 'code' ) );
- },
- oncomplete : function (r) {
- var res = r.recv();
- if ( res && res.content() ) {
-
- var old_name = perm_store.getValue( current_perm, 'code' );
-
- perm_store.fetch({
- query : { id : perm_store.getValue( current_perm, 'id' ) },
- onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } },
- scope : perm_store
- });
-
- current_perm = null;
-
- new_kid_button.disabled = true;
- save_ppl_button.disabled = true;
- delete_ppl_button.disabled = true;
-
- var main_settings_fields = [ 'code', 'description' ];
- for ( var i in main_settings_fields ) {
- var field = main_settings_fields[i];
- window["editor_pane_" + field].setValue( '' ); // unset the value
- window["editor_pane_" + field].setDisplayedValue( '' ); // unset the value
+ perm_store.fetch({
+ query : { id : perm_store.getValue( current_perm, 'id' ) },
+ onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } },
+ scope : perm_store
+ });
+
+ current_perm = null;
+
+ highlighter.green.play();
+ status_update( old_name + ' deleted' );
+ } else {
+ highlighter.red.play();
+ status_update( 'Problem deleting ' + old_name );
}
-
- highlighter.green.play();
- status_update( old_name + ' deleted' );
- } else {
- highlighter.red.play();
- status_update( 'Problem deleting ' + old_name );
}
- }
- }).send();
-
+ }).send();
+
+ }
}
</script>
Modified: branches/dojo-admin/Open-ILS/web/conify/global/permission/perm_list.js
===================================================================
--- branches/dojo-admin/Open-ILS/web/conify/global/permission/perm_list.js 2008-04-01 03:38:15 UTC (rev 9171)
+++ branches/dojo-admin/Open-ILS/web/conify/global/permission/perm_list.js 2008-04-01 06:25:45 UTC (rev 9172)
@@ -1,8 +1,6 @@
-dojo.require('conify.fieldmapper.addToHash', true);
-dojo.require('conify.fieldmapper.addFromHash', true);
-dojo.require('conify.fieldmapper.addToStoreData', true);
-dojo.require('conify.fieldmapper.addFromStoreItem', true);
+dojo.require('fieldmapper.dojoData');
dojo.require('dojo.parser');
+dojo.require('dojo.string');
dojo.require('dojo.data.ItemFileWriteStore');
dojo.require('dijit.form.TextBox');
dojo.require('dijit.form.ValidationTextBox');
@@ -35,6 +33,8 @@
var modified_ppl = new ppl().fromStoreItem( current_perm );
modified_ppl.ischanged( 1 );
+ modified_ppl.description( dojo.string.trim( modified_ppl.description() ) );
+ modified_ppl.code( dojo.string.trim( modified_ppl.code() ) );
pCRUD.request({
method : 'open-ils.permacrud.update.ppl',
Added: branches/dojo-admin/Open-ILS/web/conify/js/fieldmapper/Fieldmapper.js
===================================================================
--- branches/dojo-admin/Open-ILS/web/conify/js/fieldmapper/Fieldmapper.js (rev 0)
+++ branches/dojo-admin/Open-ILS/web/conify/js/fieldmapper/Fieldmapper.js 2008-04-01 06:25:45 UTC (rev 9172)
@@ -0,0 +1,80 @@
+if(!dojo._hasResource["fieldmapper.Fieldmapper"]){
+/* generate fieldmapper javascript classes. This expects a global variable
+ 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"; }
+
+
+ dojo._hasResource["fieldmapper.Fieldmapper"] = true;
+ dojo.provide("fieldmapper.Fieldmapper");
+
+ dojo.declare( "fieldmapper.Fieldmapper", null, {
+
+ constructor : function (initArray) {
+ if (initArray) {
+ if (dojo.isArray(initArray)) {
+ this.a = initArray;
+ } else {
+ this.a = [];
+ }
+ }
+ },
+
+ _isfieldmapper : true,
+ fm_classes : fmclasses,
+
+ clone : function() {
+ var obj = new this.constructor();
+
+ 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(instanceOf(thing, Array)) {
+ obj.a[i] = new Array();
+
+ 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;
+ },
+
+ isnew : function(n) { if(arguments.length == 1) this.a[0] =n; return this.a[0]; },
+ ischanged : function(n) { if(arguments.length == 1) this.a[1] =n; return this.a[1]; },
+ isdeleted : function(n) { if(arguments.length == 1) this.a[2] =n; return this.a[2]; }
+
+ });
+
+ for( var cl in fmclasses ) {
+ dojo.provide( cl );
+ dojo.declare( cl , fieldmapper.Fieldmapper, {
+ constructor : function () {
+ if (!this.a) this.a = [];
+ this.classname = this.declaredClass;
+ this._fields = fmclasses[this.classname];
+ for( var pos = 0; pos < this._fields.length; pos++ ) {
+ var p = parseInt(pos) + 3;
+ var f = this._fields[pos];
+ this[f]=new Function('n', 'if(arguments.length==1)this.a['+p+']=n;return this.a['+p+'];');
+ }
+ }
+ });
+
+ }
+}
+
+
Deleted: branches/dojo-admin/Open-ILS/web/conify/js/fieldmapper/addToHash.js
===================================================================
--- branches/dojo-admin/Open-ILS/web/conify/js/fieldmapper/addToHash.js 2008-04-01 03:38:15 UTC (rev 9171)
+++ branches/dojo-admin/Open-ILS/web/conify/js/fieldmapper/addToHash.js 2008-04-01 06:25:45 UTC (rev 9172)
@@ -1,13 +0,0 @@
-
-function _toHash () {
- var _hash = {};
- var _fields = fmclasses[this.classname];
- for ( var i=0; i < _fields.length; i++) {
- if (this[_fields[i]]() != null)
- _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/fieldmapper/addToStoreData.js
===================================================================
--- branches/dojo-admin/Open-ILS/web/conify/js/fieldmapper/addToStoreData.js 2008-04-01 03:38:15 UTC (rev 9171)
+++ branches/dojo-admin/Open-ILS/web/conify/js/fieldmapper/addToStoreData.js 2008-04-01 06:25:45 UTC (rev 9172)
@@ -1,76 +0,0 @@
-
-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;
-}
-
-// 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, {});
-}
-*/
-
Modified: branches/dojo-admin/Open-ILS/web/conify/js/fieldmapper/dojoData.js
===================================================================
--- branches/dojo-admin/Open-ILS/web/conify/js/fieldmapper/dojoData.js 2008-04-01 03:38:15 UTC (rev 9171)
+++ branches/dojo-admin/Open-ILS/web/conify/js/fieldmapper/dojoData.js 2008-04-01 06:25:45 UTC (rev 9172)
@@ -12,10 +12,9 @@
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] );
+ for ( var i=0; i < this._fields.length; i++) {
+ if (dojo.isArray( this[this._fields[i]]() ))
+ this[this._fields[i]]( this[this._fields[i]]()[0] );
}
return this;
}
Modified: branches/dojo-admin/Open-ILS/web/conify/js/fieldmapper/hash.js
===================================================================
--- branches/dojo-admin/Open-ILS/web/conify/js/fieldmapper/hash.js 2008-04-01 03:38:15 UTC (rev 9171)
+++ branches/dojo-admin/Open-ILS/web/conify/js/fieldmapper/hash.js 2008-04-01 06:25:45 UTC (rev 9172)
@@ -5,29 +5,25 @@
dojo.require('fieldmapper.Fieldmapper');
function _fromHash (_hash) {
- var _fields = fmclasses[this.classname];
- for ( var i=0; i < _fields.length; i++) {
- if (_hash[_fields[i]] != null)
- this[_fields[i]]( _hash[_fields[i]] );
+ 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;
}
- for (var i in fmclasses) {
- window[i].prototype.fromHash = _fromHash;
- window[i].prototype.toHash = _toHash;
- }
-
-
function _toHash () {
var _hash = {};
- var _fields = fmclasses[this.classname];
- for ( var i=0; i < _fields.length; i++) {
- if (this[_fields[i]]() != null)
- _hash[_fields[i]] = '' + this[_fields[i]]();
+ for ( var i=0; i < this._fields.length; i++) {
+ if (this[this._fields[i]]())
+ _hash[this._fields[i]] = '' + this[this._fields[i]]();
}
return _hash;
}
+ for (var i in fmclasses) {
+ window[i].prototype.fromHash = _fromHash;
+ window[i].prototype.toHash = _toHash;
+ }
}
More information about the open-ils-commits
mailing list