From: miker Date: Sat, 29 Mar 2008 05:33:02 +0000 (+0000) Subject: moving dojo to /js/; adding the start of the permission editor; using a dropdown... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=907767ab8343834036df8a03a347456967291ca8;p=Evergreen.git moving dojo to /js/; adding the start of the permission editor; using a dropdown for application perms; starting on the group-perm map git-svn-id: svn://svn.open-ils.org/ILS/branches/dojo-admin@9160 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/web/conify/global/actor/org_unit.html b/Open-ILS/web/conify/global/actor/org_unit.html index e7a6e3ee55..5be7978cad 100644 --- a/Open-ILS/web/conify/global/actor/org_unit.html +++ b/Open-ILS/web/conify/global/actor/org_unit.html @@ -3,9 +3,9 @@ Confiy :: Global :: Actor :: Org Units - - + + - - + + @@ -62,19 +62,21 @@ params : [ ses, { id : { "!=" : null } }, { order_by : { pgt : 'name' } } ], onerror : function (r) { status_update('Problem fetching groups') }, oncomplete : function (r) { - ou_group_store = new dojo.data.ItemFileWriteStore({ data : pgt.toStoreData( r.recv().content() ) }); - ou_group_store.onSet = function (item, attr, n, o) { + window._group_list = r.recv().content(); + window._group_data = pgt.toStoreData( window._group_list ); + window.group_store = new dojo.data.ItemFileWriteStore({ data : window._group_data }); + window.group_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_group_store.fetch({ + window.group_store.fetch({ query : { ischanged : 1 }, queryOptions : { deep : true }, onItem : function (item, req) { try { if (this.isItem( item )) window.dirtyStore.push( item ); } catch (e) { /* meh */ } }, - scope : ou_group_store + scope : window.group_store }); if (dirtyStore.length > 0) { @@ -95,13 +97,84 @@ } }).send(); + function get_perm_part(part, model, row) { + var value; + perm_store.fetchItemByIdentity({ + identity : model.getRow(row).perm, + onItem : function (item) { value = perm_store.getValue( item, part ) } + }); + return value; + } + + // XXX Use existing perm grabbing functions?? see old interface + pCRUD.request({ + method : 'open-ils.permacrud.search.ppl.atomic', + timeout : 10, + params : [ ses, { id : { "!=" : null } }, { order_by : { ppl : 'code' } } ], + onerror : function (r) { status_update('Problem fetching perms') }, + oncomplete : function (r) { + + window._perm_list = r.recv().content(); + window._perm_data = ppl.toStoreData( window._perm_list, 'code' ); + window._perm_name_data = ppl.toStoreData( window._perm_list, 'code', { identifier : 'code' } ); + window.perm_store = new dojo.data.ItemFileWriteStore({ data : window._perm_data }); + window.perm_name_store = new dojo.data.ItemFileWriteStore({ data : window._perm_name_data }); + + window.current_perm_grid_layout = [ + { cells : [ + [ + { name : "Depth", + field : "perm", + width : "5em", + noresize : true + }, + { name : "Code", + //get : dojo.partial(get_perm_part, "code", perm_map_model), + width : "300px" + }, + { name : "Description", + //get : dojo.partial(get_perm_part, "code", perm_map_model), + width : "auto" + } + ] + ] + } + ]; + + } + }).send(); + + pCRUD.request({ + method : 'open-ils.permacrud.search.pgmp.atomic', + timeout : 10, + params : [ ses, { id : { "!=" : null } } ], + onerror : function (r) { status_update('Problem fetching perm maps') }, + oncomplete : function (r) { + window._perm_map_list = r.recv().content(); + window._perm_map_data = pgpm.toStoreData( window._perm_map_list, 'id' ); + window.perm_map_store = new dojo.data.ItemFileWriteStore({ data : window._perm_map_data }); + } + }).send(); + + pCRUD.request({ + method : 'open-ils.permacrud.search.aout.atomic', + timeout : 10, + params : [ ses, { id : { "!=" : null } }, { order_by : { aout : 'depth' } } ], + 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.ItemFileWriteStore({ data : window._ou_type_data }); + } + }).send(); +
@@ -119,7 +192,7 @@ save_out_button.disabled = false; delete_out_button.disabled = false; - var main_settings_fields = [ 'name', 'perm_interval', 'description', 'application_perm']; + var main_settings_fields = [ 'name', 'perm_interval', 'description']; for ( var i in main_settings_fields ) { var field = main_settings_fields[i]; var value = this.store.getValue( current_group, field ); @@ -141,6 +214,8 @@ editor_pane_parent.setValue( this.store.getValue( current_group, 'parent' ) ); } + editor_pane_application_perm.setValue( this.store.getValue( current_group, 'application_perm' ) ); + editor_pane_usergroup.setChecked( this.store.getValue( current_group, 'usergroup' ) == 't' ? true : false ); @@ -160,7 +235,8 @@ window.right_pane_toggler.hide(); -
+
+
@@ -190,7 +266,7 @@ id="editor_pane_description" dojoType="dijit.form.Textarea" jsId="editor_pane_description" - onChange="if (current_group) ou_group_store.setValue( current_group, "description", this.getValue() );" + onChange="if (current_group) group_store.setValue( current_group, "description", this.getValue() );" > @@ -200,7 +276,7 @@ @@ -209,13 +285,18 @@ Edit Permission - +
- +
@@ -225,7 +306,7 @@ id="editor_pane_parent" dojoType="dijit.form.FilteringSelect" jsId="editor_pane_parent" - store="ou_group_store" + store="group_store" searchAttr="name" ignoreCase="true" required="true" @@ -246,7 +327,7 @@ jsId="editor_pane_usergroup" type="checkbox" dojoType="dijit.form.CheckBox" - onChange='if (current_group) ou_group_store.setValue( current_group, "usergroup", this.checked ? "t" : "f" );' + onChange='if (current_group) group_store.setValue( current_group, "usergroup", this.checked ? "t" : "f" );' /> @@ -266,9 +347,9 @@
+ +
+ +
+
diff --git a/Open-ILS/web/conify/global/permission/grp_tree.js b/Open-ILS/web/conify/global/permission/grp_tree.js index 031db97f41..de5b941f33 100644 --- a/Open-ILS/web/conify/global/permission/grp_tree.js +++ b/Open-ILS/web/conify/global/permission/grp_tree.js @@ -19,6 +19,7 @@ dojo.require('dijit.layout.LayoutContainer'); dojo.require('dijit.layout.SplitContainer'); dojo.require('dojox.widget.Toaster'); dojo.require('dojox.fx'); +//dojo.require('dojox.grid.Grid'); // some handy globals var cgi = new CGI(); @@ -50,17 +51,17 @@ function save_group () { params : [ ses, modified_pgt ], onerror : function (r) { highlighter.editor_pane.red.play(); - status_update( 'Problem saving data for ' + ou_group_store.getValue( current_group, 'name' ) ); + status_update( 'Problem saving data for ' + group_store.getValue( current_group, 'name' ) ); }, oncomplete : function (r) { var res = r.recv(); if ( res && res.content() ) { - ou_group_store.setValue( current_group, 'ischanged', 0 ); + group_store.setValue( current_group, 'ischanged', 0 ); highlighter.editor_pane.green.play(); - status_update( 'Saved changes to ' + ou_group_store.getValue( current_group, 'name' ) ); + status_update( 'Saved changes to ' + group_store.getValue( current_group, 'name' ) ); } else { highlighter.editor_pane.red.play(); - status_update( 'Problem saving data for ' + ou_group_store.getValue( current_group, 'name' ) ); + status_update( 'Problem saving data for ' + group_store.getValue( current_group, 'name' ) ); } }, }).send(); diff --git a/Open-ILS/web/conify/global/permission/perm_list.html b/Open-ILS/web/conify/global/permission/perm_list.html new file mode 100644 index 0000000000..4ccba0712a --- /dev/null +++ b/Open-ILS/web/conify/global/permission/perm_list.html @@ -0,0 +1,214 @@ + + + Confiy :: Global :: Permission :: Permission List + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+ +
+ +
+ +
+ + + + + +
+ + + diff --git a/Open-ILS/web/conify/global/permission/perm_list.js b/Open-ILS/web/conify/global/permission/perm_list.js new file mode 100644 index 0000000000..fb103e8ebe --- /dev/null +++ b/Open-ILS/web/conify/global/permission/perm_list.js @@ -0,0 +1,62 @@ +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('dojo.parser'); +dojo.require('dojo.data.ItemFileWriteStore'); +dojo.require('dijit.form.TextBox'); +dojo.require('dijit.form.ValidationTextBox'); +dojo.require('dijit.form.Textarea'); +dojo.require('dijit.layout.ContentPane'); +dojo.require('dojox.widget.Toaster'); +dojo.require('dojox.fx'); +dojo.require('dojox.grid.Grid'); +dojo.require('dojox.grid._data.model'); +dojo.require("dojox.grid.editors"); + +// some handy globals +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'); + +var current_perm; +var virgin_out_id = -1; + +var highlighter = {}; + +function status_update (markup) { + if (parent !== window && parent.status_update) parent.status_update( markup ); +} + +function save_perm () { + + var modified_ppl = new ppl().fromStoreItem( current_perm ); + modified_ppl.ischanged( 1 ); + + new_kid_button.disabled = false; + save_out_button.disabled = false; + delete_out_button.disabled = false; + + pCRUD.request({ + method : 'open-ils.permacrud.update.ppl', + timeout : 10, + params : [ ses, modified_ppl ], + onerror : function (r) { + highlighter.red.play(); + status_update( 'Problem saving data for ' + perm_store.getValue( current_perm, 'code' ) ); + }, + oncomplete : function (r) { + var res = r.recv(); + if ( res && res.content() ) { + perm_store.setValue( current_perm, 'ischanged', 0 ); + highlighter.green.play(); + status_update( 'Saved changes to ' + perm_store.getValue( current_perm, 'code' ) ); + } else { + highlighter.red.play(); + status_update( 'Problem saving data for ' + perm_store.getValue( current_perm, 'code' ) ); + } + }, + }).send(); +} + diff --git a/Open-ILS/web/conify/js/conify/fieldmapper/addToStoreData.js b/Open-ILS/web/conify/js/conify/fieldmapper/addToStoreData.js index e5d097eaab..99f803e927 100644 --- a/Open-ILS/web/conify/js/conify/fieldmapper/addToStoreData.js +++ b/Open-ILS/web/conify/js/conify/fieldmapper/addToStoreData.js @@ -1,14 +1,18 @@ 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 : 'shortname', identifier : 'id', items : [] }; + var data = { label : label, identifier : params.identifier, items : [] }; for (var i in list) data.items.push( list[i].toHash() ); - if (params.children && params['parent']) { + if (params.children && params.parent) { var _hash_list = data.items; var _find_root = {}; @@ -23,7 +27,7 @@ function _toStoreData (list, label, params) { for (var j in _hash_list) { var kid = _hash_list[j]; - if (kid[params['parent']] == obj[params.identifier]) { + 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]]; @@ -35,7 +39,7 @@ function _toStoreData (list, label, params) { for (var j in _find_root) { _find_root[j]['_top'] = 'true'; - if (!_find_root[j][params['parent']]) + if (!_find_root[j][params.parent]) _find_root[j]['_trueRoot'] = 'true'; } @@ -63,4 +67,10 @@ pgt.toStoreData = function (list, label) { return _toStoreData(list, label, { 'parent' : 'parent', 'children' : 'children' }); } +/* +ppl.toStoreData = function (list, label) { + if (!label) label = 'code'; + return _toStoreData(list, label, {}); +} +*/