From: miker Date: Fri, 25 Sep 2009 01:16:05 +0000 (+0000) Subject: Patch from Warren Layton at Laurentian university which addresses some issues X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=792446fca0a909726a8ce6c5b8705b0a2c0fb22d;p=evergreen%2Fmasslnc.git Patch from Warren Layton at Laurentian university which addresses some issues saving org unit data via the conify interfaces. Thanks, Warren, and sorry for the delay. M Open-ILS/web/conify/global/actor/org_unit.js M Open-ILS/web/conify/global/actor/org_unit.html M Open-ILS/examples/fm_IDL.xml git-svn-id: svn://svn.open-ils.org/ILS/trunk@14165 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 79bd4353c6..fe7fd4ef80 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -1511,14 +1511,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - + - + - - + + diff --git a/Open-ILS/web/conify/global/actor/org_unit.html b/Open-ILS/web/conify/global/actor/org_unit.html index 5f08602fb0..d0d85d1fce 100644 --- a/Open-ILS/web/conify/global/actor/org_unit.html +++ b/Open-ILS/web/conify/global/actor/org_unit.html @@ -353,47 +353,37 @@ var modified_ou = new aou().fromStoreItem( current_ou ); modified_ou.isdeleted( 1 ); - pCRUD.request({ - method : 'open-ils.pcrud.delete.aou', + pcrud.eliminate( modified_ou, { timeout : 10, - params : [ ses, modified_ou ], onerror : function (r) { highlighter.editor_pane.red.play(); status_update(dojo.string.substitute(aou_strings.ERROR_DELETING, [old_name])); }, oncomplete : function (r) { - var res = r.recv(); - if ( res && res.content() ) { - - ou_list_store.fetch({ - query : { id : ou_list_store.getValue( current_ou, 'id' ) }, - queryOptions : { deep : true }, - onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } }, - scope : ou_list_store - }); - - current_ou = null; - - new_kid_button.disabled = true; - save_ou_button.disabled = true; - delete_ou_button.disabled = true; - - var main_settings_fields = [ 'name', 'shortname', 'email', 'phone', 'ou_type', 'parent_ou' ]; - 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 - } - - highlighter.editor_pane.green.play(); - status_update(dojo.string.substitute(aou_strings.STATUS_DELETED, [old_name])); - } else { - highlighter.editor_pane.red.play(); - status_update(dojo.string.substitute(aou_strings.ERROR_DELETING, [old_name])); + ou_list_store.fetch({ + query : { id : ou_list_store.getValue( current_ou, 'id' ) }, + queryOptions : { deep : true }, + onItem : function (item, req) { try { if (this.isItem( item )) this.deleteItem( item ); } catch (e) { /* meh */ } }, + scope : ou_list_store + }); + + current_ou = null; + + new_kid_button.disabled = true; + save_ou_button.disabled = true; + delete_ou_button.disabled = true; + + var main_settings_fields = [ 'name', 'shortname', 'email', 'phone', 'ou_type', 'parent_ou' ]; + 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 } + + highlighter.editor_pane.green.play(); + status_update(dojo.string.substitute(aou_strings.STATUS_DELETED, [old_name])); } - }).send(); - + }); } ]]> @@ -418,10 +408,8 @@ var new_obj; - pCRUD.request({ - method : 'open-ils.pcrud.create.aou', + pcrud.create( new_fm_obj, { timeout : 10, - params : [ ses, new_fm_obj ], onerror : function (r) { highlighter.editor_pane.red.play(); status_update( aou_strings.ERROR_CREATING_CHILD_AOU ); @@ -437,8 +425,8 @@ highlighter.editor_pane.red.play(); status_update( aou_strings.ERROR_CREATING_CHILD_AOU ); } - }, - }).send(); + } + }); highlighter.editor_pane.green.play(); highlighter.ou_tree.green.play(); @@ -490,30 +478,38 @@ diff --git a/Open-ILS/web/conify/global/actor/org_unit.js b/Open-ILS/web/conify/global/actor/org_unit.js index b139e1cc20..d923270eca 100644 --- a/Open-ILS/web/conify/global/actor/org_unit.js +++ b/Open-ILS/web/conify/global/actor/org_unit.js @@ -42,7 +42,7 @@ var ses = cookieManager.read('ses') || cgi.param('ses'); var pCRUD = new OpenSRF.ClientSession('open-ils.pcrud'); var pcrud = new openils.PermaCrud({ authtoken : ses }); -var current_ou, current_ou_hoo, ou_list_store +var current_ou, current_ou_hoo, ou_list_store, hoo_id; var dirtyStore = []; var virgin_ou_id = -1; @@ -65,7 +65,7 @@ function save_org () { var modified_ou = new aou().fromStoreItem( current_ou ); modified_ou.ischanged( 1 ); - pcrud.apply( modified_ou, { + pcrud.update( modified_ou, { timeout : 10, // makes it synchronous onerror : function (r) { highlighter.editor_pane.red.play(); @@ -87,46 +87,33 @@ function save_org () { } 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.pcrud.retrieve.aouhoo', - params : [ ses, ou_list_store.getValue( current_ou, 'id' ) ], - onerror : function (r) { - throw dojo.string.substitute(aou_strings.ERROR_FETCHING_HOURS, [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']() ) - ); + save_hoo_button.disabled = false; + + hoo_id = pcrud.search( 'aouhoo',{id:ou_list_store.getValue( current_ou, 'id' )}); + if (hoo_id.length == 0) { + current_ou_hoo = new aouhoo().fromHash({id:ou_list_store.getValue( current_ou, 'id' )}); + 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'); + } + } else { + current_ou_hoo = pcrud.retrieve( 'aouhoo', ou_list_store.getValue( current_ou, 'id' ), { + onerror : function (r) { + throw dojo.string.substitute(aou_strings.ERROR_FETCHING_HOURS,[ou_list_store.getValue( current_ou, 'name' )]); } + }); + } - highlighter.hoo_pane.green.play(); - } - }).send(); + 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(); } function addr_load () {