Files
brewman/brewman/static/scripts/attendance.js
T
tanshu 8347a3e603 Updates: Bootstrap updated to 3.3.1
Chosen updated to 1.3.0
AngularJS updated to 1.3.8
jQuery updated to 2.1.3
angular-loading-bar updated to 0.6.0
ui-bootstrap updated to 0.12.0
  -- All the datepickers updated for is-open so that they open on focus.
Chore: Replaces this in controllers with $scope. Don't know the downsides of using "this", but to prevent any unknown side-effects.
Chore: Rename Crtl to Controller for all controllers.
2014-12-25 16:26:41 +05:30

58 lines
1.8 KiB
JavaScript

'use strict';
var AttendanceController = ['$scope', '$location', 'asDateFilter', 'Attendance', 'attendanceTypes', 'info', function ($scope, $location, asDate, Attendance, attendanceTypes, info) {
$scope.attendanceTypes = attendanceTypes;
$scope.info = info;
$scope.show = function () {
$scope.info.Date = asDate($scope.info.Date);
$location.path('/Attendance/' + $scope.info.Date);
};
$scope.save = function () {
$scope.info.Date = asDate($scope.info.Date);
return $scope.info.$save(function (u) {
$scope.toasts.push({Type: 'Success', Message: u.Code});
}, function (data) {
$scope.toasts.push({Type: 'Danger', Message: data.data});
});
};
$('#txtDate').focus();
}];
var AttendanceSubController = ['$scope', function ($scope) {
$scope.original = {};
angular.copy($scope.item, $scope.original);
$scope.isLabel = function () {
return true;
};
$scope.isError = function () {
return $scope.item.Worked === 'Error';
};
$scope.isGood = function () {
return $scope.item.Worked === true;
};
$scope.isBad = function () {
return $scope.item.Worked === false;
};
$scope.isDirty = function () {
return !angular.equals($scope.original, $scope.item);
};
}];
AttendanceController.resolve = {
info: ['$route', 'Attendance', function ($route, Attendance) {
var date = $route.current.params.date;
if (angular.isUndefined(date)) {
return Attendance.get({}).$promise;
} else {
return Attendance.get({date: date}).$promise;
}
}],
attendanceTypes: ['AttendanceTypes', function (AttendanceTypes) {
return AttendanceTypes.query({}).$promise;
}]
};