[open-ils-commits] r14167 - in branches/rel_1_6_0/Open-ILS: examples web/conify/global/actor (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Sep 24 21:19:18 EDT 2009
Author: miker
Date: 2009-09-24 21:19:17 -0400 (Thu, 24 Sep 2009)
New Revision: 14167
Modified:
branches/rel_1_6_0/Open-ILS/examples/fm_IDL.xml
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:
Backporting r14165:
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.
Modified: branches/rel_1_6_0/Open-ILS/examples/fm_IDL.xml
===================================================================
--- branches/rel_1_6_0/Open-ILS/examples/fm_IDL.xml 2009-09-25 01:18:41 UTC (rev 14166)
+++ branches/rel_1_6_0/Open-ILS/examples/fm_IDL.xml 2009-09-25 01:19:17 UTC (rev 14167)
@@ -1508,14 +1508,14 @@
<field name="org_unit" oils_persist:virtual="true" reporter:datatype="org_unit"/>
</fields>
<links>
- <link field="org_unit" reltype="might_have" key="id" map="" class="aou"/>
+ <link field="id" reltype="might_have" key="id" map="" class="aou"/>
</links>
<permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
<actions>
- <create permission="CREATE_HOURS_OF_OPERATION" context_field="org_unit"/>
+ <create permission="CREATE_HOURS_OF_OPERATION" context_field="id"/>
<retrieve/>
- <update permission="UPDATE_HOURS_OF_OPERATION" context_field="org_unit"/>
- <delete permission="DELETE_HOURS_OF_OPERATION" context_field="org_unit"/>
+ <update permission="UPDATE_HOURS_OF_OPERATION" context_field="id"/>
+ <delete permission="DELETE_HOURS_OF_OPERATION" context_field="id"/>
</actions>
</permacrud>
</class>
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-09-25 01:18:41 UTC (rev 14166)
+++ branches/rel_1_6_0/Open-ILS/web/conify/global/actor/org_unit.html 2009-09-25 01:19:17 UTC (rev 14167)
@@ -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();
-
+ });
}
]]>
</script>
@@ -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 @@
</table>
<button jsId="save_hoo_button" dojoType="dijit.form.Button" label="&conify.save_button.label;">
+ <script type="dojo/connect" event="startup">
+ this.disabled = true;
+ </script>
<script type="dojo/connect" event="onClick">
<![CDATA[
- var method_name = 'open-ils.pcrud.update.aouhoo';
- if (current_ou_hoo.isnew() == 1) method_name = 'open-ils.pcrud.create.aouhoo';
-
- pCRUD.request({
- method : method_name,
- params : [ ses, current_ou_hoo ],
- onerror : function (r) {
- highlighter.editor_pane.red.play();
- status_update( dojo.string.substitute( aou_strings.ERROR_SAVING_HOO, [ou_list_store.getValue( current_ou, 'name' )] ) );
- },
- oncomplete : function (r) {
- var res = r.recv();
- if ( res && res.content() ) {
- current_ou_hoo.isnew(0);
- highlighter.editor_pane.green.play();
+ 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 {
- highlighter.editor_pane.red.play();
+ },
+ });
+ } 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' )] ) );
- }
- },
- }).send();
+ },
+ 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' )] ) );
+ },
+ });
+ }
+
]]>
</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-09-25 01:18:41 UTC (rev 14166)
+++ branches/rel_1_6_0/Open-ILS/web/conify/global/actor/org_unit.js 2009-09-25 01:19:17 UTC (rev 14167)
@@ -42,7 +42,7 @@
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 @@
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 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);
+ save_hoo_button.disabled = false;
- 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();
+ 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' )]);
}
+ });
+ }
- 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']() )
+ );
+ }
- 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();
- }
- }).send();
-
+ highlighter.hoo_pane.green.play();
}
function addr_load () {
More information about the open-ils-commits
mailing list