[open-ils-commits] r18386 - in trunk/Open-ILS: src/perlmods/OpenILS/Application web/js/dojo/openils/widget web/js/ui/default/conify/global/asset web/templates/default/conify/global/asset (senator)
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Oct 18 17:53:50 EDT 2010
Author: senator
Date: 2010-10-18 17:53:44 -0400 (Mon, 18 Oct 2010)
New Revision: 18386
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm
trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js
trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js
trunk/Open-ILS/web/js/ui/default/conify/global/asset/copy_template.js
trunk/Open-ILS/web/templates/default/conify/global/asset/copy_template.tt2
Log:
Make editing of asset.copy_template a little more friendly (AutoGrid w/ pcrud
can't deal with editor/creator fields for you).
Incidentally add createPaneOnSubmit and editPaneOnSubmit attributes to
AutoGrid that take a function name as their values, specifying an alternate
callback function to use instead of pcrud.create/update
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm 2010-10-18 19:47:06 UTC (rev 18385)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm 2010-10-18 21:53:44 UTC (rev 18386)
@@ -1191,4 +1191,35 @@
return $mfhd->id;
}
+__PACKAGE__->register_method(
+ method => "create_update_asset_copy_template",
+ api_name => "open-ils.cat.asset.copy_template.create_or_update"
+);
+
+sub create_update_asset_copy_template {
+ my ($self, $client, $authtoken, $act) = @_;
+
+ my $e = new_editor("xact" => 1, "authtoken" => $authtoken);
+ return $e->die_event unless $e->checkauth;
+ return $e->die_event unless $e->allowed(
+ "ADMIN_ASSET_COPY_TEMPLATE", $act->owning_lib
+ );
+
+ $act->editor($e->requestor->id);
+ $act->edit_date("now");
+
+ my $retval;
+ if (!$act->id) {
+ $act->creator($e->requestor->id);
+ $act->create_date("now");
+
+ $e->create_asset_copy_template($act) or return $e->die_event;
+ $retval = $e->data;
+ } else {
+ $e->update_asset_copy_template($act) or return $e->die_event;
+ $retval = $e->retrieve_asset_copy_template($e->data);
+ }
+ $e->commit and return $retval;
+}
+
1;
Modified: trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js 2010-10-18 19:47:06 UTC (rev 18385)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js 2010-10-18 21:53:44 UTC (rev 18386)
@@ -15,6 +15,8 @@
{
/* if true, pop up an edit dialog when user hits Enter on a give row */
+ editPaneOnSubmit : null,
+ createPaneOnSubmit : null,
editOnEnter : false,
defaultCellWidth : null,
editStyle : 'dialog',
@@ -404,6 +406,8 @@
}
});
+ if (typeof this.editPaneOnSubmit == "function")
+ pane.onSubmit = this.editPaneOnSubmit;
pane.fieldOrder = this.fieldOrder;
pane.mode = 'update';
return pane;
@@ -438,6 +442,8 @@
if(onCancel) onCancel();
}
});
+ if (typeof this.createPaneOnSubmit == "function")
+ pane.onSubmit = this.createPaneOnSubmit;
pane.fieldOrder = this.fieldOrder;
pane.mode = 'create';
return pane;
Modified: trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js 2010-10-18 19:47:06 UTC (rev 18385)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/EditPane.js 2010-10-18 21:53:44 UTC (rev 18386)
@@ -213,6 +213,7 @@
},
performEditAction : function(opts) {
+ var self = this;
var fields = this.getFields();
if(this.mode == 'create')
this.fmObject = new fieldmapper[this.fmClass]();
@@ -221,7 +222,7 @@
if(this.mode == 'create' && this.fmIDL.pkey_sequence)
this.fmObject[this.fmIDL.pkey](null);
if (typeof(this.onSubmit) == "function") {
- this.onSubmit(this.fmObject);
+ this.onSubmit(this.fmObject, opts, self);
} else {
(new openils.PermaCrud())[this.mode](this.fmObject, opts);
}
Modified: trunk/Open-ILS/web/js/ui/default/conify/global/asset/copy_template.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/conify/global/asset/copy_template.js 2010-10-18 19:47:06 UTC (rev 18385)
+++ trunk/Open-ILS/web/js/ui/default/conify/global/asset/copy_template.js 2010-10-18 21:53:44 UTC (rev 18386)
@@ -9,6 +9,21 @@
var actOwner;
var actList;
+function create_or_update_act(obj, opts, edit_pane) {
+ fieldmapper.standardRequest(
+ ["open-ils.cat", "open-ils.cat.asset.copy_template.create_or_update"], {
+ "params": [openils.User.authtoken, obj],
+ "async": true,
+ "oncomplete": function(r) {
+ if (r = openils.Util.readResponse(r)) {
+ if (edit_pane.onPostSubmit)
+ edit_pane.onPostSubmit();
+ }
+ }
+ }
+ );
+}
+
function actInit() {
pcrud = new openils.PermaCrud();
Modified: trunk/Open-ILS/web/templates/default/conify/global/asset/copy_template.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/conify/global/asset/copy_template.tt2 2010-10-18 19:47:06 UTC (rev 18385)
+++ trunk/Open-ILS/web/templates/default/conify/global/asset/copy_template.tt2 2010-10-18 21:53:44 UTC (rev 18386)
@@ -23,11 +23,14 @@
<table jsId="actGrid"
dojoType="openils.widget.AutoGrid"
fieldOrder="['name', 'owning_lib']"
- suppressFields="['creator','editor','edit_date', 'create_date']"
+ suppressFields="['creator','editor','edit_date','create_date']"
+ suppressEditFields="['creator','editor','edit_date','create_date']"
query="{id: '*'}"
editStyle="pane"
fmClass="act"
autoHeight="true"
+ createPaneOnSubmit="create_or_update_act"
+ editPaneOnSubmit="create_or_update_act"
editOnEnter="true">
</table>
</div>
More information about the open-ils-commits
mailing list