Skip to content

Commit 2d98182

Browse files
committed
chore(deps) Finally use up to date async
1 parent 460fe54 commit 2d98182

File tree

4 files changed

+286
-202
lines changed

4 files changed

+286
-202
lines changed

package-lock.json

Lines changed: 56 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"RESTful API"
3232
],
3333
"dependencies": {
34-
"async": "1.5.2",
34+
"async": "2.6.0",
3535
"lodash": "4.17.4",
3636
"node.extend": "1.1.6"
3737
},
@@ -45,6 +45,7 @@
4545
"@types/jquery": "^2.0.41",
4646
"@types/lodash": "4.14.64",
4747
"@types/node": "^6.0.65",
48+
"@types/mongoose": "^4.7.27",
4849
"body-parser": "1.16.0",
4950
"del": "2.2.2",
5051
"express": "4.14.1",

server/data_form.js

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22
Object.defineProperty(exports, "__esModule", { value: true });
3-
/// <reference path="../node_modules/@types/mongoose/index.d.ts" />
43
// This part of forms-angular borrows _very_ heavily from https://github.com/Alexandre-Strzelewicz/angular-bridge
54
// (now https://github.com/Unitech/angular-bridge
65
var _ = require('lodash');
@@ -41,10 +40,8 @@ var DataForm = function (mongoose, app, options) {
4140
this.searchFunc = async.forEach;
4241
this.registerRoutes();
4342
this.app.get.apply(this.app, processArgs(this.options, ['search', this.searchAll()]));
44-
if (this.options.JQMongoFileUploader) {
45-
var JqUploadModule = this.options.JQMongoFileUploader.module || require('fng-jq-upload').Controller;
46-
this.fileUploader = new JqUploadModule(this, processArgs, this.options.JQMongoFileUploader);
47-
void (this.fileUploader); // suppress warning
43+
for (var plugin in this.options.plugins) {
44+
this[plugin] = new this.options.plugins[plugin].module(this, processArgs, this.options.plugins[plugin].options);
4845
}
4946
};
5047
module.exports = exports = DataForm;
@@ -66,16 +63,16 @@ DataForm.prototype.getListFields = function (resource, doc, cb) {
6663
if (typeof doc[aField.field] !== 'undefined') {
6764
if (aField.params) {
6865
if (aField.params.ref) {
69-
var lookupResource = that.getResource(resource.model.schema['paths'][aField.field].options.ref);
70-
if (lookupResource) {
71-
var hiddenFields = that.generateHiddenFields(lookupResource, false);
66+
var lookupResource_1 = that.getResource(resource.model.schema['paths'][aField.field].options.ref);
67+
if (lookupResource_1) {
68+
var hiddenFields = that.generateHiddenFields(lookupResource_1, false);
7269
hiddenFields.__v = 0;
73-
lookupResource.model.findOne({ _id: doc[aField.field] }).select(hiddenFields).exec(function (err, doc2) {
70+
lookupResource_1.model.findOne({ _id: doc[aField.field] }).select(hiddenFields).exec(function (err, doc2) {
7471
if (err) {
7572
cbm(err);
7673
}
7774
else {
78-
that.getListFields(lookupResource, doc2, cbm);
75+
that.getListFields(lookupResource_1, doc2, cbm);
7976
}
8077
});
8178
}
@@ -244,7 +241,8 @@ DataForm.prototype.internalSearch = function (req, resourcesToSearch, includeRes
244241
}
245242
}
246243
}
247-
var that = this, results = [], moreCount = 0, searchCriteria, multiMatchPossible = searchFor.includes(' '), modifiedSearchStr = multiMatchPossible ? searchFor.split(' ').join('|') : searchFor;
244+
var that = this;
245+
var results = [], moreCount = 0, searchCriteria, multiMatchPossible = searchFor.includes(' '), modifiedSearchStr = multiMatchPossible ? searchFor.split(' ').join('|') : searchFor;
248246
// Removed the logic that preserved spaces when collection was specified because Louise asked me to.
249247
searchCriteria = { $regex: '^(' + modifiedSearchStr + ')', $options: 'i' };
250248
this.searchFunc(searches, function (item, cb) {
@@ -492,7 +490,8 @@ DataForm.prototype.report = function () {
492490
if (!(req.resource = this.getResource(req.params.resourceName))) {
493491
return next();
494492
}
495-
var reportSchema, self = this, urlParts = url.parse(req.url, true);
493+
var self = this;
494+
var reportSchema, urlParts = url.parse(req.url, true);
496495
if (req.params.reportName) {
497496
reportSchema = req.resource.model.schema.statics['report'](req.params.reportName, req);
498497
}
@@ -519,9 +518,11 @@ DataForm.prototype.report = function () {
519518
}
520519
}
521520
}
522-
reportSchema = { pipeline: [
521+
reportSchema = {
522+
pipeline: [
523523
{ $project: fields }
524-
], drilldown: req.params.resourceName + '/|_id|/edit' };
524+
], drilldown: req.params.resourceName + '/|_id|/edit'
525+
};
525526
}
526527
// Replace parameters in pipeline
527528
var schemaCopy = {};
@@ -624,10 +625,10 @@ DataForm.prototype.reportInternal = function (req, resource, schema, options, ca
624625
resource.model.aggregate(runPipeline, cb);
625626
}
626627
};
627-
var translations = []; // array of form {ref:'lookupname',translations:[{value:xx, display:' '}]}
628+
var translations_1 = []; // array of form {ref:'lookupname',translations:[{value:xx, display:' '}]}
628629
// if we need to do any column translations add the function to the tasks list
629630
if (schema.columnTranslations) {
630-
toDo.applyTranslations = ['runAggregation', function (cb, results) {
631+
toDo.applyTranslations = ['runAggregation', function (results, cb) {
631632
function doATranslate(column, theTranslation) {
632633
results['runAggregation'].forEach(function (resultRow) {
633634
var valToTranslate = resultRow[column.field];
@@ -643,7 +644,7 @@ DataForm.prototype.reportInternal = function (req, resource, schema, options, ca
643644
doATranslate(columnTranslation, columnTranslation);
644645
}
645646
if (columnTranslation.ref) {
646-
var theTranslation = _.find(translations, function (translation) {
647+
var theTranslation = _.find(translations_1, function (translation) {
647648
return (translation.ref === columnTranslation.ref);
648649
});
649650
if (theTranslation) {
@@ -673,19 +674,21 @@ DataForm.prototype.reportInternal = function (req, resource, schema, options, ca
673674
var lookup = ref;
674675
return function (cb) {
675676
var translateObject = { ref: lookup.resourceName, translations: [] };
676-
translations.push(translateObject);
677+
translations_1.push(translateObject);
677678
lookup.model.find({}, {}, { lean: true }, function (err, findResults) {
678679
if (err) {
679680
cb(err);
680681
}
681682
else {
682683
// TODO - this ref func can probably be done away with now that list fields can have ref
683-
var j = 0;
684-
async.whilst(function () { return j < findResults.length; }, function (cbres) {
685-
var theResult = findResults[j];
686-
translateObject.translations[j] = translateObject.translations[j] || {};
687-
var theTranslation = translateObject.translations[j];
688-
j++;
684+
var j_1 = 0;
685+
async.whilst(function () {
686+
return j_1 < findResults.length;
687+
}, function (cbres) {
688+
var theResult = findResults[j_1];
689+
translateObject.translations[j_1] = translateObject.translations[j_1] || {};
690+
var theTranslation = translateObject.translations[j_1];
691+
j_1++;
689692
self.getListFields(lookup, theResult, function (err, description) {
690693
if (err) {
691694
cbres(err);
@@ -718,7 +721,7 @@ DataForm.prototype.reportInternal = function (req, resource, schema, options, ca
718721
}
719722
}
720723
if (callFuncs) {
721-
toDo['callFunctions'] = ['runAggregation', function (cb, results) {
724+
toDo['callFunctions'] = ['runAggregation', function (results, cb) {
722725
async.each(results.runAggregation, function (row, cb) {
723726
for (var i = 0; i < schema.columnTranslations.length; i++) {
724727
var thisColumnTranslation = schema.columnTranslations[i];
@@ -821,10 +824,10 @@ DataForm.prototype.collectionGet = function () {
821824
if (aggregationParam) {
822825
this.hackVariablesInPipeline(aggregationParam);
823826
}
824-
var self = this;
827+
var self_1 = this;
825828
this.filteredFind(req.resource, req, aggregationParam, findParam, orderParam, limitParam, skipParam, function (err, docs) {
826829
if (err) {
827-
return self.renderError(err, null, req, res, next);
830+
return self_1.renderError(err, null, req, res, next);
828831
}
829832
else {
830833
res.send(docs);
@@ -845,7 +848,8 @@ DataForm.prototype.doFindFunc = function (req, resource, cb) {
845848
}
846849
};
847850
DataForm.prototype.filteredFind = function (resource, req, aggregationParam, findParam, sortOrder, limit, skip, callback) {
848-
var that = this, hiddenFields = this.generateHiddenFields(resource, false);
851+
var that = this;
852+
var hiddenFields = this.generateHiddenFields(resource, false);
849853
function doAggregation(cb) {
850854
if (aggregationParam) {
851855
resource.model.aggregate(aggregationParam, function (err, aggregationResults) {
@@ -1037,11 +1041,11 @@ DataForm.prototype.entityPut = function () {
10371041
req.doc[name] = (value === '') ? undefined : value;
10381042
});
10391043
if (req.resource.options.hide !== undefined) {
1040-
var hiddenFields = that.generateHiddenFields(req.resource, true);
1041-
hiddenFields._id = false;
1042-
req.resource.model.findById(req.doc._id, hiddenFields, { lean: true }, function (err, data) {
1044+
var hiddenFields_1 = that.generateHiddenFields(req.resource, true);
1045+
hiddenFields_1._id = false;
1046+
req.resource.model.findById(req.doc._id, hiddenFields_1, { lean: true }, function (err, data) {
10431047
that.replaceHiddenFields(req.doc, data);
1044-
that.saveAndRespond(req, res, hiddenFields);
1048+
that.saveAndRespond(req, res, hiddenFields_1);
10451049
});
10461050
}
10471051
else {

0 commit comments

Comments
 (0)