From f99e8feb43bf0df1f100016aa01f57fcbabd0bed Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Wed, 22 Feb 2012 12:48:55 -0500 Subject: [PATCH] Fix OU Editor save bug The OU Editor has been flashing red and pretending that id didn't save your changes for ... quite some time. This fixes that, which was caused by a change in the way the openils.PermaCrud dojo module passed results to the user-supplied oncomplete handler. Also, some unrelated whitespace changes. Sorry, Dan. Signed-off-by: Mike Rylander Signed-off-by: Bill Erickson --- .../web/conify/global/actor/org_unit.html | 93 +++++++++---------- Open-ILS/web/conify/global/actor/org_unit.js | 5 +- 2 files changed, 47 insertions(+), 51 deletions(-) diff --git a/Open-ILS/web/conify/global/actor/org_unit.html b/Open-ILS/web/conify/global/actor/org_unit.html index e839bdd1bb..6235e7fd47 100644 --- a/Open-ILS/web/conify/global/actor/org_unit.html +++ b/Open-ILS/web/conify/global/actor/org_unit.html @@ -353,29 +353,34 @@ var modified_ou = new aou().fromStoreItem( current_ou ); modified_ou.isdeleted( 1 ); - var objs = []; - objs.push(modified_ou); + var objs = []; + objs.push(modified_ou); if (!current_billing_address.isnew()) { - current_billing_address.isdeleted( 1 ); - objs.push(current_billing_address); - } + current_billing_address.isdeleted( 1 ); + objs.push(current_billing_address); + } + if (!current_mailing_address.isnew()) { - current_mailing_address.isdeleted( 1 ); - objs.push(current_mailing_address); - } + current_mailing_address.isdeleted( 1 ); + objs.push(current_mailing_address); + } + if (!current_holds_address.isnew()) { - current_holds_address.isdeleted( 1 ); - objs.push(current_holds_address); - } + current_holds_address.isdeleted( 1 ); + objs.push(current_holds_address); + } + if (!current_ill_address.isnew()) { - current_ill_address.isdeleted( 1 ); - objs.push(current_ill_address); - } - if (!current_ou_hoo.isnew()) { - current_ou_hoo.isdeleted( 1 ); - objs.push(current_ou_hoo); - } - pcrud.apply(objs, { + current_ill_address.isdeleted( 1 ); + objs.push(current_ill_address); + } + + if (!current_ou_hoo.isnew()) { + current_ou_hoo.isdeleted( 1 ); + objs.push(current_ou_hoo); + } + + pcrud.apply(objs, { timeout : 10, onerror : function (r) { highlighter.editor_pane.red.play(); @@ -400,11 +405,11 @@ scope : ou_list_store }); - current_billing_address = null; - current_mailing_address = null; - current_holds_address = null; - current_ill_address = null; - current_ou_hoo = null; + current_billing_address = null; + current_mailing_address = null; + current_holds_address = null; + current_ill_address = null; + current_ou_hoo = null; current_ou = null; highlighter.editor_pane.green.play(); @@ -439,11 +444,11 @@ highlighter.editor_pane.red.play(); status_update( aou_strings.ERROR_CREATING_CHILD_AOU ); }, - oncomplete : function (r) { - var res = r.recv(); - if ( res && res.content() ) { + oncomplete : function (r, list) { + + if ( list.length ) { ou_list_store.newItem( - res.content().toHash(), + list[0].toHash(), { parent : current_ou, attribute : 'children' } ); } else { @@ -595,11 +600,9 @@ highlighter.addresses_pane.red.play(); status_update( dojo.string.substitute( aou_strings.ERROR_SAVING_PHYSICAL, [ou_list_store.getValue( current_ou, 'name' )] ) ); }, - oncomplete : function (r) { - var res = r.recv(); - if (res && res.content() - && (current_billing_address.isnew() == 1)) { - current_billing_address = res.content(); + oncomplete : function (r, list) { + if (list[0] && (current_billing_address.isnew() == 1)) { + current_billing_address = list[0]; ou_list_store.setValue( current_ou, "billing_address", current_billing_address.id()); save_org(); @@ -665,11 +668,9 @@ highlighter.addresses_pane.red.play(); status_update( dojo.string.substitute( aou_strings.ERROR_SAVING_HOLDS, [ou_list_store.getValue( current_ou, 'name' )] ) ); }, - oncomplete : function (r) { - var res = r.recv(); - if (res && res.content() - && (current_holds_address.isnew() == 1)) { - current_holds_address = res.content(); + oncomplete : function (r, list) { + if (list[0] && (current_holds_address.isnew() == 1)) { + current_holds_address = list[0]; ou_list_store.setValue( current_ou, "holds_address", current_holds_address.id()); save_org(); @@ -734,11 +735,9 @@ highlighter.addresses_pane.red.play(); status_update( dojo.string.substitute( aou_strings.ERROR_SAVING_MAILING, [ou_list_store.getValue( current_ou, 'name' )] ) ); }, - oncomplete : function (r) { - var res = r.recv(); - if (res && res.content() - && (current_mailing_address.isnew() == 1)) { - current_mailing_address = res.content(); + oncomplete : function (r, list) { + if (list[0] && (current_mailing_address.isnew() == 1)) { + current_mailing_address = list[0]; ou_list_store.setValue( current_ou, "mailing_address", current_mailing_address.id()); save_org(); @@ -803,11 +802,9 @@ highlighter.addresses_pane.red.play(); status_update( dojo.string.substitute( aou_strings.ERROR_SAVING_ILL, [ou_list_store.getValue( current_ou, 'name' )] ) ); }, - oncomplete : function (r) { - var res = r.recv(); - if (res && res.content() - && (current_ill_address.isnew() == 1)) { - current_ill_address = res.content(); + oncomplete : function (r, list) { + if (list[0] && (current_ill_address.isnew() == 1)) { + current_ill_address = list[0]; ou_list_store.setValue( current_ou, "ill_address", current_ill_address.id()); save_org(); diff --git a/Open-ILS/web/conify/global/actor/org_unit.js b/Open-ILS/web/conify/global/actor/org_unit.js index 066deddf70..41cc5e8a23 100644 --- a/Open-ILS/web/conify/global/actor/org_unit.js +++ b/Open-ILS/web/conify/global/actor/org_unit.js @@ -71,9 +71,8 @@ function save_org () { highlighter.editor_pane.red.play(); status_update( dojo.string.substitute( aou_strings.ERROR_SAVING_DATA, [ou_list_store.getValue( current_ou, 'name' )] ) ); }, - oncomplete : function (r) { - var res = r.recv(); - if ( res && res.content() ) { + oncomplete : function (r, list) { + if ( list[0] ) { ou_list_store.setValue( current_ou, 'ischanged', 0 ); highlighter.editor_pane.green.play(); status_update( dojo.string.substitute( aou_strings.SUCCESS_SAVE, [ou_list_store.getValue( current_ou, 'name' )] ) ); -- 2.43.2