From f8d8e21072f17392d8dfb432fae321035cde820c Mon Sep 17 00:00:00 2001 From: miker Date: Wed, 26 Mar 2008 15:58:44 +0000 Subject: [PATCH] admin wrapper with status display; separation of JS and HTML where useful git-svn-id: svn://svn.open-ils.org/ILS/branches/dojo-admin@9138 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/conify/global/actor/org_unit.html | 330 +++++-------------------- Open-ILS/web/conify/global/actor/org_unit.js | 242 ++++++++++++++++++ Open-ILS/web/conify/global/admin.html | 57 +++++ 3 files changed, 367 insertions(+), 262 deletions(-) create mode 100644 Open-ILS/web/conify/global/actor/org_unit.js create mode 100644 Open-ILS/web/conify/global/admin.html diff --git a/Open-ILS/web/conify/global/actor/org_unit.html b/Open-ILS/web/conify/global/actor/org_unit.html index cffb6da380..8d2b8b35df 100644 --- a/Open-ILS/web/conify/global/actor/org_unit.html +++ b/Open-ILS/web/conify/global/actor/org_unit.html @@ -41,250 +41,10 @@ - - - - - - + - var res = r.recv(); - if (res) { - if (res.content()) current_holds_address = res.content(); - } - - if (!current_holds_address) { - current_holds_address = new aoa().fromHash({org_unit:ou_list_store.getValue( current_ou, 'id' )}); - current_holds_address.isnew(1); - } - - set_addr_inputs('holds'); - highlighter.addresses_pane.green.play(); - } - }).send(); - } else { - current_holds_address = new aoa().fromHash({org_unit:ou_list_store.getValue( current_ou, 'id' )}); - current_holds_address.isnew(1); - set_addr_inputs('holds'); - } - - if (ou_list_store.getValue( current_ou, 'ill_address' )) { - pCRUD.request({ - method : 'open-ils.permacrud.retrieve.aoa', - params : [ ses, ou_list_store.getValue( current_ou, 'ill_address' ) ], - onerror : function (r) { throw 'Problem fetching Physical Address for ' + ou_list_store.getValue( current_ou, 'name' );}, - oncomplete : function (r) { - current_ill_address = null; - - var res = r.recv(); - if (res) { - if (res.content()) current_ill_address = res.content(); - } - - if (!current_ill_address) { - current_ill_address = new aoa().fromHash({org_unit:ou_list_store.getValue( current_ou, 'id' )}); - current_ill_address.isnew(1); - } - - set_addr_inputs('ill'); - highlighter.addresses_pane.green.play(); - } - }).send(); - } else { - current_ill_address = new aoa().fromHash({org_unit:ou_list_store.getValue( current_ou, 'id' )}); - current_ill_address.isnew(1); - set_addr_inputs('ill'); - } - - } - - function set_addr_inputs (type) { - window[type + '_addr_valid'].setChecked( window['current_' + type + '_address'].valid() == 't' ? true : false ); - window[type + '_addr_type'].setValue( window['current_' + type + '_address'].address_type() || '' ); - window[type + '_addr_street1'].setValue( window['current_' + type + '_address'].street1() || '' ); - window[type + '_addr_street2'].setValue( window['current_' + type + '_address'].street2() || '' ); - window[type + '_addr_city'].setValue( window['current_' + type + '_address'].city() || '' ); - window[type + '_addr_county'].setValue( window['current_' + type + '_address'].county() || '' ); - window[type + '_addr_country'].setValue( window['current_' + type + '_address'].country() || '' ); - window[type + '_addr_state'].setValue( window['current_' + type + '_address'].state() || '' ); - window[type + '_addr_post_code'].setValue( window['current_' + type + '_address'].post_code() || '' ); - } - - + @@ -296,19 +56,50 @@
-
Now editing:
@@ -659,16 +458,17 @@ params : [ ses, current_ou_hoo ], onerror : function (r) { highlighter.editor_pane.red.play(); - throw 'Problem saving Hours of Operation data for ' + ou_list_store.getValue( current_ou, 'name' ); + status_update( 'Problem saving Hours of Operation data for ' + ou_list_store.getValue( current_ou, 'name' )); }, oncomplete : function (r) { var res = r.recv(); if ( res && res.content() ) { current_ou_hoo.isnew(0); highlighter.editor_pane.green.play(); + status_update( 'Hours of Operation updated for ' + ou_list_store.getValue( current_ou, 'name' ) ); } else { highlighter.editor_pane.red.play(); - throw 'Problem saving Hours of Operation data for ' + ou_list_store.getValue( current_ou, 'name' ); + status_update( 'Problem saving Hours of Operation data for ' + ou_list_store.getValue( current_ou, 'name' )); } }, }).send(); @@ -736,7 +536,7 @@ params : [ ses, current_billing_address ], onerror : function (r) { highlighter.addresses_pane.red.play(); - throw 'Problem saving Physical Address data for ' + ou_list_store.getValue( current_ou, 'name' ); + status_update( 'Problem saving Physical Address data for ' + ou_list_store.getValue( current_ou, 'name' ) ); }, oncomplete : function (r) { var res = r.recv(); @@ -748,9 +548,10 @@ } current_billing_address.isnew(0); highlighter.addresses_pane.green.play(); + status_update( 'Changes to the Physical Address of ' + ou_list_store.getValue( current_ou, 'name' ) + ' saved' ); } else { highlighter.addresses_pane.red.play(); - throw 'Problem saving Physical Address data for ' + ou_list_store.getValue( current_ou, 'name' ); + status_update( 'Problem saving Physical Address data for ' + ou_list_store.getValue( current_ou, 'name' ) ); } }, }).send(); @@ -806,7 +607,7 @@ params : [ ses, current_holds_address ], onerror : function (r) { highlighter.addresses_pane.red.play(); - throw 'Problem saving Physical Address data for ' + ou_list_store.getValue( current_ou, 'name' ); + throw 'Problem saving Holds Address data for ' + ou_list_store.getValue( current_ou, 'name' ); }, oncomplete : function (r) { var res = r.recv(); @@ -818,9 +619,10 @@ } current_holds_address.isnew(0); highlighter.addresses_pane.green.play(); + status_update( 'Changes to the Holds Address of ' + ou_list_store.getValue( current_ou, 'name' ) + ' saved' ); } else { highlighter.addresses_pane.red.play(); - throw 'Problem saving Physical Address data for ' + ou_list_store.getValue( current_ou, 'name' ); + throw 'Problem saving Holds Address data for ' + ou_list_store.getValue( current_ou, 'name' ); } }, }).send(); @@ -876,7 +678,7 @@ params : [ ses, current_mailing_address ], onerror : function (r) { highlighter.addresses_pane.red.play(); - throw 'Problem saving Physical Address data for ' + ou_list_store.getValue( current_ou, 'name' ); + throw 'Problem saving Mailing Address data for ' + ou_list_store.getValue( current_ou, 'name' ); }, oncomplete : function (r) { var res = r.recv(); @@ -888,9 +690,10 @@ } current_mailing_address.isnew(0); highlighter.addresses_pane.green.play(); + status_update( 'Changes to the Mailing Address of ' + ou_list_store.getValue( current_ou, 'name' ) + ' saved' ); } else { highlighter.addresses_pane.red.play(); - throw 'Problem saving Physical Address data for ' + ou_list_store.getValue( current_ou, 'name' ); + throw 'Problem saving Mailing Address data for ' + ou_list_store.getValue( current_ou, 'name' ); } }, }).send(); @@ -958,6 +761,7 @@ } current_ill_address.isnew(0); highlighter.addresses_pane.green.play(); + status_update( 'Changes to the ILL Address of ' + ou_list_store.getValue( current_ou, 'name' ) + ' saved' ); } else { highlighter.addresses_pane.red.play(); throw 'Problem saving Physical Address data for ' + ou_list_store.getValue( current_ou, 'name' ); @@ -973,5 +777,7 @@
+ +
Now editing:
diff --git a/Open-ILS/web/conify/global/actor/org_unit.js b/Open-ILS/web/conify/global/actor/org_unit.js new file mode 100644 index 0000000000..31ec66c39a --- /dev/null +++ b/Open-ILS/web/conify/global/actor/org_unit.js @@ -0,0 +1,242 @@ +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.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_ou, current_ou_hoo; +var virgin_ou_id = -1; + +var ou_type_store = new dojo.data.ItemFileWriteStore({ data : aout.toStoreData( globalOrgTypes ) }); + +var highlighter = {}; + +function status_update (markup) { + if (parent.status_update) parent.status_update( markup ); +} + +function save_org () { + var modified_ou = new aou().fromStoreItem( current_ou ); + modified_ou.ischanged( 1 ); + + new_kid_button.disabled = false; + save_ou_button.disabled = false; + delete_ou_button.disabled = false; + + pCRUD.request({ + method : 'open-ils.permacrud.update.aou', + timeout : 10, + params : [ ses, modified_ou ], + onerror : function (r) { + highlighter.editor_pane.red.play(); + status_update( 'Problem saving data for ' + ou_list_store.getValue( current_ou, 'name' ) ); + }, + oncomplete : function (r) { + var res = r.recv(); + if ( res && res.content() ) { + ou_list_store.setValue( current_ou, 'ischanged', 0 ); + highlighter.editor_pane.green.play(); + status_update( 'Saved changes to ' + ou_list_store.getValue( current_ou, 'name' ) ); + } else { + highlighter.editor_pane.red.play(); + status_update( 'Problem saving data for ' + ou_list_store.getValue( current_ou, 'name' ) ); + } + }, + }).send(); +} + +function hoo_load () { + // empty result not coming through ... + current_ou_hoo = new aouhoo().fromHash({id:ou_list_store.getValue( current_ou, 'id' )}); + current_ou_hoo.isnew(1); + + pCRUD.request({ + method : 'open-ils.permacrud.retrieve.aouhoo', + params : [ ses, ou_list_store.getValue( current_ou, 'id' ) ], + onerror : function (r) { throw 'Problem fetching hours of operation for ' + ou_list_store.getValue( current_ou, 'name' );}, + oncomplete : function (r) { + current_ou_hoo = null; + + var res = r.recv(); + if (res) { + if (res.content()) current_ou_hoo = res.content(); + } + + if (!current_ou_hoo) { + current_ou_hoo = new aouhoo().fromHash({id:ou_list_store.getValue( current_ou, 'id' )}); + current_ou_hoo.isnew(1); + for (var i = 0; i < 7; i++) { + current_ou_hoo['dow_' + i + '_open']('09:00:00'); + current_ou_hoo['dow_' + i + '_close']('17:00:00'); + } + } + + for (var i = 0; i < 7; i++) { + window['dow_' + i + '_open'].setValue( + dojo.date.stamp.fromISOString( 'T' + current_ou_hoo['dow_' + i + '_open']() ) + ); + window['dow_' + i + '_close'].setValue( + dojo.date.stamp.fromISOString( 'T' + current_ou_hoo['dow_' + i + '_close']() ) + ); + } + + highlighter.hoo_pane.green.play(); + } + }).send(); + +} + +function addr_load () { + // empty result not coming through ... + + save_ill_address.disabled = false; + save_holds_address.disabled = false; + save_mailing_address.disabled = false; + save_billing_address.disabled = false; + + if (ou_list_store.getValue( current_ou, 'billing_address' )) { + pCRUD.request({ + method : 'open-ils.permacrud.retrieve.aoa', + params : [ ses, ou_list_store.getValue( current_ou, 'billing_address' ) ], + onerror : function (r) { throw 'Problem fetching Physical Address for ' + ou_list_store.getValue( current_ou, 'name' );}, + oncomplete : function (r) { + current_billing_address = null; + + var res = r.recv(); + if (res) { + if (res.content()) current_billing_address = res.content(); + } + + if (!current_billing_address) { + current_billing_address = new aoa().fromHash({org_unit:ou_list_store.getValue( current_ou, 'id' )}); + current_billing_address.isnew(1); + } + + set_addr_inputs('billing'); + highlighter.addresses_pane.green.play(); + } + }).send(); + } else { + current_billing_address = new aoa().fromHash({org_unit:ou_list_store.getValue( current_ou, 'id' )}); + current_billing_address.isnew(1); + set_addr_inputs('billing'); + } + + if (ou_list_store.getValue( current_ou, 'mailing_address' )) { + pCRUD.request({ + method : 'open-ils.permacrud.retrieve.aoa', + params : [ ses, ou_list_store.getValue( current_ou, 'mailing_address' ) ], + onerror : function (r) { throw 'Problem fetching Physical Address for ' + ou_list_store.getValue( current_ou, 'name' );}, + oncomplete : function (r) { + current_mailing_address = null; + + var res = r.recv(); + if (res) { + if (res.content()) current_mailing_address = res.content(); + } + + if (!current_mailing_address) { + current_mailing_address = new aoa().fromHash({org_unit:ou_list_store.getValue( current_ou, 'id' )}); + current_mailing_address.isnew(1); + } + + set_addr_inputs('mailing'); + highlighter.addresses_pane.green.play(); + } + }).send(); + } else { + current_mailing_address = new aoa().fromHash({org_unit:ou_list_store.getValue( current_ou, 'id' )}); + current_mailing_address.isnew(1); + set_addr_inputs('mailing'); + } + + if (ou_list_store.getValue( current_ou, 'holds_address' )) { + pCRUD.request({ + method : 'open-ils.permacrud.retrieve.aoa', + params : [ ses, ou_list_store.getValue( current_ou, 'holds_address' ) ], + onerror : function (r) { throw 'Problem fetching Physical Address for ' + ou_list_store.getValue( current_ou, 'name' );}, + oncomplete : function (r) { + current_holds_address = null; + + var res = r.recv(); + if (res) { + if (res.content()) current_holds_address = res.content(); + } + + if (!current_holds_address) { + current_holds_address = new aoa().fromHash({org_unit:ou_list_store.getValue( current_ou, 'id' )}); + current_holds_address.isnew(1); + } + + set_addr_inputs('holds'); + highlighter.addresses_pane.green.play(); + } + }).send(); + } else { + current_holds_address = new aoa().fromHash({org_unit:ou_list_store.getValue( current_ou, 'id' )}); + current_holds_address.isnew(1); + set_addr_inputs('holds'); + } + + if (ou_list_store.getValue( current_ou, 'ill_address' )) { + pCRUD.request({ + method : 'open-ils.permacrud.retrieve.aoa', + params : [ ses, ou_list_store.getValue( current_ou, 'ill_address' ) ], + onerror : function (r) { throw 'Problem fetching Physical Address for ' + ou_list_store.getValue( current_ou, 'name' );}, + oncomplete : function (r) { + current_ill_address = null; + + var res = r.recv(); + if (res) { + if (res.content()) current_ill_address = res.content(); + } + + if (!current_ill_address) { + current_ill_address = new aoa().fromHash({org_unit:ou_list_store.getValue( current_ou, 'id' )}); + current_ill_address.isnew(1); + } + + set_addr_inputs('ill'); + highlighter.addresses_pane.green.play(); + } + }).send(); + } else { + current_ill_address = new aoa().fromHash({org_unit:ou_list_store.getValue( current_ou, 'id' )}); + current_ill_address.isnew(1); + set_addr_inputs('ill'); + } + +} + +function set_addr_inputs (type) { + window[type + '_addr_valid'].setChecked( window['current_' + type + '_address'].valid() == 't' ? true : false ); + window[type + '_addr_type'].setValue( window['current_' + type + '_address'].address_type() || '' ); + window[type + '_addr_street1'].setValue( window['current_' + type + '_address'].street1() || '' ); + window[type + '_addr_street2'].setValue( window['current_' + type + '_address'].street2() || '' ); + window[type + '_addr_city'].setValue( window['current_' + type + '_address'].city() || '' ); + window[type + '_addr_county'].setValue( window['current_' + type + '_address'].county() || '' ); + window[type + '_addr_country'].setValue( window['current_' + type + '_address'].country() || '' ); + window[type + '_addr_state'].setValue( window['current_' + type + '_address'].state() || '' ); + window[type + '_addr_post_code'].setValue( window['current_' + type + '_address'].post_code() || '' ); +} + diff --git a/Open-ILS/web/conify/global/admin.html b/Open-ILS/web/conify/global/admin.html new file mode 100644 index 0000000000..045aa0d0cb --- /dev/null +++ b/Open-ILS/web/conify/global/admin.html @@ -0,0 +1,57 @@ + + + Conify :: Global :: Admin + + + + + + + + + + + + + +
+
+ + Configure your ILS +
+
+
+
+ +
+
+ +
+
+ + + -- 2.11.0