});
},
- 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;
}
transFunction = that.getTransFunction(),
transWorkspace = that.getTransWorkspace();
+ that._printModels = [];
+
// If argument is false, this whole process was cancelled
if (workspace === false) {
return;
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");
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 () {
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 = {},
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
// 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;
}));