[OPEN-ILS-DEV] ***SPAM*** Re: Preliminary Conify (Org. Units) Patch

Mike Rylander mrylander at gmail.com
Fri Oct 23 12:22:21 EDT 2009


On Fri, Oct 23, 2009 at 12:03 PM, Warren Layton <warren.layton at gmail.com> wrote:
> On Fri, Oct 23, 2009 at 11:27 AM, Warren Layton <warren.layton at gmail.com> wrote:
>> Attached is the new patch for review/testing (against
>> tags/rel_1_6_0_0). DCO is below, just in case.
>
> Hello again,
>
> As a bonus, attached is a patch for both affected files in which I ran
> ":1,$s/\t/    /g" in Vim (turning tabs into 4 spaces). Thanks for
> pointing it out on the #evergreen channel -- I always forget about the
> spacing stuff!

Heh ... I was busily reviewing your first version and missed the next
two.  Take a look at the attached patch against org_unit.js (against
stock version), which I believe changes things in the way you want,
but with less cut-n-paste for each address.  The only question I have
is about setting ischanged on the hoo and aua objects when your fetch
them in the load_...() functions.  I've retained that from your
earlier patch, but I'm not sure of the purpose.

If your cross-review looks good, I'll commit your HTML and my JS, eh?

--miker

>
> Cheers,
>  Warren Layton
>  NRCan Library / Bibliothèque RNCan
>
>
>> =============================================
>> Developer's Certificate of Origin 1.1
>>
>> By making a contribution to this project, I certify that:
>>
>> (a) The contribution was created in whole or in part by me and I
>>    have the right to submit it under the open source license
>>    indicated in the file; or
>>
>> (b) The contribution is based upon previous work that, to the best
>>    of my knowledge, is covered under an appropriate open source
>>    license and I have the right under that license to submit that
>>    work with modifications, whether created in whole or in part
>>    by me, under the same open source license (unless I am
>>    permitted to submit under a different license), as indicated
>>    in the file; or
>>
>> (c) The contribution was provided directly to me by some other
>>    person who certified (a), (b) or (c) and I have not modified
>>    it.
>>
>> (d) I understand and agree that this project and the contribution
>>    are public and that a record of the contribution (including all
>>    personal information I submit with it, including my sign-off) is
>>    maintained indefinitely and may be redistributed consistent with
>>    this project or the open source license(s) involved.
>>
>> Signed-off-by: Warren A. Layton
>> =============================================
>>
>



-- 
Mike Rylander
 | VP, Research and Design
 | Equinox Software, Inc. / The Evergreen Experts
 | phone:  1-877-OPEN-ILS (673-6457)
 | email:  miker at esilibrary.com
 | web:  http://www.esilibrary.com
-------------- next part --------------
--- Open-ILS/web/conify/global/actor/org_unit.js	2009-10-23 12:15:50.000000000 -0400
+++ Open-ILS/web/conify/global/actor/org_unit.js	2009-10-23 12:09:22.000000000 -0400
@@ -40,10 +40,9 @@ dojo.requireLocalization("openils.conify
 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;
 
@@ -64,9 +63,9 @@ function save_org () {
 	delete_ou_button.disabled = false;
 
 	var modified_ou = new aou().fromStoreItem( current_ou );
-	modified_ou.ischanged( 1 );
+    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();
@@ -90,19 +89,20 @@ function save_org () {
 function hoo_load () {
 	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' )});
+    var hours_list = pcrud.search( 'aouhoo',{id:ou_list_store.getValue( current_ou, 'id' )});
+
+    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');
 		}
-	} 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' )]);
-			}
-		});
 	}
 
 	for (var i = 0; i < 7; i++) {
@@ -117,133 +117,35 @@ function hoo_load () {
 	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;
 
-	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();
+        if (this_addr.length) {
+            window[cur_var_name] = this_addr[0];
+            window[cur_var_name].ischanged( 1 ); // XXX why?
 	} 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.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;
-
-				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();
+            window[cur_var_name] = new aoa().fromHash({
+                isnew       :   1,
+                org_unit    :   ou_list_store.getValue( current_ou, 'id' )
+            });
 				}
-
-				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(atype);
 				}
 
-				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');
-	}
 
 }
 


More information about the Open-ils-dev mailing list