Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- angular.module('client').config(function ($stateProvider, stateFactory) {
- $stateProvider.state('staff.shifts', stateFactory('Shifts', {
- url: '/shifts',
- templateUrl: 'states/shifts/index/shift-daylist.html'
- }));
- }).controller('ShiftsCtrl', function ($scope, sheduleRest, MultiSidebarService) {
- var PAGE_SIZE = 30;
- $scope.query = {
- start: moment().startOf('week').unix(),
- end: moment().endOf('week').unix()
- };
- $scope.entities = [];
- $scope.activeEnt = null;
- $scope.tempEnt = null;
- $scope.inProgress = false;
- var getNextPage = $scope.getNextPage = function () {
- if ($scope.inProgress) {
- return;
- }
- var length = $scope.entities.length;
- $scope.inProgress = true;
- getEntities(length).then(function (entities) {
- $scope.addEntities(entities);
- $scope.inProgress = false;
- });
- };
- $scope.addEntities = function (entities) {
- $scope.entities.push.apply($scope.entities, entities);
- };
- $scope.getFirstPage = function () {
- $scope.entities = [];
- getNextPage();
- };
- $scope.$watch('query', function(){
- $scope.getFirstPage();
- });
- $scope.editPositions = function(template){
- MultiSidebarService.create($scope, template);
- };
- function getEntities(offset) {
- offset = offset || 0;
- return sheduleRest.query({
- offset: offset,
- limit: PAGE_SIZE,
- companyId: 1,
- start: $scope.query.start,
- end: $scope.query.end
- }).$promise;
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement