diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2013-01-06 23:57:14 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2013-01-06 23:57:14 +0100 |
commit | 7a0db61a0d9ba8e1359f5d14392bc90e6a0872e0 (patch) | |
tree | 78f56c88024d8542a0bd567aefeb7c688c75ac77 /src/main/webapp/apps/frontPageApp/frontPageApp.js | |
parent | a310ffdce4cd6dcbb6ba8e4fb739412ea9abdca5 (diff) | |
download | esper-testing-7a0db61a0d9ba8e1359f5d14392bc90e6a0872e0.tar.gz esper-testing-7a0db61a0d9ba8e1359f5d14392bc90e6a0872e0.tar.bz2 esper-testing-7a0db61a0d9ba8e1359f5d14392bc90e6a0872e0.tar.xz esper-testing-7a0db61a0d9ba8e1359f5d14392bc90e6a0872e0.zip |
o Creating a recent badges view.
Diffstat (limited to 'src/main/webapp/apps/frontPageApp/frontPageApp.js')
-rwxr-xr-x | src/main/webapp/apps/frontPageApp/frontPageApp.js | 63 |
1 files changed, 46 insertions, 17 deletions
diff --git a/src/main/webapp/apps/frontPageApp/frontPageApp.js b/src/main/webapp/apps/frontPageApp/frontPageApp.js index 39dbc9d..5f1cf2c 100755 --- a/src/main/webapp/apps/frontPageApp/frontPageApp.js +++ b/src/main/webapp/apps/frontPageApp/frontPageApp.js @@ -1,8 +1,9 @@ 'use strict'; -var frontPageApp = angular.module('frontPageApp', ['ngGrid', 'person', 'badge', 'build', 'pagingTableService', 'core.directives']).config(function ($routeProvider, $locationProvider) { +var frontPageApp = angular.module('frontPageApp', ['ngGrid', 'person', 'badge', 'build', 'pagingTableService', 'core.directives']).config(function ($routeProvider) { $routeProvider. when('/', {controller: FrontPageCtrl, templateUrl: '/apps/frontPageApp/frontPage.html?noCache=' + noCache}). + when('/badge/', {controller: BadgeListCtrl, templateUrl: '/apps/frontPageApp/badgeList.html?noCache=' + noCache}). when('/person/', {controller: PersonListCtrl, templateUrl: '/apps/frontPageApp/personList.html?noCache=' + noCache}). when('/person/:personUuid', {controller: PersonCtrl, templateUrl: '/apps/frontPageApp/person.html?noCache=' + noCache}); }); @@ -12,28 +13,56 @@ function FrontPageCtrl($scope, Person, Badge) { $scope.recentBadges = Badge.query(); } -function PersonListCtrl($scope, Person, PagingTableService) { +function groupBy(array, size) { + var group = []; + var groups = []; + angular.forEach(array, function (element) { + group.push(element); + if (group.length == size) { + groups.push(group); + group = []; + } + }); + + if (group.length != 0) { + groups.push(group); + } + return groups; +} + +function BadgeListCtrl($scope, Badge, PagingTableService) { + var groupSize = 6; + var personsWatcher = function () { - var array = $scope.persons.rows; - - var group = []; - var groups = []; - angular.forEach(array, function(element) { - group.push(element); - if(group.length == 4) { - groups.push(group); - group = []; - } + var withDay = _.map($scope.badges.rows, function(badge) { + badge.day = new Date(badge.badge.createdDate).clearTime().getTime(); +// badge.day.clearTime(); + return badge; }); - if(group.length != 0) { - groups.push(group); - } + var byDay = _.groupBy(withDay, 'day'); + console.log("byDay", byDay); +// var dateGroups = _.map(byDay, function(group, date) { +// return {date: groupBy(group, groupSize)} +// }); + + $scope.badgeGroups = byDay; + }; + + $scope.badges = PagingTableService.create($scope, PagingTableService.defaultCallback(Badge), + {count: groupSize * 6, watcher: personsWatcher}); - $scope.personGroups = groups; + $scope.badgeGroups = []; +} + +function PersonListCtrl($scope, Person, PagingTableService) { + var groupSize = 4; + var personsWatcher = function () { + $scope.personGroups = groupBy($scope.persons.rows, groupSize); }; - $scope.persons = PagingTableService.create($scope, PagingTableService.defaultCallback(Person, {orderBy: "name"}), {count: 4 * 6, watcher: personsWatcher}); + $scope.persons = PagingTableService.create($scope, PagingTableService.defaultCallback(Person, {orderBy: "name"}), + {count: groupSize * 6, watcher: personsWatcher}); $scope.personGroups = []; } |