@@ -21,11 +21,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
app.controller('ListController', function ($scope, $location, $filter, BoardService, $element, $timeout) {
|
||||
app.controller('ListController', function ($scope, $location, $filter, BoardService, $element, $timeout, $stateParams) {
|
||||
$scope.boards = [];
|
||||
$scope.newBoard = {};
|
||||
$scope.status = {
|
||||
deleteUndo: []
|
||||
deleteUndo: [],
|
||||
filter: $stateParams.filter ? $stateParams.filter : '',
|
||||
sidebar: false
|
||||
};
|
||||
$scope.colors = ['0082c9', '00c9c6','00c906', 'c92b00', 'F1DB50', '7C31CC', '3A3B3D', 'CACBCD'];
|
||||
$scope.boardservice = BoardService;
|
||||
@@ -42,9 +44,27 @@ app.controller('ListController', function ($scope, $location, $filter, BoardServ
|
||||
|
||||
$scope.filterData = function () {
|
||||
angular.copy($scope.boardservice.getData(), $scope.boardservice.sorted);
|
||||
$scope.boardservice.sidebar = $filter('orderBy')($scope.boardservice.sorted, 'title');
|
||||
|
||||
if ($scope.status.filter === 'archived') {
|
||||
var filter = {};
|
||||
filter[$scope.status.filter] = true;
|
||||
$scope.boardservice.sorted = $filter('cardFilter')($scope.boardservice.sorted, filter);
|
||||
} else if ($scope.status.filter === 'shared') {
|
||||
$scope.boardservice.sorted = $filter('cardFilter')($scope.boardservice.sorted, {archived: false});
|
||||
$scope.boardservice.sorted = $filter('boardFilterAcl')($scope.boardservice.sorted);
|
||||
} else {
|
||||
$scope.boardservice.sorted = $filter('cardFilter')($scope.boardservice.sorted, {archived: false});
|
||||
}
|
||||
$scope.boardservice.sorted = $filter('orderBy')($scope.boardservice.sorted, 'title');
|
||||
};
|
||||
|
||||
$scope.$state = $stateParams;
|
||||
$scope.$watch('$state.filter', function (name) {
|
||||
$scope.status.filter = name;
|
||||
$scope.filterData();
|
||||
});
|
||||
|
||||
$scope.selectColor = function(color) {
|
||||
$scope.newBoard.color = color;
|
||||
};
|
||||
@@ -72,11 +92,24 @@ app.controller('ListController', function ($scope, $location, $filter, BoardServ
|
||||
board.status.edit = false;
|
||||
};
|
||||
|
||||
$scope.boardArchive = function (board) {
|
||||
board.archived = true;
|
||||
BoardService.update(board).then(function(data) {
|
||||
$scope.filterData();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.boardUnarchive = function (board) {
|
||||
board.archived = false;
|
||||
BoardService.update(board).then(function(data) {
|
||||
$scope.filterData();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.boardDelete = function(board) {
|
||||
var boardId = board.id;
|
||||
$scope.status.deleteUndo[boardId] = 10;
|
||||
$scope.boardDeleteCountdown = function () {
|
||||
console.log($scope.status);
|
||||
if($scope.status.deleteUndo[boardId] > 0) {
|
||||
$scope.status.deleteUndo[boardId]--;
|
||||
$timeout($scope.boardDeleteCountdown, 1000);
|
||||
|
||||
Reference in New Issue
Block a user