[open-ils-commits] r18387 - in branches/rel_2_0/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:54:24 EDT 2010


Author: senator
Date: 2010-10-18 17:54:18 -0400 (Mon, 18 Oct 2010)
New Revision: 18387

Modified:
   branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm
   branches/rel_2_0/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js
   branches/rel_2_0/Open-ILS/web/js/dojo/openils/widget/EditPane.js
   branches/rel_2_0/Open-ILS/web/js/ui/default/conify/global/asset/copy_template.js
   branches/rel_2_0/Open-ILS/web/templates/default/conify/global/asset/copy_template.tt2
Log:
Backport r18386 from trunk, asset.copy_template editing improvement


Modified: branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm
===================================================================
--- branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm	2010-10-18 21:53:44 UTC (rev 18386)
+++ branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm	2010-10-18 21:54:18 UTC (rev 18387)
@@ -1081,4 +1081,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: branches/rel_2_0/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js
===================================================================
--- branches/rel_2_0/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js	2010-10-18 21:53:44 UTC (rev 18386)
+++ branches/rel_2_0/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js	2010-10-18 21:54:18 UTC (rev 18387)
@@ -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: branches/rel_2_0/Open-ILS/web/js/dojo/openils/widget/EditPane.js
===================================================================
--- branches/rel_2_0/Open-ILS/web/js/dojo/openils/widget/EditPane.js	2010-10-18 21:53:44 UTC (rev 18386)
+++ branches/rel_2_0/Open-ILS/web/js/dojo/openils/widget/EditPane.js	2010-10-18 21:54:18 UTC (rev 18387)
@@ -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: branches/rel_2_0/Open-ILS/web/js/ui/default/conify/global/asset/copy_template.js
===================================================================
--- branches/rel_2_0/Open-ILS/web/js/ui/default/conify/global/asset/copy_template.js	2010-10-18 21:53:44 UTC (rev 18386)
+++ branches/rel_2_0/Open-ILS/web/js/ui/default/conify/global/asset/copy_template.js	2010-10-18 21:54:18 UTC (rev 18387)
@@ -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: branches/rel_2_0/Open-ILS/web/templates/default/conify/global/asset/copy_template.tt2
===================================================================
--- branches/rel_2_0/Open-ILS/web/templates/default/conify/global/asset/copy_template.tt2	2010-10-18 21:53:44 UTC (rev 18386)
+++ branches/rel_2_0/Open-ILS/web/templates/default/conify/global/asset/copy_template.tt2	2010-10-18 21:54:18 UTC (rev 18387)
@@ -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