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
git-svn-id: svn://svn.open-ils.org/ILS/trunk@18386
dcc99617-32d9-48b4-a31d-
7c20da2025e4
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;
{
/* 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',
}
});
+ if (typeof this.editPaneOnSubmit == "function")
+ pane.onSubmit = this.editPaneOnSubmit;
pane.fieldOrder = this.fieldOrder;
pane.mode = 'update';
return pane;
if(onCancel) onCancel();
}
});
+ if (typeof this.createPaneOnSubmit == "function")
+ pane.onSubmit = this.createPaneOnSubmit;
pane.fieldOrder = this.fieldOrder;
pane.mode = 'create';
return pane;
},
performEditAction : function(opts) {
+ var self = this;
var fields = this.getFields();
if(this.mode == 'create')
this.fmObject = new fieldmapper[this.fmClass]();
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);
}
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();
<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>