This commit is contained in:
Dobie Wollert
2015-12-16 09:12:35 -08:00
parent f9c9672818
commit f94ca33b9e
805 changed files with 67409 additions and 24609 deletions

View File

@ -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);
});
});
}
}