[open-ils-commits] SPAM: r9151 - in
branches/dojo-admin/Open-ILS/web/conify/global: . actor
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Mar 27 02:52:05 EDT 2008
Author: miker
Date: 2008-03-27 02:16:41 -0400 (Thu, 27 Mar 2008)
New Revision: 9151
Added:
branches/dojo-admin/Open-ILS/web/conify/global/actor/org_unit_type.html
branches/dojo-admin/Open-ILS/web/conify/global/actor/org_unit_type.js
Modified:
branches/dojo-admin/Open-ILS/web/conify/global/actor/org_unit.html
branches/dojo-admin/Open-ILS/web/conify/global/admin.html
Log:
cleaning up org unit interface; adding org type interface
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-27 06:15:43 UTC (rev 9150)
+++ branches/dojo-admin/Open-ILS/web/conify/global/actor/org_unit.html 2008-03-27 06:16:41 UTC (rev 9151)
@@ -110,10 +110,12 @@
<script type="dojo/method" event="onClick" args="item,node">
+ right_pane_toggler.show();
+
current_ou = item;
highlighter.editor_pane.green.play();
- status_update( 'Now editing' + this.store.getValue( item, 'name' ) );
+ status_update( 'Now editing ' + this.store.getValue( item, 'name' ) );
new_kid_button.disabled = false;
save_ou_button.disabled = false;
@@ -159,7 +161,11 @@
</div>
</div>
- <div id="right_pane" dojoType="dijit.layout.ContentPane" sizeMin="200" sizeShare="300">
+ <div jsId="right_pane" id="right_pane" dojoType="dijit.layout.ContentPane" sizeMin="200" sizeShare="300">
+ <script type="dojo/method">
+ window.right_pane_toggler = new dojo.fx.Toggler({ node: 'right_pane'});
+ window.right_pane_toggler.hide();
+ </script>
<div id="right_tabpane" dojoType="dijit.layout.TabContainer">
@@ -290,6 +296,14 @@
</script>
<script type="dojo/connect" event="onClick">
+ var old_name = ou_list_store.getValue( current_ou, 'name' );
+
+ if (ou_list_store.getValue( current_ou, '_trueRoot' ) == 'true') {
+ highlighter.editor_pane.red.play();
+ status_update( 'Cannot delete' + ou_list_store.getValue( current_ou, 'name' ) + ', you need at least one.' );
+ return false;
+ }
+
if ( current_ou.children ) {
var kids = current_ou.children;
if (!dojo.isArray(kids)) kids = [kids];
@@ -317,7 +331,7 @@
params : [ ses, modified_ou ],
onerror : function (r) {
highlighter.editor_pane.red.play();
- status_update( 'Problem deleting ' + ou_list_store.getValue( current_ou, 'name' ) );
+ status_update( 'Problem deleting ' + old_name );
},
oncomplete : function (r) {
var res = r.recv();
@@ -344,12 +358,12 @@
}
highlighter.editor_pane.green.play();
- status_update( ou_list_store.getValue( current_ou, 'name' ) + ' deleted' );
+ status_update( old_name + ' deleted' );
} else {
highlighter.editor_pane.red.play();
- status_update( 'Problem deleting ' + ou_list_store.getValue( current_ou, 'name' ) );
+ status_update( 'Problem deleting ' + old_name );
}
- },
+ }
}).send();
}
Added: branches/dojo-admin/Open-ILS/web/conify/global/actor/org_unit_type.html
===================================================================
--- branches/dojo-admin/Open-ILS/web/conify/global/actor/org_unit_type.html (rev 0)
+++ branches/dojo-admin/Open-ILS/web/conify/global/actor/org_unit_type.html 2008-03-27 06:16:41 UTC (rev 9151)
@@ -0,0 +1,409 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>Confiy :: Global :: Actor :: Org Unit Types</title>
+
+ <style type="text/css">
+ @import url("/conify/js/dojo/resources/dojo.css");
+ @import url("/conify/js/dijit/themes/tundra/tundra.css");
+ @import url("/conify/js/dojox/widget/Toaster/Toaster.css");
+ </style>
+
+ <style>
+ html, body
+ {
+ height: 100%;
+ width: 100%;
+ margin: 0px 0px 0px 0px;
+ padding: 0px 0px 0px 0px;
+ overflow: hidden;
+ }
+
+ th
+ {
+ text-align: right;
+ font-weight: bold;
+ padding-left: 20px;
+ padding-right: 5px;
+ }
+ </style>
+
+ <!-- The OpenSRF API writ JS -->
+ <script language='javascript' src='/opac/common/js/utils.js' type='text/javascript'></script>
+ <script language='javascript' src='/opac/common/js/Cookies.js' type='text/javascript'></script>
+ <script language='javascript' src='/opac/common/js/CGI.js' type='text/javascript'></script>
+ <script language='javascript' src='/opac/common/js/JSON_v1.js' type='text/javascript'></script>
+ <script language='javascript' src='/opac/common/js/opensrf.js' type='text/javascript'></script>
+ <script language='javascript' src='/opac/common/js/opensrf_xhr.js' type='text/javascript'></script>
+
+ <!-- Fieldmapper objects -->
+ <script language='javascript' src='/opac/common/js/fmall.js' type='text/javascript'></script>
+ <script language='javascript' src='/opac/common/js/fmgen.js' type='text/javascript'></script>
+ <script language='javascript' src='/opac/common/js/OrgTree.js' type='text/javascript'></script>
+
+ <!-- Dojo goodness -->
+ <script type="text/javascript" src="/conify/js/dojo/dojo.js.uncompressed.js" djConfig="parseOnLoad: true"></script>
+ <script type="text/javascript" src="/conify/js/dijit/dijit.js"></script>
+
+ <script type="text/javascript" src="org_unit_type.js"></script>
+
+ </head>
+
+ <body class="tundra" id='pagebody'>
+
+ <div dojoType="dijit.layout.SplitContainer" orientation="horizontal" style="height: 100%">
+
+ <div dojoType="dijit.layout.ContentPane" sizeMin="100" sizeShare="100">
+ <script type="dojo/method">
+ window.dirtyStore = [];
+
+ pCRUD.request({
+ method : 'open-ils.permacrud.search.aout.atomic',
+ timeout : 10,
+ params : [ ses, { id : { "!=" : null } }, { order_by : { aou : 'name' } } ],
+ onerror : function (r) { status_update('Problem fetching types') },
+ oncomplete : function (r) {
+ ou_type_store = new dojo.data.ItemFileWriteStore({ data : aout.toStoreData( r.recv().content() ) });
+ ou_type_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_type_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_type_store
+ });
+
+ if (dirtyStore.length > 0) {
+ var confirmation = confirm(
+ 'There are unsaved modified Organization Types! '+
+ 'OK to save these changes, Cancel to abandon them.'
+ );
+
+ if (confirmation) {
+ for (var i in window.dirtyStore) {
+ window.current_type = window.dirtyStore[i];
+ save_type(true);
+ }
+ }
+ }
+
+ });
+ }
+ }).send();
+
+ </script>
+ <div
+ id="type_tree"
+ label="Oragnization Types"
+ query="{'_top':'true'}"
+ dojoType="dijit.Tree"
+ store="ou_type_store"
+ minSize="200"
+ jsId="type_tree"
+ >
+
+ <script type="dojo/method" event="onClick" args="item,node">
+
+ current_type = item;
+
+ highlighter.editor_pane.green.play();
+ status_update( 'Now editing ' + this.store.getValue( item, 'name' ) );
+
+ new_kid_button.disabled = false;
+ save_out_button.disabled = false;
+ delete_out_button.disabled = false;
+
+ var main_settings_fields = [ 'name', 'opac_label'];
+ for ( var i in main_settings_fields ) {
+ var field = main_settings_fields[i];
+ var value = this.store.getValue( current_type, field );
+
+ if (!value) {
+ window["editor_pane_" + field].setValue( '' ); // unset the value
+ window["editor_pane_" + field].setDisplayedValue( '' ); // unset the value
+ } else window["editor_pane_" + field].setValue( value );
+ }
+
+ if ( this.store.getValue( current_type, '_trueRoot' ) == 'true' ) {
+ editor_pane_parent.disabled = true;
+ editor_pane_parent.setValue(null);
+ editor_pane_parent.setDisplayedValue('');
+ editor_pane_parent.validate(false);
+ } else {
+ editor_pane_parent.disabled = false;
+ editor_pane_parent.validate(true);
+ editor_pane_parent.setValue( this.store.getValue( current_type, 'parent' ) );
+ }
+
+ editor_pane_can_have_vols.setChecked( this.store.getValue( current_type, 'can_have_vols' ) == '1' ? true : false );
+ editor_pane_can_have_users.setChecked( this.store.getValue( current_type, 'can_have_users' ) == '1' ? true : false );
+
+ </script>
+
+ <script type="dojo/method" event="getLabel" args="item,pI">
+ var label = this.store.getValue(item,'name');
+ if (this.store.getValue(item,'ischanged') == 1) label = '* ' + label;
+ return label;
+ </script>
+
+ </div>
+ </div>
+
+ <div id="right_pane" dojoType="dijit.layout.ContentPane" sizeMin="100" sizeShare="300">
+
+ <div id="editor_pane" dojoType="dijit.layout.ContentPane">
+ <script type="dojo/method">
+ highlighter.type_tree = {};
+ highlighter.editor_pane = {};
+ highlighter.type_tree.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'type_tree', duration : 500 } );
+ highlighter.type_tree.red = dojox.fx.highlight( { color : '#FF2018', node : 'type_tree', duration : 500 } );
+ highlighter.editor_pane.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'editor_pane', duration : 500 } );
+ highlighter.editor_pane.red = dojox.fx.highlight( { color : '#FF2018', node : 'editor_pane', duration : 500 } );
+ </script>
+
+ <table class="tundra" style="margin:10px;">
+ <tr>
+ <th>Type Name</th>
+ <td>
+ <span id="editor_pane_name" dojoType="dijit.form.ValidationTextBox" jsId="editor_pane_name" regExp=".+" required="true">
+ <script type="dojo/connect" event="onChange">
+ if (current_type) {
+ ou_type_store.setValue( current_type, "name", this.getValue() );
+ }
+ </script>
+ </span>
+ </td>
+ </tr>
+ <tr>
+ <th>OPAC Label</th>
+ <td>
+ <span id="editor_pane_opac_label" dojoType="dijit.form.ValidationTextBox" jsId="editor_pane_opac_label" regExp=".+" required="true">
+ <script type="dojo/connect" event="onChange">
+ if (current_type) {
+ ou_type_store.setValue( current_type, "opac_label", this.getValue() );
+ }
+ </script>
+ </span>
+ </td>
+ </tr>
+ <tr>
+ <th>Parent Type</th>
+ <td>
+ <div
+ id="editor_pane_parent"
+ dojoType="dijit.form.FilteringSelect"
+ jsId="editor_pane_parent"
+ store="ou_type_store"
+ searchAttr="name"
+ ignoreCase="true"
+ required="true"
+ >
+ <script type="dojo/method" event="onChange" args=>
+ if (current_type) {
+ if ( this.store.getValue( current_type, 'depth' ) == this.getValue() ) return;
+
+ this.store.setValue( current_type, "parent", this.getValue() );
+ this.store.fetch({
+ query : { "parent" : this.getValue() },
+ onItem: function (parent_item) {
+ this.setValue( current_type, 'depth', 1 + parseInt(this.getValue( parent_item, 'depth' ) ));
+ },
+ scope : ou_type_store
+ });
+ }
+ </script>
+ </div>
+ </td>
+ </tr>
+ <tr>
+ <th>Can have Volumes/Copies</th>
+ <td>
+ <input
+ id="editor_pane_can_have_vols"
+ jsId="editor_pane_can_have_vols"
+ type="checkbox"
+ dojoType="dijit.form.CheckBox"
+ value='t'
+ >
+ <script type="dojo/connect" event="onChange">
+ if (current_type) {
+ ou_type_store.setValue( current_type, "can_have_vols", this.isChecked() ? "1":"0" );
+ }
+ </script>
+ </input>
+ </td>
+ </tr>
+ <tr>
+ <th>Can have Users</th>
+ <td>
+ <input
+ id="editor_pane_can_have_users"
+ jsId="editor_pane_can_have_users"
+ type="checkbox"
+ dojoType="dijit.form.CheckBox"
+ value='t'
+ >
+ <script type="dojo/connect" event="onChange">
+ if (current_type) {
+ ou_type_store.setValue( current_type, "can_have_users", this.isChecked() ? "1":"0" );
+ }
+ </script>
+ </input>
+ </td>
+ </tr>
+ </table>
+
+ <div dojoType="dijit.layout.ContentPane" orientation="horizontal" style="margin-bottom: 20px;">
+
+ <button jsId="save_out_button" dojoType="dijit.form.Button" label="Save" onClick="save_type()">
+ <script type="dojo/connect" event="startup">
+ this.disabled = true;
+ </script>
+ </button>
+
+ <button jsId="delete_out_button" dojoType="dijit.form.Button" label="Delete">
+ <script type="dojo/connect" event="startup">
+ this.disabled = true;
+ </script>
+ <script type="dojo/connect" event="onClick">
+
+ if (ou_type_store.getValue( current_type, '_trueRoot' ) == 'true') {
+ highlighter.editor_pane.red.play();
+ status_update( 'Cannot delete' + ou_type_store.getValue( current_type, 'name' ) + ', you need at least one.' );
+ return false;
+ }
+
+ if ( current_type.children ) {
+ var kids = current_type.children;
+ if (!dojo.isArray(kids)) kids = [kids];
+
+ var existing_kids = dojo.filter(
+ kids,
+ function(kid){ return kid.isdeleted[0] != 1 }
+ );
+ if ( existing_kids.length > 0) {
+ highlighter.editor_pane.red.play();
+ status_update( 'Cannot delete' + ou_type_store.getValue( current_type, 'name' ) + ', ' + existing_kids.length + ' subordinates still exist.' );
+ return;
+ }
+ }
+
+ if ( confirm('Are you sure you want to delete ' + current_type.name + '?')) {
+ ou_type_store.setValue( current_type, 'isdeleted', 1 );
+
+ var modified_aout = new aout().fromStoreItem( current_type );
+ modified_aout.isdeleted( 1 );
+
+ pCRUD.request({
+ method : 'open-ils.permacrud.delete.aout',
+ timeout : 10,
+ params : [ ses, modified_aout ],
+ onerror : function (r) {
+ highlighter.editor_pane.red.play();
+ status_update( 'Problem deleting ' + ou_type_store.getValue( current_type, 'name' ) );
+ },
+ oncomplete : function (r) {
+ var res = r.recv();
+ if ( res && res.content() ) {
+
+ var old_name = ou_type_store.getValue( current_type, 'name' );
+
+ ou_type_store.fetch({
+ query : { id : ou_type_store.getValue( current_type, 'id' ) },
+ queryOptions : { deep : true },
+ onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } },
+ scope : ou_type_store
+ });
+
+ current_type = null;
+
+ new_kid_button.disabled = true;
+ save_out_button.disabled = true;
+ delete_out_button.disabled = true;
+
+ var main_settings_fields = [ 'name', 'opac_label' ];
+ 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
+ }
+
+ window["editor_pane_can_have_vols"].setChecked( false ); // unset the value
+ window["editor_pane_can_have_users"].setChecked( false ); // unset the value
+
+ highlighter.editor_pane.green.play();
+ status_update( old_name + ' deleted' );
+ } else {
+ highlighter.editor_pane.red.play();
+ status_update( 'Problem deleting ' + old_name );
+ }
+ }
+ }).send();
+
+ }
+
+ </script>
+ </button>
+
+ </div>
+
+ <button jsId="new_kid_button" dojoType="dijit.form.Button" label="New Child">
+ <script type="dojo/connect" event="startup">
+ this.disabled = true;
+ </script>
+ <script type="dojo/connect" event="onClick">
+
+ var new_fm_obj = new aout().fromHash({
+ isnew : 1,
+ name : 'New Type',
+ can_have_vols : '0',
+ can_have_users : '0',
+ depth : 1 + parseInt(ou_type_store.getValue( current_type, 'depth' )),
+ opac_label : ou_type_store.getValue( current_type, 'opac_label' ) + ' child' + virgin_out_id--,
+ parent : ou_type_store.getValue( current_type, 'id' )
+ });
+
+ var err = false;
+ pCRUD.request({
+ method : 'open-ils.permacrud.create.aout',
+ timeout : 10,
+ params : [ ses, new_fm_obj ],
+ onerror : function (r) {
+ highlighter.editor_pane.red.play();
+ status_update( 'Problem calling method to create child Org Type' );
+ err = true;
+ },
+ oncomplete : function (r) {
+ var res = r.recv();
+ if ( res && res.content() ) {
+ ou_type_store.newItem(
+ res.content().toHash(),
+ { parent : current_type, attribute : 'children' }
+ );
+ } else {
+ highlighter.editor_pane.red.play();
+ status_update( 'Problem creating child Org Type' );
+ err = true;
+ }
+ },
+ }).send();
+
+ if (!err) {
+ highlighter.editor_pane.green.play();
+ highlighter.type_tree.green.play();
+ status_update( 'New child Organization Type created for ' + ou_type_store.getValue( current_type, 'name' ) );
+ }
+
+ </script>
+ </button>
+
+ </div>
+ </div>
+ </div>
+ </div>
+ </body>
+</html>
Added: 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 (rev 0)
+++ branches/dojo-admin/Open-ILS/web/conify/global/actor/org_unit_type.js 2008-03-27 06:16:41 UTC (rev 9151)
@@ -0,0 +1,67 @@
+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('dojo.date.stamp');
+dojo.require('dijit.form.NumberSpinner');
+dojo.require('dijit.form.TextBox');
+dojo.require('dijit.form.TimeTextBox');
+dojo.require('dijit.form.ValidationTextBox');
+dojo.require('dijit.form.CheckBox');
+dojo.require('dijit.form.FilteringSelect');
+dojo.require('dijit.Tree');
+dojo.require('dijit.layout.ContentPane');
+dojo.require('dijit.layout.TabContainer');
+dojo.require('dijit.layout.LayoutContainer');
+dojo.require('dijit.layout.SplitContainer');
+dojo.require('dojox.widget.Toaster');
+dojo.require('dojox.fx');
+
+// 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_type;
+var virgin_out_id = -1;
+
+var highlighter = {};
+
+function status_update (markup) {
+ if (parent !== window && parent.status_update) parent.status_update( markup );
+}
+
+function save_type () {
+
+ var modified_aout = new aout().fromStoreItem( current_type );
+ modified_aout.ischanged( 1 );
+
+ new_kid_button.disabled = false;
+ save_out_button.disabled = false;
+ delete_out_button.disabled = false;
+
+ pCRUD.request({
+ method : 'open-ils.permacrud.update.aout',
+ timeout : 10,
+ params : [ ses, modified_aout ],
+ onerror : function (r) {
+ highlighter.editor_pane.red.play();
+ status_update( 'Problem saving data for ' + ou_type_store.getValue( current_type, 'name' ) );
+ },
+ oncomplete : function (r) {
+ var res = r.recv();
+ if ( res && res.content() ) {
+ ou_type_store.setValue( current_type, 'ischanged', 0 );
+ highlighter.editor_pane.green.play();
+ status_update( 'Saved changes to ' + ou_type_store.getValue( current_type, 'name' ) );
+ } else {
+ highlighter.editor_pane.red.play();
+ status_update( 'Problem saving data for ' + ou_type_store.getValue( current_type, 'name' ) );
+ }
+ },
+ }).send();
+}
+
Modified: branches/dojo-admin/Open-ILS/web/conify/global/admin.html
===================================================================
--- branches/dojo-admin/Open-ILS/web/conify/global/admin.html 2008-03-27 06:15:43 UTC (rev 9150)
+++ branches/dojo-admin/Open-ILS/web/conify/global/admin.html 2008-03-27 06:16:41 UTC (rev 9151)
@@ -42,8 +42,11 @@
<img src="/opac/images/small_logo.jpg"/>
<span style="font-size: large; padding-left: 20px;"> Configure your ILS </span>
</div>
- <div id="left_pane" jsId="left_pane" dojoType="dijit.layout.ContentPane" layoutAlign="left" orientation="vertical" style="height: 90%; margin: 4px" title="Controls">
- <button dojoType="dijit.form.Button" label="Organizational Units" onClick="dojo.byId('action_iframe').src = 'actor/org_unit.html';" />
+ <div id="left_pane" jsId="left_pane" dojoType="dijit.layout.ContentPane" layoutAlign="left" orientation="vertical" style="height: 90%; margin: 4px;" label="Controls">
+ <ul>
+ <li><a href="" onclick="dojo.byId('action_iframe').src = 'actor/org_unit_type.html'; return false;">Organization Types</a></li>
+ <li><a href="" onclick="dojo.byId('action_iframe').src = 'actor/org_unit.html'; return false;">Organizational Units</a></li>
+ </ul>
</div>
<div id="content_pane" jsId="content_pane" dojoType="dijit.layout.ContentPane" layoutAlign="client" style="margin: 2px; border-top: 2px solid grey; border-bottom: 2px solid grey; border-left: 2px solid grey;">
<iframe id="action_iframe" marginwidth="0" marginheight="0" style="border:0; height: 100%; width: 100%;"></iframe>
More information about the open-ils-commits
mailing list