diff --git a/app/controllers/devices.js b/app/controllers/devices.js index 9ad8ef4..d059c44 100644 --- a/app/controllers/devices.js +++ b/app/controllers/devices.js @@ -32,7 +32,6 @@ exports.get = function(req, res, next) { Device.findById(id) .populate('deviceType', 'category make model checkList') - .populate('deviceType.checkList', 'name fields') .populate('client', 'name identifier') .exec(returnResult(res)); }; diff --git a/app/controllers/testRuns.js b/app/controllers/testRuns.js index 9429e99..b441520 100644 --- a/app/controllers/testRuns.js +++ b/app/controllers/testRuns.js @@ -115,6 +115,15 @@ module.exports = function(config) { } testRun.save(returnResult(res)); + + Device.findById(testRun.device, function(err, device) { + if (err) { + log.error("Failed to fetch device for testRun: %s", err); + } else { + device.lastTestRun = testRun; + device.save(); + } + }); }, update: function(req, res, next) { diff --git a/app/controllers/workorders.js b/app/controllers/workorders.js index 878704b..c31373c 100644 --- a/app/controllers/workorders.js +++ b/app/controllers/workorders.js @@ -108,12 +108,12 @@ module.exports = function(config, calendar) { }); }, function(callback) { - Device.find({client: req.body.client, deleted: false }) - .populate({path: 'deviceType'}) - .exec(function(err, results) { - devices = results; - callback(err); - }); + Device.find({'_id': { $in: req.body.devices }}) + .populate({path: 'deviceType'}) + .exec(function(err, results) { + devices = results; + callback(err); + }); }, function(callback) { User.find({ diff --git a/app/model/device.js b/app/model/device.js index 65aa8d7..e3ec1c7 100644 --- a/app/model/device.js +++ b/app/model/device.js @@ -13,6 +13,7 @@ var deviceSchema = new Schema({ location: String, frequencyType: String, frequencySchedule: [], + lastTestRun: {}, deleted: { type: Boolean, default: false } }); diff --git a/public/js/controllers/testRuns.js b/public/js/controllers/testRuns.js index 12cba84..e2e0dce 100644 --- a/public/js/controllers/testRuns.js +++ b/public/js/controllers/testRuns.js @@ -40,6 +40,8 @@ function testRunAddController($scope, Devices, CheckLists, TestRuns, $location, field.result = (field.value == 'true'); } else if (field.type == 'range') { field.result = field.value >= field.min && field.value <= field.max; + } else if (field.type == 'text') { + field.result = true; } $scope.model.result &= field.result; @@ -55,4 +57,4 @@ function testRunAddController($scope, Devices, CheckLists, TestRuns, $location, function testRunViewController($scope, Devices, CheckLists, TestRuns, $location, $filter, $routeParams) { $scope.model = TestRuns.get($routeParams); -} \ No newline at end of file +} diff --git a/public/partials/checkLists/add.html b/public/partials/checkLists/add.html index 0d97f78..d2ad07a 100644 --- a/public/partials/checkLists/add.html +++ b/public/partials/checkLists/add.html @@ -38,6 +38,7 @@ diff --git a/public/partials/clients/edit.html b/public/partials/clients/edit.html index 3e5896f..101774a 100644 --- a/public/partials/clients/edit.html +++ b/public/partials/clients/edit.html @@ -305,7 +305,8 @@