Latest work

This commit is contained in:
Dobie Wollert
2015-04-19 21:15:06 -04:00
parent 8cfff70ce0
commit 397b828024
12 changed files with 200 additions and 70 deletions

View File

@ -66,7 +66,15 @@ biomed.SchedulePmsCtrl = function($scope, Clients) {
$scope.month = moment().month();
$scope.frequencies = [];
var allData = Clients.frequencies(function() {
if (allData) {
angular.forEach(allData[0].frequencies, function(value, key) {
$scope.frequencies.push(key);
});
}
filter();
$scope.loading = false;
});
@ -80,12 +88,9 @@ biomed.SchedulePmsCtrl = function($scope, Clients) {
angular.forEach(client.frequencies, function(value, key) {
if (value[$scope.month]) {
reason.push(key);
// $scope.pms.push({
// reason: key,
// client: client
// });
if (!$scope.frequency || $scope.frequency == key) {
reason.push(key);
}
}
});
@ -120,6 +125,7 @@ biomed.SchedulePmsCtrl = function($scope, Clients) {
};
$scope.$watch('month', filter);
$scope.$watch('frequency', filter);
};
biomed.UsersIndexCtrl = function($scope, $filter, $routeParams, $location, Users, LocationBinder) {
@ -676,7 +682,7 @@ biomed.AccountingIndexCtrl = function($scope, $filter, $routeParams, Workorders,
var defaultEnd = moment().toDate();
var defaultStart = moment(defaultEnd).subtract('days', 7).toDate();
LocationBinder($scope, ['query', 'start', 'end'], {
LocationBinder($scope, ['query', 'status', 'start', 'end'], {
start: defaultStart,
end: defaultEnd
});
@ -693,6 +699,8 @@ biomed.AccountingIndexCtrl = function($scope, $filter, $routeParams, Workorders,
$scope.$watch('query', filter);
$scope.$watch('status', filter);
$scope.$watch('start', fetchData);
$scope.$watch('end', fetchData);
@ -709,10 +717,14 @@ biomed.AccountingIndexCtrl = function($scope, $filter, $routeParams, Workorders,
}
function filter() {
filteredData = $filter('filter')(data, $scope.query);
filteredData = $filter('filter')(data, {
$: $scope.query,
status: $scope.status
});
index = initialPageSize;
$scope.canLoad = true;
$scope.workorders = filteredData.slice(0, initialPageSize);
$scope.total = filteredData.length;
};
$scope.selectedCls = function(column) {
@ -729,6 +741,11 @@ biomed.AccountingIndexCtrl = function($scope, $filter, $routeParams, Workorders,
}
};
$scope.selectPage = function(status) {
console.log('SelectPage: ' + status);
$scope.status = status;
}
function fetchData() {
$scope.loading = true;
@ -971,14 +988,14 @@ biomed.WorkorderAddCtrl = function($scope, $location, Workorders, Schedule, Clie
};
function updateUsers() {
Users.index({ group: $scope.group }, function(result) {
Users.index({ group: $scope.group, perms: 'workorder.schedulable' }, function(result) {
$scope.users = result;
});
}
function updateAllUsers() {
var criteria = {};
var criteria = { perms: 'workorder.schedulable' };
Users.index(criteria, function(result) {
result.sort(function(a,b) {
@ -1029,6 +1046,24 @@ biomed.WorkorderEditCtrl = function($scope, $routeParams, Workorders, Schedule,
$scope.remarks = createController();
$scope.scheduling = createSchedulingController();
function updateStatus() {
if ($scope.status.model.invoiceNumber && $scope.status.model.checkNumber) {
$scope.status.model.status = 'paid';
} else if ($scope.status.model.invoiceNumber) {
$scope.status.model.status = 'invoiced';
} else {
$scope.status.model.status = 'scheduled';
}
}
$scope.$watch('status.model.invoiceNumber', function() {
updateStatus();
});
$scope.$watch('status.model.checkNumber', function() {
updateStatus();
});
$scope.destroy = function() {
Workorders.destroy({id: $scope.master._id});
window.history.back();
@ -1185,13 +1220,13 @@ biomed.WorkorderEditCtrl = function($scope, $routeParams, Workorders, Schedule,
}
function updateUsers() {
Users.index({ group: $scope.group }, function(result) {
Users.index({ group: $scope.group, perms: 'workorder.schedulable' }, function(result) {
$scope.users = result;
});
}
function updateAllUsers() {
var criteria = {};
var criteria = {perms: 'workorder.schedulable'};
Users.index(criteria, function(result) {
result.sort(function(a,b) {

View File

@ -834,4 +834,37 @@ angular.module('biomed.directives', [])
});
}
};
});
})
.directive('abUnique', function(Clients, $timeout) {
return {
restrict: 'A',
require: 'ngModel',
link: function(scope, element, attrs, ngModel) {
var stop_timeout;
return scope.$watch(function() {
return ngModel.$modelValue;
}, function(name) {
$timeout.cancel(stop_timeout);
if (!name) {
ngModel.$setValidity('unique', true);
}
stop_timeout = $timeout(function() {
var keyProperty = scope.$eval(attrs.abUnique);
if (name) {
Clients.isUnique({
key: keyProperty.key,
field: keyProperty.field,
value: name
}, function(result) {
console.log('unique = ' + result.isUnique);
ngModel.$setValidity('unique', result.isUnique);
});
}
}, 200);
});
}
};
})

View File

@ -4,13 +4,14 @@ angular.module('biomed.services', [])
{ id: "@id", cmd: "@cmd" },
{
index: { method: 'GET', params: {}, isArray: true },
frequencies:{ method: 'GET', params: { cmd: 'frequencies' }, isArray: true },
frequencies: { method: 'GET', params: { cmd: 'frequencies' }, isArray: true },
get: { method: 'GET', params: { id: 0} },
create: { method: 'POST', params: {} },
update: { method: 'POST', params: { id: 0} },
destroy: { method: 'DELETE', params: { id: 0 } },
workorders: { method: 'GET', params: { id: 0, cmd: 'workorders' }, isArray: true },
tags: { method: 'GET', params: { id: 0, cmd: 'tags' }, isArray: true }
workorders: { method: 'GET', params: { id: 0, cmd: 'workorders' }, isArray: true },
tags: { method: 'GET', params: { id: 0, cmd: 'tags' }, isArray: true },
isUnique: { method: 'GET', params: { cmd: 'isUnique' } },
});
})
.factory("Posts", function($resource) {