mirror of
https://github.com/atlanticbiomedical/biomedjs.git
synced 2025-07-02 00:47:26 -04:00
Changes
This commit is contained in:
@ -1,12 +1,12 @@
|
||||
angular.module('biomed')
|
||||
.controller("CheckListIndexCtrl", checkListsIndexController)
|
||||
.controller("CheckListAddCtrl", checkListsControllerFactory(false))
|
||||
.controller("CheckListEditCtrl", checkListsControllerFactory(true))
|
||||
.controller("CheckListIndexCtrl", checkListsIndexController)
|
||||
.controller("CheckListAddCtrl", checkListsControllerFactory(false))
|
||||
.controller("CheckListEditCtrl", checkListsControllerFactory(true))
|
||||
|
||||
function checkListsIndexController($scope, $filter, $routeParams, CheckLists, LocationBinder) {
|
||||
$scope.loading = true;
|
||||
|
||||
var allData = CheckLists.index(function() {
|
||||
var allData = CheckLists.index(function () {
|
||||
$scope.loading = false;
|
||||
$scope.filter();
|
||||
});
|
||||
@ -18,20 +18,20 @@ function checkListsIndexController($scope, $filter, $routeParams, CheckLists, Lo
|
||||
|
||||
$scope.canLoad = true;
|
||||
|
||||
$scope.$watch('query', function() {
|
||||
$scope.$watch('query', function () {
|
||||
$scope.filter();
|
||||
});
|
||||
|
||||
LocationBinder($scope, ['query']);
|
||||
|
||||
$scope.filter = function() {
|
||||
$scope.filter = function () {
|
||||
filteredData = $filter('orderBy')($filter('filter')(allData, $scope.query), $scope.sort.column, $scope.sort.descending);
|
||||
index = initialPageSize;
|
||||
$scope.canLoad = true;
|
||||
$scope.checkLists = filteredData.slice(0, initialPageSize);
|
||||
};
|
||||
|
||||
$scope.addItems = function() {
|
||||
$scope.addItems = function () {
|
||||
$scope.checkLists = $scope.checkLists.concat(filteredData.slice(index, index + pageSize));
|
||||
index += pageSize;
|
||||
$scope.canLoad = index < filteredData.length;
|
||||
@ -42,11 +42,11 @@ function checkListsIndexController($scope, $filter, $routeParams, CheckLists, Lo
|
||||
descending: false
|
||||
};
|
||||
|
||||
$scope.selectedCls = function(column) {
|
||||
$scope.selectedCls = function (column) {
|
||||
return column == $scope.sort.column && 'sort-' + $scope.sort.descending;
|
||||
}
|
||||
|
||||
$scope.changeSorting = function(column) {
|
||||
$scope.changeSorting = function (column) {
|
||||
var sort = $scope.sort;
|
||||
if (sort.column == column) {
|
||||
sort.descending = !sort.descending;
|
||||
@ -60,10 +60,10 @@ function checkListsIndexController($scope, $filter, $routeParams, CheckLists, Lo
|
||||
}
|
||||
|
||||
function checkListsControllerFactory(isEdit) {
|
||||
return function($scope, CheckLists, $location, $filter, $routeParams) {
|
||||
return function ($scope, CheckLists, $location, $filter, $routeParams) {
|
||||
|
||||
function addField() {
|
||||
$scope.model.fields.push({ type: 'boolean' })
|
||||
$scope.model.fields.push({type: 'boolean'})
|
||||
}
|
||||
|
||||
function removeField(index) {
|
||||
@ -74,22 +74,22 @@ function checkListsControllerFactory(isEdit) {
|
||||
}
|
||||
|
||||
function moveUpField(index) {
|
||||
$scope.model.fields.splice(index - 1, 0, $scope.model.fields.splice(index, 1)[0]);
|
||||
$scope.model.fields.splice(index - 1, 0, $scope.model.fields.splice(index, 1)[0]);
|
||||
}
|
||||
|
||||
function moveDownField(index) {
|
||||
$scope.model.fields.splice(index + 1, 0, $scope.model.fields.splice(index, 1)[0]);
|
||||
}
|
||||
function moveDownField(index) {
|
||||
$scope.model.fields.splice(index + 1, 0, $scope.model.fields.splice(index, 1)[0]);
|
||||
}
|
||||
|
||||
function save() {
|
||||
if (isEdit) {
|
||||
CheckLists.update({id: $scope.model._id}, $scope.model, function() {
|
||||
CheckLists.update({id: $scope.model._id}, $scope.model, function () {
|
||||
$location.path("/checkLists/");
|
||||
});
|
||||
} else {
|
||||
CheckLists.create($scope.model, function(result) {
|
||||
CheckLists.create($scope.model, function (result) {
|
||||
$location.path("/checkLists/" + result._id);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,269 +1,269 @@
|
||||
angular.module('biomed')
|
||||
|
||||
.controller("DeviceTypeIndexCtrl", function($scope, $filter, $routeParams, DeviceTypes, LocationBinder) {
|
||||
$scope.loading = true;
|
||||
.controller("DeviceTypeIndexCtrl", function ($scope, $filter, $routeParams, DeviceTypes, LocationBinder) {
|
||||
$scope.loading = true;
|
||||
|
||||
var allData = DeviceTypes.index(function() {
|
||||
$scope.loading = false;
|
||||
$scope.filter();
|
||||
});
|
||||
|
||||
var filteredData = [];
|
||||
var index = 0;
|
||||
var initialPageSize = 100;
|
||||
var pageSize = 5;
|
||||
|
||||
$scope.canLoad = true;
|
||||
|
||||
$scope.$watch('query', function() {
|
||||
$scope.filter();
|
||||
});
|
||||
|
||||
LocationBinder($scope, ['query']);
|
||||
|
||||
$scope.filter = function() {
|
||||
filteredData = $filter('orderBy')($filter('filter')(allData, $scope.query), $scope.sort.column, $scope.sort.descending);
|
||||
index = initialPageSize;
|
||||
$scope.canLoad = true;
|
||||
$scope.devices = filteredData.slice(0, initialPageSize);
|
||||
};
|
||||
|
||||
$scope.addItems = function() {
|
||||
$scope.devices = $scope.devices.concat(filteredData.slice(index, index + pageSize));
|
||||
index += pageSize;
|
||||
$scope.canLoad = index < filteredData.length;
|
||||
}
|
||||
|
||||
$scope.sort = {
|
||||
column: 'category',
|
||||
descending: false
|
||||
};
|
||||
|
||||
$scope.selectedCls = function(column) {
|
||||
return column == $scope.sort.column && 'sort-' + $scope.sort.descending;
|
||||
}
|
||||
|
||||
$scope.changeSorting = function(column) {
|
||||
var sort = $scope.sort;
|
||||
if (sort.column == column) {
|
||||
sort.descending = !sort.descending;
|
||||
} else {
|
||||
sort.column = column;
|
||||
sort.descending = false;
|
||||
}
|
||||
|
||||
$scope.filter();
|
||||
};
|
||||
})
|
||||
|
||||
.controller("DeviceTypeAddCtrl", function($scope, DeviceTypes, CheckLists, $location, $filter) {
|
||||
$scope.model = {};
|
||||
|
||||
$scope.categories = DeviceTypes.categories();
|
||||
$scope.deviceMakes = DeviceTypes.makes();
|
||||
|
||||
$scope.checkLists = CheckLists.index();
|
||||
|
||||
$scope.categoryOpts = {
|
||||
containerCssClass: 'input-xxlarge',
|
||||
placeholder: 'Choose a Device Type',
|
||||
query: function(query) {
|
||||
var data = $filter('filter')($scope.categories, query.term);
|
||||
var results = [];
|
||||
data.forEach(function(item) {
|
||||
results.push({id: item, text: item});
|
||||
});
|
||||
query.callback({results: results });
|
||||
},
|
||||
createSearchChoice: function(term) {
|
||||
return { id: term, text: term };
|
||||
}
|
||||
};
|
||||
|
||||
$scope.makeOpts = {
|
||||
containerCssClass: 'input-xxlarge',
|
||||
placeholder: 'Choose a Device Make',
|
||||
query: function(query) {
|
||||
var data = $filter('filter')($scope.deviceMakes, query.term);
|
||||
var results = [];
|
||||
data.forEach(function(item) {
|
||||
results.push({id: item, text: item});
|
||||
});
|
||||
query.callback({results: results });
|
||||
},
|
||||
createSearchChoice: function(term) {
|
||||
return { id: term, text: term };
|
||||
}
|
||||
};
|
||||
|
||||
var images = {};
|
||||
|
||||
$scope.imageOpts = {
|
||||
options: {
|
||||
url: '/api/deviceTypes/images',
|
||||
addRemoveLinks: true
|
||||
},
|
||||
eventHandlers: {
|
||||
success: function(file, response) {
|
||||
file.filename = response.filename;
|
||||
|
||||
if (images[file.filename]) {
|
||||
images[file.filename]++;
|
||||
this.removeFile(file);
|
||||
} else {
|
||||
images[file.filename] = 1;
|
||||
}
|
||||
},
|
||||
removedfile: function(file) {
|
||||
images[file.filename]--;
|
||||
|
||||
if (images[file.filename] <= 0) {
|
||||
delete images[file.filename];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$scope.$watch('categoryPicker', function() {
|
||||
if ($scope.categoryPicker) {
|
||||
$scope.model.category = $scope.categoryPicker.id;
|
||||
} else {
|
||||
$scope.model.category = null;
|
||||
}
|
||||
});
|
||||
|
||||
$scope.$watch('makePicker', function() {
|
||||
if ($scope.makePicker) {
|
||||
$scope.model.make = $scope.makePicker.id;
|
||||
} else {
|
||||
$scope.model.make = null;
|
||||
}
|
||||
});
|
||||
|
||||
$scope.save = function() {
|
||||
$scope.model.images = Object.keys(images);
|
||||
|
||||
DeviceTypes.create($scope.model, function(result) {
|
||||
$location.path("/deviceTypes/");
|
||||
});
|
||||
};
|
||||
})
|
||||
|
||||
.controller("DeviceTypeEditCtrl", function($scope, DeviceTypes, Devices, CheckLists, $location, $filter, $routeParams) {
|
||||
var images = {};
|
||||
|
||||
$scope.checkLists = CheckLists.index(function() {
|
||||
$scope.model = DeviceTypes.get($routeParams, function() {
|
||||
var allData = DeviceTypes.index(function () {
|
||||
$scope.loading = false;
|
||||
$scope.filter();
|
||||
});
|
||||
|
||||
$scope.existingImages = $scope.model.images;
|
||||
if ($scope.model.images) {
|
||||
for (var i = 0; i < $scope.model.images.length; i++) {
|
||||
images[$scope.model.images[i]] = 1;
|
||||
}
|
||||
var filteredData = [];
|
||||
var index = 0;
|
||||
var initialPageSize = 100;
|
||||
var pageSize = 5;
|
||||
|
||||
$scope.canLoad = true;
|
||||
|
||||
$scope.$watch('query', function () {
|
||||
$scope.filter();
|
||||
});
|
||||
|
||||
LocationBinder($scope, ['query']);
|
||||
|
||||
$scope.filter = function () {
|
||||
filteredData = $filter('orderBy')($filter('filter')(allData, $scope.query), $scope.sort.column, $scope.sort.descending);
|
||||
index = initialPageSize;
|
||||
$scope.canLoad = true;
|
||||
$scope.devices = filteredData.slice(0, initialPageSize);
|
||||
};
|
||||
|
||||
$scope.addItems = function () {
|
||||
$scope.devices = $scope.devices.concat(filteredData.slice(index, index + pageSize));
|
||||
index += pageSize;
|
||||
$scope.canLoad = index < filteredData.length;
|
||||
}
|
||||
|
||||
$scope.sort = {
|
||||
column: 'category',
|
||||
descending: false
|
||||
};
|
||||
|
||||
$scope.selectedCls = function (column) {
|
||||
return column == $scope.sort.column && 'sort-' + $scope.sort.descending;
|
||||
}
|
||||
|
||||
$scope.changeSorting = function (column) {
|
||||
var sort = $scope.sort;
|
||||
if (sort.column == column) {
|
||||
sort.descending = !sort.descending;
|
||||
} else {
|
||||
sort.column = column;
|
||||
sort.descending = false;
|
||||
}
|
||||
|
||||
$scope.categoryPicker = {id: $scope.model.category, text: $scope.model.category};
|
||||
$scope.makePicker = {id: $scope.model.make, text: $scope.model.make};
|
||||
});
|
||||
});
|
||||
$scope.filter();
|
||||
};
|
||||
})
|
||||
|
||||
console.log($routeParams);
|
||||
.controller("DeviceTypeAddCtrl", function ($scope, DeviceTypes, CheckLists, $location, $filter) {
|
||||
$scope.model = {};
|
||||
|
||||
$scope.devices = Devices.index({ deviceType: $routeParams.id });
|
||||
$scope.categories = DeviceTypes.categories();
|
||||
$scope.deviceMakes = DeviceTypes.makes();
|
||||
|
||||
$scope.categories = DeviceTypes.categories();
|
||||
$scope.deviceMakes = DeviceTypes.makes();
|
||||
$scope.checkLists = CheckLists.index();
|
||||
|
||||
|
||||
$scope.categoryOpts = {
|
||||
containerCssClass: 'input-xxlarge',
|
||||
placeholder: 'Choose a Device Type',
|
||||
query: function(query) {
|
||||
var data = $filter('filter')($scope.categories, query.term);
|
||||
var results = [];
|
||||
data.forEach(function(item) {
|
||||
results.push({id: item, text: item});
|
||||
});
|
||||
query.callback({results: results });
|
||||
},
|
||||
createSearchChoice: function(term) {
|
||||
return { id: term, text: term };
|
||||
}
|
||||
};
|
||||
|
||||
$scope.makeOpts = {
|
||||
containerCssClass: 'input-xxlarge',
|
||||
placeholder: 'Choose a Device Make',
|
||||
query: function(query) {
|
||||
var data = $filter('filter')($scope.deviceMakes, query.term);
|
||||
var results = [];
|
||||
data.forEach(function(item) {
|
||||
results.push({id: item, text: item});
|
||||
});
|
||||
query.callback({results: results });
|
||||
},
|
||||
createSearchChoice: function(term) {
|
||||
return { id: term, text: term };
|
||||
}
|
||||
};
|
||||
|
||||
$scope.imageOpts = {
|
||||
options: {
|
||||
url: '/api/deviceTypes/images',
|
||||
addRemoveLinks: true
|
||||
},
|
||||
eventHandlers: {
|
||||
success: function(file, response) {
|
||||
file.filename = response.filename;
|
||||
|
||||
if (images[file.filename]) {
|
||||
images[file.filename]++;
|
||||
this.removeFile(file);
|
||||
} else {
|
||||
images[file.filename] = 1;
|
||||
}
|
||||
$scope.categoryOpts = {
|
||||
containerCssClass: 'input-xxlarge',
|
||||
placeholder: 'Choose a Device Type',
|
||||
query: function (query) {
|
||||
var data = $filter('filter')($scope.categories, query.term);
|
||||
var results = [];
|
||||
data.forEach(function (item) {
|
||||
results.push({id: item, text: item});
|
||||
});
|
||||
query.callback({results: results});
|
||||
},
|
||||
removedfile: function(file) {
|
||||
images[file.filename]--;
|
||||
createSearchChoice: function (term) {
|
||||
return {id: term, text: term};
|
||||
}
|
||||
};
|
||||
|
||||
if (images[file.filename] <= 0) {
|
||||
delete images[file.filename];
|
||||
$scope.makeOpts = {
|
||||
containerCssClass: 'input-xxlarge',
|
||||
placeholder: 'Choose a Device Make',
|
||||
query: function (query) {
|
||||
var data = $filter('filter')($scope.deviceMakes, query.term);
|
||||
var results = [];
|
||||
data.forEach(function (item) {
|
||||
results.push({id: item, text: item});
|
||||
});
|
||||
query.callback({results: results});
|
||||
},
|
||||
createSearchChoice: function (term) {
|
||||
return {id: term, text: term};
|
||||
}
|
||||
};
|
||||
|
||||
var images = {};
|
||||
|
||||
$scope.imageOpts = {
|
||||
options: {
|
||||
url: '/api/deviceTypes/images',
|
||||
addRemoveLinks: true
|
||||
},
|
||||
eventHandlers: {
|
||||
success: function (file, response) {
|
||||
file.filename = response.filename;
|
||||
|
||||
if (images[file.filename]) {
|
||||
images[file.filename]++;
|
||||
this.removeFile(file);
|
||||
} else {
|
||||
images[file.filename] = 1;
|
||||
}
|
||||
},
|
||||
removedfile: function (file) {
|
||||
images[file.filename]--;
|
||||
|
||||
if (images[file.filename] <= 0) {
|
||||
delete images[file.filename];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
$scope.$watch('categoryPicker', function() {
|
||||
if ($scope.categoryPicker) {
|
||||
$scope.model.category = $scope.categoryPicker.id;
|
||||
} else {
|
||||
$scope.model.category = null;
|
||||
}
|
||||
});
|
||||
|
||||
$scope.$watch('makePicker', function() {
|
||||
if ($scope.makePicker) {
|
||||
$scope.model.make = $scope.makePicker.id;
|
||||
} else {
|
||||
$scope.model.make = null;
|
||||
}
|
||||
});
|
||||
|
||||
$scope.save = function() {
|
||||
$scope.model.images = Object.keys(images);
|
||||
|
||||
DeviceTypes.update({id: $scope.model._id}, $scope.model, function(result) {
|
||||
$location.path("/deviceTypes/");
|
||||
$scope.$watch('categoryPicker', function () {
|
||||
if ($scope.categoryPicker) {
|
||||
$scope.model.category = $scope.categoryPicker.id;
|
||||
} else {
|
||||
$scope.model.category = null;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.delete = function() {
|
||||
$scope.model.images = Object.keys(images);
|
||||
$scope.model.deleted = true;
|
||||
|
||||
DeviceTypes.update({id: $scope.model._id}, $scope.model, function(result) {
|
||||
$location.path("/deviceTypes/");
|
||||
$scope.$watch('makePicker', function () {
|
||||
if ($scope.makePicker) {
|
||||
$scope.model.make = $scope.makePicker.id;
|
||||
} else {
|
||||
$scope.model.make = null;
|
||||
}
|
||||
});
|
||||
};
|
||||
})
|
||||
|
||||
$scope.save = function () {
|
||||
$scope.model.images = Object.keys(images);
|
||||
|
||||
DeviceTypes.create($scope.model, function (result) {
|
||||
$location.path("/deviceTypes/");
|
||||
});
|
||||
};
|
||||
})
|
||||
|
||||
.controller("DeviceTypeEditCtrl", function ($scope, DeviceTypes, Devices, CheckLists, $location, $filter, $routeParams) {
|
||||
var images = {};
|
||||
|
||||
$scope.checkLists = CheckLists.index(function () {
|
||||
$scope.model = DeviceTypes.get($routeParams, function () {
|
||||
$scope.loading = false;
|
||||
|
||||
$scope.existingImages = $scope.model.images;
|
||||
if ($scope.model.images) {
|
||||
for (var i = 0; i < $scope.model.images.length; i++) {
|
||||
images[$scope.model.images[i]] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$scope.categoryPicker = {id: $scope.model.category, text: $scope.model.category};
|
||||
$scope.makePicker = {id: $scope.model.make, text: $scope.model.make};
|
||||
});
|
||||
});
|
||||
|
||||
console.log($routeParams);
|
||||
|
||||
$scope.devices = Devices.index({deviceType: $routeParams.id});
|
||||
|
||||
$scope.categories = DeviceTypes.categories();
|
||||
$scope.deviceMakes = DeviceTypes.makes();
|
||||
|
||||
|
||||
$scope.categoryOpts = {
|
||||
containerCssClass: 'input-xxlarge',
|
||||
placeholder: 'Choose a Device Type',
|
||||
query: function (query) {
|
||||
var data = $filter('filter')($scope.categories, query.term);
|
||||
var results = [];
|
||||
data.forEach(function (item) {
|
||||
results.push({id: item, text: item});
|
||||
});
|
||||
query.callback({results: results});
|
||||
},
|
||||
createSearchChoice: function (term) {
|
||||
return {id: term, text: term};
|
||||
}
|
||||
};
|
||||
|
||||
$scope.makeOpts = {
|
||||
containerCssClass: 'input-xxlarge',
|
||||
placeholder: 'Choose a Device Make',
|
||||
query: function (query) {
|
||||
var data = $filter('filter')($scope.deviceMakes, query.term);
|
||||
var results = [];
|
||||
data.forEach(function (item) {
|
||||
results.push({id: item, text: item});
|
||||
});
|
||||
query.callback({results: results});
|
||||
},
|
||||
createSearchChoice: function (term) {
|
||||
return {id: term, text: term};
|
||||
}
|
||||
};
|
||||
|
||||
$scope.imageOpts = {
|
||||
options: {
|
||||
url: '/api/deviceTypes/images',
|
||||
addRemoveLinks: true
|
||||
},
|
||||
eventHandlers: {
|
||||
success: function (file, response) {
|
||||
file.filename = response.filename;
|
||||
|
||||
if (images[file.filename]) {
|
||||
images[file.filename]++;
|
||||
this.removeFile(file);
|
||||
} else {
|
||||
images[file.filename] = 1;
|
||||
}
|
||||
},
|
||||
removedfile: function (file) {
|
||||
images[file.filename]--;
|
||||
|
||||
if (images[file.filename] <= 0) {
|
||||
delete images[file.filename];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$scope.$watch('categoryPicker', function () {
|
||||
if ($scope.categoryPicker) {
|
||||
$scope.model.category = $scope.categoryPicker.id;
|
||||
} else {
|
||||
$scope.model.category = null;
|
||||
}
|
||||
});
|
||||
|
||||
$scope.$watch('makePicker', function () {
|
||||
if ($scope.makePicker) {
|
||||
$scope.model.make = $scope.makePicker.id;
|
||||
} else {
|
||||
$scope.model.make = null;
|
||||
}
|
||||
});
|
||||
|
||||
$scope.save = function () {
|
||||
$scope.model.images = Object.keys(images);
|
||||
|
||||
DeviceTypes.update({id: $scope.model._id}, $scope.model, function (result) {
|
||||
$location.path("/deviceTypes/");
|
||||
});
|
||||
};
|
||||
|
||||
$scope.delete = function () {
|
||||
$scope.model.images = Object.keys(images);
|
||||
$scope.model.deleted = true;
|
||||
|
||||
DeviceTypes.update({id: $scope.model._id}, $scope.model, function (result) {
|
||||
$location.path("/deviceTypes/");
|
||||
});
|
||||
};
|
||||
})
|
||||
|
@ -1,14 +1,14 @@
|
||||
angular.module('biomed')
|
||||
.controller("DeviceAddCtrl", devicesControllerFactory(false))
|
||||
.controller("DeviceEditCtrl", devicesControllerFactory(true))
|
||||
.controller("DeviceAddCtrl", devicesControllerFactory(false))
|
||||
.controller("DeviceEditCtrl", devicesControllerFactory(true))
|
||||
|
||||
|
||||
function devicesControllerFactory(isEdit) {
|
||||
return function($scope, Devices, DeviceTypes, $location, $filter, $routeParams) {
|
||||
return function ($scope, Devices, DeviceTypes, $location, $filter, $routeParams) {
|
||||
function buildDeviceTypeFilterQuery(ignore) {
|
||||
var query = {};
|
||||
|
||||
_.each(['category', 'make', 'model'], function(key) {
|
||||
_.each(['category', 'make', 'model'], function (key) {
|
||||
if (key == ignore)
|
||||
return;
|
||||
|
||||
@ -25,23 +25,23 @@ function devicesControllerFactory(isEdit) {
|
||||
|
||||
var data = {};
|
||||
|
||||
_.each(['category', 'make', 'model'], function(key) {
|
||||
_.each(['category', 'make', 'model'], function (key) {
|
||||
var query = buildDeviceTypeFilterQuery(key);
|
||||
var filteredResults = $filter('filter')(deviceTypesList, query);
|
||||
|
||||
data[key] = [];
|
||||
|
||||
_.each(filteredResults, function(entry) {
|
||||
_.each(filteredResults, function (entry) {
|
||||
data[key].push(entry[key]);
|
||||
});
|
||||
});
|
||||
|
||||
_.each(['category', 'make', 'model'], function(key) {
|
||||
_.each(['category', 'make', 'model'], function (key) {
|
||||
$scope.deviceTypes[key].data = _.uniq(data[key]);
|
||||
|
||||
if (data[key].length == 1) {
|
||||
var value = data[key][0];
|
||||
$scope.deviceTypes[key].picker = { id: value, text: value };
|
||||
$scope.deviceTypes[key].picker = {id: value, text: value};
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -53,33 +53,33 @@ function devicesControllerFactory(isEdit) {
|
||||
$scope.deviceTypes[key].opts = {
|
||||
containerCssClass: 'input-xxlarge',
|
||||
placeholder: 'Choose a ' + label,
|
||||
query: function(query) {
|
||||
query: function (query) {
|
||||
var data = $filter('filter')($scope.deviceTypes[key].data, query.term);
|
||||
query.callback({
|
||||
results: _.map(data, function(entry) {
|
||||
return { id: entry, text: entry }
|
||||
results: _.map(data, function (entry) {
|
||||
return {id: entry, text: entry}
|
||||
})
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$scope.$watch('deviceTypes.' + key + '.picker',function() {
|
||||
$scope.$watch('deviceTypes.' + key + '.picker', function () {
|
||||
filterDeviceTypeSelectors();
|
||||
updateDeviceTypeSelection();
|
||||
}, true);
|
||||
}
|
||||
|
||||
function clearDeviceTypePickers() {
|
||||
_.each(['category', 'make', 'model'], function(key) {
|
||||
_.each(['category', 'make', 'model'], function (key) {
|
||||
$scope.deviceTypes[key].picker = null;
|
||||
});
|
||||
}
|
||||
|
||||
function updateDeviceTypeSelection() {
|
||||
var query = buildDeviceTypeFilterQuery();
|
||||
var results = $filter('filter')(deviceTypesList, query);
|
||||
var query = buildDeviceTypeFilterQuery();
|
||||
var results = $filter('filter')(deviceTypesList, query);
|
||||
|
||||
$scope.model.deviceType = (results.length == 1) ? results[0]._id : null;
|
||||
$scope.model.deviceType = (results.length == 1) ? results[0]._id : null;
|
||||
}
|
||||
|
||||
function generateRandomIdentifier() {
|
||||
@ -93,27 +93,27 @@ function devicesControllerFactory(isEdit) {
|
||||
}
|
||||
|
||||
function create() {
|
||||
Devices.create($scope.model, function(result) {
|
||||
Devices.create($scope.model, function (result) {
|
||||
$location.path("/clients/" + result.client);
|
||||
});
|
||||
}
|
||||
|
||||
function update() {
|
||||
Devices.update({id: $scope.model._id}, $scope.model, function() {
|
||||
Devices.update({id: $scope.model._id}, $scope.model, function () {
|
||||
$location.path("/clients/" + $scope.model.client);
|
||||
});
|
||||
}
|
||||
|
||||
function destroy() {
|
||||
$scope.model.deleted = true;
|
||||
Devices.update({id: $scope.model._id}, $scope.model, function() {
|
||||
$location.path("/clients/" + $scope.model.client);
|
||||
Devices.update({id: $scope.model._id}, $scope.model, function () {
|
||||
$location.path("/clients/" + $scope.model.client);
|
||||
});
|
||||
}
|
||||
|
||||
function restore() {
|
||||
$scope.model.deleted = false;
|
||||
Devices.update({id: $scope.model._id}, $scope.model, function() {
|
||||
Devices.update({id: $scope.model._id}, $scope.model, function () {
|
||||
$location.path("/clients/" + $scope.model.client);
|
||||
});
|
||||
}
|
||||
@ -147,19 +147,19 @@ function devicesControllerFactory(isEdit) {
|
||||
console.log((isEdit ? "Edit" : "Create") + " Mode");
|
||||
|
||||
if (isEdit) {
|
||||
$scope.model = Devices.get($routeParams, function() {
|
||||
$scope.model = Devices.get($routeParams, function () {
|
||||
$scope.loading = false;
|
||||
|
||||
var deviceType = $scope.model.deviceType;
|
||||
|
||||
_.each(['category', 'make', 'model'], function(key) {
|
||||
$scope.deviceTypes[key].picker = { id: deviceType[key], text: deviceType[key] };
|
||||
_.each(['category', 'make', 'model'], function (key) {
|
||||
$scope.deviceTypes[key].picker = {id: deviceType[key], text: deviceType[key]};
|
||||
});
|
||||
|
||||
$scope.model.client = $scope.model.client._id;
|
||||
$scope.model.deviceType = $scope.model.deviceType._id;
|
||||
|
||||
$scope.testRuns = Devices.testRuns($routeParams, function() {
|
||||
$scope.testRuns = Devices.testRuns($routeParams, function () {
|
||||
console.log($scope.testRuns);
|
||||
});
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
angular.module('biomed')
|
||||
.controller("TestRunAddCtrl", testRunAddController)
|
||||
.controller("TestRunViewCtrl", testRunViewController)
|
||||
.controller("TestRunAddCtrl", testRunAddController)
|
||||
.controller("TestRunViewCtrl", testRunViewController)
|
||||
|
||||
|
||||
function testRunAddController($scope, Devices, CheckLists, TestRuns, $location, $filter, $routeParams) {
|
||||
@ -8,10 +8,10 @@ function testRunAddController($scope, Devices, CheckLists, TestRuns, $location,
|
||||
|
||||
console.log(search);
|
||||
|
||||
$scope.device = Devices.get({id: search.deviceId}, function() {
|
||||
$scope.device = Devices.get({id: search.deviceId}, function () {
|
||||
console.log($scope.device);
|
||||
|
||||
$scope.checkList = CheckLists.get({id: $scope.device.deviceType.checkList}, function() {
|
||||
$scope.checkList = CheckLists.get({id: $scope.device.deviceType.checkList}, function () {
|
||||
$scope.loading = false;
|
||||
|
||||
$scope.model = {
|
||||
@ -20,7 +20,7 @@ function testRunAddController($scope, Devices, CheckLists, TestRuns, $location,
|
||||
fields: []
|
||||
};
|
||||
|
||||
_.each($scope.checkList.fields, function(field) {
|
||||
_.each($scope.checkList.fields, function (field) {
|
||||
|
||||
if (field.type == 'boolean') {
|
||||
field.value = 'false'
|
||||
@ -32,10 +32,10 @@ function testRunAddController($scope, Devices, CheckLists, TestRuns, $location,
|
||||
})
|
||||
});
|
||||
|
||||
$scope.$watch('model', function() {
|
||||
$scope.$watch('model', function () {
|
||||
$scope.model.result = true;
|
||||
|
||||
_.each($scope.model.fields, function(field) {
|
||||
_.each($scope.model.fields, function (field) {
|
||||
if (field.type == 'boolean') {
|
||||
field.result = (field.value == 'true');
|
||||
} else if (field.type == 'range') {
|
||||
@ -48,8 +48,8 @@ function testRunAddController($scope, Devices, CheckLists, TestRuns, $location,
|
||||
})
|
||||
}, true);
|
||||
|
||||
$scope.save = function() {
|
||||
TestRuns.create($scope.model, function(result) {
|
||||
$scope.save = function () {
|
||||
TestRuns.create($scope.model, function (result) {
|
||||
$location.path("/testRuns/" + result._id);
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user