From: Joseph Lewis Date: Tue, 9 Aug 2011 17:52:01 +0000 (-0600) Subject: Finished moving most of the Javascript to an external file. X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=7c9a833184275f18fccd2ed4a8c71b1e3b5e1a79;p=evergreen%2Fjoelewis.git Finished moving most of the Javascript to an external file. Signed-off-by: Joseph Lewis --- diff --git a/Open-ILS/web/conify/global/actor/org_unit.html b/Open-ILS/web/conify/global/actor/org_unit.html index 1c71ea4bf9..f40e705d55 100644 --- a/Open-ILS/web/conify/global/actor/org_unit.html +++ b/Open-ILS/web/conify/global/actor/org_unit.html @@ -121,23 +121,6 @@ window.ou_type_store = new dojo.data.ItemFileReadStore({ data : window._ou_type_data }); } }); - - highlighter.ou_tree = {}; - highlighter.editor_pane = {}; - highlighter.hoo_pane = {}; - highlighter.addresses_pane = {}; - - highlighter.ou_tree.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'ou_tree', duration : 500 } ); - highlighter.ou_tree.red = dojox.fx.highlight( { color : '#FF2018', node : 'ou_tree', duration : 500 } ); - - highlighter.editor_pane.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'editor_pane', duration : 500 } ); - highlighter.editor_pane.red = dojox.fx.highlight( { color : '#FF2018', node : 'editor_pane', duration : 500 } ); - - highlighter.hoo_pane.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'hoo_pane', duration : 500 } ); - highlighter.hoo_pane.red = dojox.fx.highlight( { color : '#FF2018', node : 'hoo_pane', duration : 500 } ); - - highlighter.addresses_pane.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'addresses_pane', duration : 500 } ); - highlighter.addresses_pane.red = dojox.fx.highlight( { color : '#FF2018', node : 'addresses_pane', duration : 500 } ); ]]>
-
- @@ -579,39 +434,10 @@ - @@ -649,39 +475,10 @@ - @@ -718,39 +515,10 @@ - @@ -787,39 +555,10 @@ - diff --git a/Open-ILS/web/conify/global/actor/org_unit.js b/Open-ILS/web/conify/global/actor/org_unit.js index 066deddf70..f9c4e2ceb2 100644 --- a/Open-ILS/web/conify/global/actor/org_unit.js +++ b/Open-ILS/web/conify/global/actor/org_unit.js @@ -50,7 +50,26 @@ var aou_strings = dojo.i18n.getLocalization('openils.conify', 'conify'); //var ou_type_store = new dojo.data.ItemFileWriteStore({ data : aout.toStoreData( globalOrgTypes ) }); +// Provides visual alerts when something changes. var highlighter = {}; +highlighter.ou_tree = {}; +highlighter.editor_pane = {}; +highlighter.hoo_pane = {}; +highlighter.addresses_pane = {}; + +highlighter.ou_tree.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'ou_tree', duration : 500 } ); +highlighter.ou_tree.red = dojox.fx.highlight( { color : '#FF2018', node : 'ou_tree', duration : 500 } ); + +highlighter.editor_pane.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'editor_pane', duration : 500 } ); +highlighter.editor_pane.red = dojox.fx.highlight( { color : '#FF2018', node : 'editor_pane', duration : 500 } ); + +highlighter.hoo_pane.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'hoo_pane', duration : 500 } ); +highlighter.hoo_pane.red = dojox.fx.highlight( { color : '#FF2018', node : 'hoo_pane', duration : 500 } ); + +highlighter.addresses_pane.green = dojox.fx.highlight( { color : '#B4FFB4', node : 'addresses_pane', duration : 500 } ); +highlighter.addresses_pane.red = dojox.fx.highlight( { color : '#FF2018', node : 'addresses_pane', duration : 500 } ); + + function status_update (markup) { if (parent !== window && parent.status_update) parent.status_update( markup ); @@ -162,3 +181,221 @@ function set_addr_inputs (type) { window[type + '_addr_san'].setValue( window['current_' + type + '_address'].san() || '' ); } +/** + * 2011/08/08 - Joseph Lewis + * + * This function originally resided in org_unit.html, it was too long + * to keep there. + * + * + */ +function delete_ou() { + var old_name = ou_list_store.getValue( current_ou, 'name' ); + if (ou_list_store.getValue( current_ou, '_trueRoot' ) == 'true') { + highlighter.editor_pane.red.play(); + status_update( dojo.string.substitute( aou_strings.ERROR_DELETING_LAST_AOU, [ou_list_store.getValue( current_ou, 'name' )] ) ); + return false; + } + + if ( current_ou.children ) { + var kids = current_ou.children; + if (!dojo.isArray(kids)) kids = [kids]; + + var existing_kids = dojo.filter( + kids, + function(kid){ return kid.isdeleted[0] != 1 } + ); + if ( existing_kids.length > 0) { + highlighter.editor_pane.red.play(); + status_update( dojo.string.substitute( aou_strings.ERROR_ORPHANS, [ou_list_store.getValue( current_ou, 'name' ), existing_kids.length] ) ); + return; + } + } + + 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 ); + + 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) { + 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 + } + + 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])); + } + }); + } +} + + +function changeAddr() { + 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' )] ) ); + }, + }); +} + +function saveHoldsAddrs() { + 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' )] ) ); + }, + }); +} + +function billingAddrChange() { + 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' )] ) ); + }, + }); +} + +function newChild() { + var new_fm_obj = new aou().fromHash({ + isnew : 1, + 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' ) + }); + + pcrud.create( new_fm_obj, { + timeout : 10, + onerror : function (r) { + highlighter.editor_pane.red.play(); + status_update( aou_strings.ERROR_CREATING_CHILD_AOU ); + }, + oncomplete : function (r) { + var res = r.recv(); + if ( res && res.content() ) { + ou_list_store.newItem( + res.content().toHash(), + { parent : current_ou, attribute : 'children' } + ); + } else { + highlighter.editor_pane.red.play(); + status_update( aou_strings.ERROR_CREATING_CHILD_AOU ); + } + } + }); + + highlighter.editor_pane.green.play(); + highlighter.ou_tree.green.play(); + status_update( dojo.string.substitute(aou_strings.SUCCESS_CREATING_CHILD_AOU, [ou_list_store.getValue( current_ou, 'name' )] ) ); + +} \ No newline at end of file