issue #22243: push auxilliary data to report route
authorSteve Hackbarth <stephenhackbarth@gmail.com>
Fri, 28 Feb 2014 22:01:34 +0000 (17:01 -0500)
committerSteve Hackbarth <stephenhackbarth@gmail.com>
Fri, 28 Feb 2014 22:01:34 +0000 (17:01 -0500)
lib/backbone-x/source/model.js
lib/enyo-x/source/views/transaction_list.js
node-datasource/routes/generate_report.js
test/lib/coverage.js

index a0207d8..3433c36 100644 (file)
       });
     },
 
-    doPrint: function () {
-      XT.dataSource.callRoute("generate-report", this.getReportPayload("print"), {
+    doPrint: function (options) {
+      XT.dataSource.callRoute("generate-report", this.getReportPayload("print", options), {
         success: function () {
           console.log("print success");
         }
       return XM.Model.getReportUrl(action, modelName, this.id);
     },
 
-    getReportPayload: function (action) {
+    getReportPayload: function (action, options) {
       var modelName = this.editableModel || this.recordType;
       return {
         nameSpace: modelName.prefix(),
         type: modelName.suffix(),
         id: this.id,
+        auxilliaryInfo: options,
         action: action
       };
     },
   _.extend(XM.Model.prototype, {
     _attributeChangeFired: false,
 
-    trigger: function( eventName ) {
+    trigger: function ( eventName ) {
             if ( eventName.length > 5 && eventName.indexOf( 'change' ) === 0 ) {
                     var dit = this,
                             args = arguments;
 
-                    Backbone.Relational.eventQueue.add( function() {
+                    Backbone.Relational.eventQueue.add( function () {
                             if ( !dit._isInitialized ) {
                                     return;
                             }
index c422c74..7e743bc 100644 (file)
@@ -78,6 +78,8 @@ trailing:true, white:true, strict:false*/
           transFunction = that.getTransFunction(),
           transWorkspace = that.getTransWorkspace();
 
+        that._printModels = [];
+
         // If argument is false, this whole process was cancelled
         if (workspace === false) {
           return;
@@ -88,6 +90,11 @@ trailing:true, white:true, strict:false*/
           toTransact = model.get(model.quantityAttribute);
           transDate = model.transactionDate;
 
+
+          if (workspace._printAfterPersist) {
+            that._printModels.push(model);
+          }
+
           if (toTransact) {
             if (transFunction === "receipt") {
               wsOptions.freight = model.get("freight");
@@ -110,9 +117,10 @@ trailing:true, white:true, strict:false*/
           if (data[0]) {
             that.doProcessingChanged({isProcessing: true});
             dispOptions.success = function () {
-              if (workspace._printAfterPersist) {
-                workspace._printModel.doPrint();
-              }
+              _.each(that._printModels, function (printModel) {
+                // XXX eventually replace _auxilliaryInfo with meta, probably
+                printModel.doPrint(printModel._auxilliaryInfo);
+              });
               that.doProcessingChanged({isProcessing: false});
             };
             dispOptions.error = function () {
index 927559a..78f0a56 100644 (file)
@@ -40,6 +40,7 @@ regexp:true, undef:true, strict:true, trailing:true, white:true */
       databaseName = req.session.passport.user.organization,
       // TODO: introduce pseudorandomness (maybe a timestamp) to avoid collisions
       reportName = req.query.type.toLowerCase() + req.query.id + ".pdf",
+      auxilliaryInfo = req.query.options,
       workingDir = path.join(__dirname, "../temp", databaseName),
       reportPath = path.join(workingDir, reportName),
       imageFilenameMap = {},
@@ -523,6 +524,7 @@ regexp:true, undef:true, strict:true, trailing:true, white:true */
           return;
         }
         rawData = _.extend(rawData, result.data.data);
+        rawData = _.extend(rawData, auxilliaryInfo);
         // take the raw data and added detail fields and put
         // into array format for the report
         // XXX temporary hack
index 81b053d..1b2f98f 100644 (file)
@@ -22,6 +22,7 @@
         // filter out .swp files, etc.
         return path.extname(fileName) === '.js';
       }),
+      // TODO: consider tests in xtuple-extensions and private-extensions
       coverageArray = _.compact(_.map(specFiles, function (specFile) {
         return require(path.join(__dirname, "../specs", specFile)).spec.recordType;
       }));