[open-ils-commits] r14581 - branches/rel_1_6_0/Open-ILS/web/conify/global/actor (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Oct 23 13:31:55 EDT 2009
Author: miker
Date: 2009-10-23 13:31:51 -0400 (Fri, 23 Oct 2009)
New Revision: 14581
Modified:
branches/rel_1_6_0/Open-ILS/web/conify/global/actor/org_unit.html
branches/rel_1_6_0/Open-ILS/web/conify/global/actor/org_unit.js
Log:
Patch from Warren Layton which fixes the behavior of the new Org Unit
configuration interfaces. Moving from raw open-ils.pcrud service calls to the
handy openils.PermaCrud dojo module.
Applied with minor editorialization to remove some duplicated code.
Modified: branches/rel_1_6_0/Open-ILS/web/conify/global/actor/org_unit.html
===================================================================
--- branches/rel_1_6_0/Open-ILS/web/conify/global/actor/org_unit.html 2009-10-23 17:31:27 UTC (rev 14580)
+++ branches/rel_1_6_0/Open-ILS/web/conify/global/actor/org_unit.html 2009-10-23 17:31:51 UTC (rev 14581)
@@ -81,7 +81,7 @@
ou_list_store.onSet = function (item, attr, o, n) {
if (attr == 'ischanged') return;
- if (n == o) return;
+ if ((n == o) || ((o == null) && (n == ''))) return;
this.setValue( item, 'ischanged', 1);
};
@@ -103,7 +103,7 @@
if (confirmation) {
for (var i in dirtyStore) {
- window.current_ou = window.dirtyStore[i];
+ current_ou = window.dirtyStore[i];
save_org(true);
}
}
@@ -349,26 +349,39 @@
if (confirm(dojo.string.substitute(aou_strings.CONFIRM_DELETE, [current_ou.name]))) {
ou_list_store.setValue( current_ou, 'isdeleted', 1 );
-
+
var modified_ou = new aou().fromStoreItem( current_ou );
modified_ou.isdeleted( 1 );
-
- pcrud.eliminate( modified_ou, {
+
+ var objs = [];
+ objs.push(modified_ou);
+ if (!current_billing_address.isnew()) {
+ 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);
+ }
+ if (!current_holds_address.isnew()) {
+ 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, {
timeout : 10,
onerror : function (r) {
highlighter.editor_pane.red.play();
status_update(dojo.string.substitute(aou_strings.ERROR_DELETING, [old_name]));
},
oncomplete : function (r) {
- 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;
@@ -380,6 +393,20 @@
window["editor_pane_" + field].setDisplayedValue( '' ); // unset the value
}
+ 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) { } },
+ 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_ou = null;
+
highlighter.editor_pane.green.play();
status_update(dojo.string.substitute(aou_strings.STATUS_DELETED, [old_name]));
}
@@ -399,15 +426,13 @@
<![CDATA[
var new_fm_obj = new aou().fromHash({
isnew : 1,
- name : aou_strings.LABEL_NEW_BRANCH,
+ name : aou_strings.LABEL_NEW_BRANCH + virgin_ou_id,
opac_visible : 'f',
shortname : ou_list_store.getValue( current_ou, 'shortname' ) + '-NEW' + virgin_ou_id--,
parent_ou : ou_list_store.getValue( current_ou, 'id' ),
ou_type : ou_list_store.getValue( current_ou, 'ou_type' )
});
-
- var new_obj;
-
+
pcrud.create( new_fm_obj, {
timeout : 10,
onerror : function (r) {
@@ -483,33 +508,23 @@
</script>
<script type="dojo/connect" event="onClick">
<![CDATA[
- if (hoo_id.length == 0) {
- pcrud.create( current_ou_hoo, {
- timeout : 10,
- onerror : function (r) {
- highlighter.hoo_pane.red.play();
- status_update( dojo.string.substitute( aou_strings.ERROR_SAVING_HOO, [ou_list_store.getValue( current_ou, 'name' )] ) );
- },
- oncomplete : function (r) {
- hoo_id = pcrud.search( 'aouhoo',{id:ou_list_store.getValue( current_ou, 'id' )});
- highlighter.hoo_pane.green.play();
- status_update( dojo.string.substitute( aou_strings.SUCCESS_SAVING_HOO, [ou_list_store.getValue( current_ou, 'name' )] ) );
- },
- });
- } else {
- pcrud.update( current_ou_hoo, {
- timeout : 10,
- onerror : function (r) {
- highlighter.hoo_pane.red.play();
- status_update( dojo.string.substitute( aou_strings.ERROR_SAVING_HOO, [ou_list_store.getValue( current_ou, 'name' )] ) );
- },
- oncomplete : function (r) {
- highlighter.hoo_pane.green.play();
- status_update( dojo.string.substitute( aou_strings.SUCCESS_SAVING_HOO, [ou_list_store.getValue( current_ou, 'name' )] ) );
- },
- });
- }
-
+ if (!current_ou_hoo.isnew()) {
+ current_ou_hoo.ischanged( 1 );
+ }
+
+ pcrud.apply( current_ou_hoo, {
+ timeout : 10,
+ onerror : function (r) {
+ highlighter.hoo_pane.red.play();
+ status_update( dojo.string.substitute( aou_strings.ERROR_SAVING_HOO, [ou_list_store.getValue( current_ou, 'name' )] ) );
+ },
+ oncomplete : function (r) {
+ current_ou_hoo.isnew( 0 );
+ current_ou_hoo.ischanged( 0 );
+ highlighter.hoo_pane.green.play();
+ status_update( dojo.string.substitute( aou_strings.SUCCESS_SAVING_HOO, [ou_list_store.getValue( current_ou, 'name' )] ) );
+ },
+ });
]]>
</script>
</button>
@@ -521,10 +536,10 @@
<div id="billing_address_pane" dojoType="dijit.layout.TabContainer" style="margin-top:10px">
<script type="dojo/method">
- window.current_billing_address = null;
- window.current_mailing_address = null;
- window.current_holds_address = null;
- window.current_ill_address = null;
+ current_billing_address = null;
+ current_mailing_address = null;
+ current_holds_address = null;
+ current_ill_address = null;
</script>
<div id="billing_address" dojoType="dijit.layout.ContentPane" title="&conify.org_unit.addresses_pane.physical.title;">
@@ -567,33 +582,31 @@
</script>
<script type="dojo/connect" event="onClick">
<![CDATA[
- var method_name = 'open-ils.pcrud.update.aoa';
- if (current_billing_address.isnew() == 1) method_name = 'open-ils.pcrud.create.aoa';
-
- pCRUD.request({
- method : method_name,
- params : [ ses, current_billing_address ],
- onerror : function (r) {
- 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() ) {
- if (current_billing_address.isnew() == 1) {
- current_billing_address = res.content();
- ou_list_store.setValue( current_ou, 'billing_address', current_billing_address.id() );
- save_org();
- }
- current_billing_address.isnew(0);
- highlighter.addresses_pane.green.play();
- status_update( dojo.string.subsitute( aou_strings.SUCCESS_SAVING_PHYSICAL, [ou_list_store.getValue( current_ou, 'name' )] ) );
- } else {
- highlighter.addresses_pane.red.play();
- status_update( dojo.string.substitute( aou_strings.ERROR_SAVING_PHYSICAL, [ou_list_store.getValue( current_ou, 'name' )] ) );
- }
- },
- }).send();
+ if (!current_billing_address.isnew()) {
+ current_billing_address.ischanged( 1 );
+ }
+
+ pcrud.apply( current_billing_address, {
+ timeout : 10,
+ onerror : function (r) {
+ 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();
+
+ ou_list_store.setValue( current_ou, "billing_address", current_billing_address.id());
+ save_org();
+ }
+ current_billing_address.isnew( 0 );
+ current_billing_address.ischanged( 0 );
+ highlighter.addresses_pane.green.play();
+ status_update( dojo.string.substitute( aou_strings.SUCCESS_SAVING_PHYSICAL, [ou_list_store.getValue( current_ou, 'name' )] ) );
+ },
+ });
]]>
</script>
</button>
@@ -636,33 +649,31 @@
</script>
<script type="dojo/connect" event="onClick">
<![CDATA[
- var method_name = 'open-ils.pcrud.update.aoa';
- if (current_holds_address.isnew() == 1) method_name = 'open-ils.pcrud.create.aoa';
-
- pCRUD.request({
- method : method_name,
- params : [ ses, current_holds_address ],
- onerror : function (r) {
- highlighter.addresses_pane.red.play();
- throw 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() ) {
- if (current_holds_address.isnew() == 1) {
- current_holds_address = res.content();
- ou_list_store.setValue( current_ou, 'holds_address', current_holds_address.id() );
- save_org();
- }
- current_holds_address.isnew(0);
- highlighter.addresses_pane.green.play();
- status_update( dojo.string.substitute( aou_strings.SUCCESS_SAVING_HOLDS, [ou_list_store.getValue( current_ou, 'name' )] ) );
- } else {
- highlighter.addresses_pane.red.play();
- throw dojo.string.substitute( aou_strings.ERROR_SAVING_HOLDS, [ou_list_store.getValue( current_ou, 'name' )] );
- }
- },
- }).send();
+ if (!current_holds_address.isnew()) {
+ current_holds_address.ischanged( 1 );
+ }
+
+ pcrud.apply( current_holds_address, {
+ timeout : 10,
+ onerror : function (r) {
+ 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();
+
+ ou_list_store.setValue( current_ou, "holds_address", current_holds_address.id());
+ save_org();
+ }
+ current_holds_address.isnew( 0 );
+ current_holds_address.ischanged( 0 );
+ highlighter.addresses_pane.green.play();
+ status_update( dojo.string.substitute( aou_strings.SUCCESS_SAVING_HOLDS, [ou_list_store.getValue( current_ou, 'name' )] ) );
+ },
+ });
]]>
</script>
</button>
@@ -704,33 +715,31 @@
</script>
<script type="dojo/connect" event="onClick">
<![CDATA[
- var method_name = 'open-ils.pcrud.update.aoa';
- if (current_mailing_address.isnew() == 1) method_name = 'open-ils.pcrud.create.aoa';
-
- pCRUD.request({
- method : method_name,
- params : [ ses, current_mailing_address ],
- onerror : function (r) {
- highlighter.addresses_pane.red.play();
- throw 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() ) {
- if (current_mailing_address.isnew() == 1) {
- current_mailing_address = res.content();
- ou_list_store.setValue( current_ou, 'mailing_address', current_mailing_address.id() );
- save_org();
- }
- current_mailing_address.isnew(0);
- highlighter.addresses_pane.green.play();
- status_update( dojo.string.substitute( aou_strings.SUCCESS_SAVING_MAILING, [ou_list_store.getValue( current_ou, 'name' )] ) );
- } else {
- highlighter.addresses_pane.red.play();
- throw dojo.string.substitute( aou_strings.ERROR_SAVING_MAILING, [ou_list_store.getValue( current_ou, 'name' )] );
- }
- },
- }).send();
+ if (!current_mailing_address.isnew()) {
+ current_mailing_address.ischanged( 1 );
+ }
+
+ pcrud.apply( current_mailing_address, {
+ timeout : 10,
+ onerror : function (r) {
+ 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();
+
+ ou_list_store.setValue( current_ou, "mailing_address", current_mailing_address.id());
+ save_org();
+ }
+ current_mailing_address.isnew( 0 );
+ current_mailing_address.ischanged( 0 );
+ highlighter.addresses_pane.green.play();
+ status_update( dojo.string.substitute( aou_strings.SUCCESS_SAVING_MAILING, [ou_list_store.getValue( current_ou, 'name' )] ) );
+ },
+ });
]]>
</script>
</button>
@@ -772,33 +781,31 @@
</script>
<script type="dojo/connect" event="onClick">
<![CDATA[
- var method_name = 'open-ils.pcrud.update.aoa';
- if (current_ill_address.isnew() == 1) method_name = 'open-ils.pcrud.create.aoa';
-
- pCRUD.request({
- method : method_name,
- params : [ ses, current_ill_address ],
- onerror : function (r) {
- highlighter.addresses_pane.red.play();
- throw 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() ) {
- if (current_ill_address.isnew() == 1) {
- current_ill_address = res.content();
- ou_list_store.setValue( current_ou, 'ill_address', current_ill_address.id() );
- save_org();
- }
- current_ill_address.isnew(0);
- highlighter.addresses_pane.green.play();
- status_update( dojo.string.substitute( aou_strings.SUCCESS_SAVING_ILL, [ou_list_store.getValue( current_ou, 'name' )] ) );
- } else {
- highlighter.addresses_pane.red.play();
- throw dojo.string.substitute( aou_strings.ERROR_SAVING_ILL, [ou_list_store.getValue( current_ou, 'name' )] );
- }
- },
- }).send();
+ if (!current_ill_address.isnew()) {
+ current_ill_address.ischanged( 1 );
+ }
+
+ pcrud.apply( current_ill_address, {
+ timeout : 10,
+ onerror : function (r) {
+ 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();
+
+ ou_list_store.setValue( current_ou, "ill_address", current_ill_address.id());
+ save_org();
+ }
+ current_ill_address.isnew( 0 );
+ current_ill_address.ischanged( 0 );
+ highlighter.addresses_pane.green.play();
+ status_update( dojo.string.substitute( aou_strings.SUCCESS_SAVING_ILL, [ou_list_store.getValue( current_ou, 'name' )] ) );
+ },
+ });
]]>
</script>
</button>
Modified: branches/rel_1_6_0/Open-ILS/web/conify/global/actor/org_unit.js
===================================================================
--- branches/rel_1_6_0/Open-ILS/web/conify/global/actor/org_unit.js 2009-10-23 17:31:27 UTC (rev 14580)
+++ branches/rel_1_6_0/Open-ILS/web/conify/global/actor/org_unit.js 2009-10-23 17:31:51 UTC (rev 14581)
@@ -40,10 +40,9 @@
var cgi = new CGI();
var cookieManager = new HTTP.Cookies();
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, hoo_id;
+var current_ou, current_ou_hoo, ou_list_store;
var dirtyStore = [];
var virgin_ou_id = -1;
@@ -54,208 +53,111 @@
var highlighter = {};
function status_update (markup) {
- if (parent !== window && parent.status_update) parent.status_update( markup );
+ if (parent !== window && parent.status_update) parent.status_update( markup );
}
function save_org () {
- new_kid_button.disabled = false;
- save_ou_button.disabled = false;
- delete_ou_button.disabled = false;
+ new_kid_button.disabled = false;
+ save_ou_button.disabled = false;
+ delete_ou_button.disabled = false;
- var modified_ou = new aou().fromStoreItem( current_ou );
- modified_ou.ischanged( 1 );
+ var modified_ou = new aou().fromStoreItem( current_ou );
+ modified_ou.ischanged ( 1 );
- pcrud.update( modified_ou, {
+ pcrud.apply( modified_ou, {
timeout : 10, // makes it synchronous
- onerror : function (r) {
- 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() ) {
- 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' )] ) );
- } else {
- highlighter.editor_pane.red.play();
- status_update( dojo.string.substitute( aou_strings.ERROR_SAVING_DATA, [ou_list_store.getValue( current_ou, 'name' )] ) );
- }
- },
+ onerror : function (r) {
+ 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() ) {
+ 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' )] ) );
+ } else {
+ highlighter.editor_pane.red.play();
+ status_update( dojo.string.substitute( aou_strings.ERROR_SAVING_DATA, [ou_list_store.getValue( current_ou, 'name' )] ) );
+ }
+ },
});
}
-
+
function hoo_load () {
- save_hoo_button.disabled = false;
+ 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' )]);
- }
- });
- }
+ var hours_list = pcrud.search( 'aouhoo',{id:ou_list_store.getValue( current_ou, 'id' )});
- 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']() )
- );
- }
+ if (hours_list.length) {
+ current_ou_hoo = hours_list[0];
+ current_ou_hoo.ischanged(1); // XXX why?
+ } else {
+ current_ou_hoo = new aouhoo().fromHash({
+ isnew : 1,
+ 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');
+ }
+ }
- highlighter.hoo_pane.green.play();
+ 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 () {
- // 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;
+ 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.pcrud.retrieve.aoa',
- params : [ ses, ou_list_store.getValue( current_ou, 'billing_address' ) ],
- onerror : function (r) {
- throw dojo.string.substitute(aou_strings.ERROR_FETCHING_PHYSICAL, [ou_list_store.getValue( current_ou, 'name' )]);
- },
- oncomplete : function (r) {
- current_billing_address = null;
+ atype_list = ['billing','mailing','holds','ill'];
+ for (var addr_idx in atype_list) {
- var res = r.recv();
- if (res) {
- if (res.content()) current_billing_address = res.content();
- }
+ var atype = atype_list[addr_idx];
+ var cur_var_name = 'current_' + atype + '_address';
- if (!current_billing_address) {
- current_billing_address = new aoa().fromHash({org_unit:ou_list_store.getValue( current_ou, 'id' )});
- current_billing_address.isnew(1);
- }
+ var this_addr = pcrud.search( 'aoa',{id:ou_list_store.getValue( current_ou, atype + '_address')});
- 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 (this_addr.length) {
+ window[cur_var_name] = this_addr[0];
+ window[cur_var_name].ischanged( 1 ); // XXX why?
+ } else {
+ window[cur_var_name] = new aoa().fromHash({
+ isnew : 1,
+ org_unit : ou_list_store.getValue( current_ou, 'id' )
+ });
+ }
+ set_addr_inputs(atype);
+ }
- if (ou_list_store.getValue( current_ou, 'mailing_address' )) {
- pCRUD.request({
- method : 'open-ils.pcrud.retrieve.aoa',
- params : [ ses, ou_list_store.getValue( current_ou, 'mailing_address' ) ],
- onerror : function (r) {
- throw dojo.string.substitute(aou_strings.ERROR_FETCHING_MAILING, [ou_list_store.getValue( current_ou, 'name' )]);
- },
- oncomplete : function (r) {
- current_mailing_address = null;
+ highlighter.addresses_pane.green.play();
- 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.pcrud.retrieve.aoa',
- params : [ ses, ou_list_store.getValue( current_ou, 'holds_address' ) ],
- onerror : function (r) {
- throw dojo.string.substitute(aou_strings.ERROR_FETCHING_HOLDS, [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.pcrud.retrieve.aoa',
- params : [ ses, ou_list_store.getValue( current_ou, 'ill_address' ) ],
- onerror : function (r) {
- throw dojo.string.substitute(aou_strings.ERROR_FETCHING_ILL, [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() || '' );
+ 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() || '' );
}
More information about the open-ils-commits
mailing list