Always select first color fixes #19
This commit is contained in:
@@ -22,57 +22,59 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
app.controller('ListController', function ($scope, $location, $filter, BoardService, $element) {
|
app.controller('ListController', function ($scope, $location, $filter, BoardService, $element) {
|
||||||
$scope.boards = [];
|
$scope.boards = [];
|
||||||
$scope.newBoard = {};
|
$scope.newBoard = {};
|
||||||
$scope.status = {};
|
$scope.status = {};
|
||||||
$scope.colors = ['0082c9', '00c9c6','00c906', 'c92b00', 'F1DB50', '7C31CC', '3A3B3D', 'CACBCD'];
|
$scope.colors = ['0082c9', '00c9c6','00c906', 'c92b00', 'F1DB50', '7C31CC', '3A3B3D', 'CACBCD'];
|
||||||
$scope.boardservice = BoardService;
|
$scope.boardservice = BoardService;
|
||||||
|
$scope.newBoard.color = $scope.colors[0];
|
||||||
|
|
||||||
// FIXME: not nice, but we want to load this only once
|
// FIXME: not nice, but we want to load this only once
|
||||||
if($element.attr('id') === 'app-navigation') {
|
if($element.attr('id') === 'app-navigation') {
|
||||||
BoardService.fetchAll().then(function(data) {
|
BoardService.fetchAll().then(function(data) {
|
||||||
$scope.filterData();
|
$scope.filterData();
|
||||||
}, function (error) {
|
}, function (error) {
|
||||||
// TODO: show error when loading fails
|
// TODO: show error when loading fails
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.filterData = function () {
|
$scope.filterData = function () {
|
||||||
angular.copy($scope.boardservice.getData(), $scope.boardservice.sorted);
|
angular.copy($scope.boardservice.getData(), $scope.boardservice.sorted);
|
||||||
$scope.boardservice.sorted = $filter('orderBy')($scope.boardservice.sorted, 'title');
|
$scope.boardservice.sorted = $filter('orderBy')($scope.boardservice.sorted, 'title');
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.selectColor = function(color) {
|
$scope.selectColor = function(color) {
|
||||||
$scope.newBoard.color = color;
|
$scope.newBoard.color = color;
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.boardCreate = function() {
|
$scope.boardCreate = function() {
|
||||||
if(!$scope.newBoard.title || !$scope.newBoard.color) {
|
if(!$scope.newBoard.title || !$scope.newBoard.color) {
|
||||||
$scope.status.addBoard=false;
|
$scope.status.addBoard=false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BoardService.create($scope.newBoard)
|
BoardService.create($scope.newBoard)
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
$scope.newBoard = {};
|
$scope.newBoard = {};
|
||||||
$scope.status.addBoard=false;
|
$scope.newBoard.color = $scope.colors[0];
|
||||||
$scope.filterData();
|
$scope.status.addBoard=false;
|
||||||
}, function(error) {
|
$scope.filterData();
|
||||||
$scope.status.createBoard = 'Unable to insert board: ' + error.message;
|
}, function(error) {
|
||||||
});
|
$scope.status.createBoard = 'Unable to insert board: ' + error.message;
|
||||||
};
|
});
|
||||||
|
};
|
||||||
|
|
||||||
$scope.boardUpdate = function(board) {
|
$scope.boardUpdate = function(board) {
|
||||||
BoardService.update(board).then(function(data) {
|
BoardService.update(board).then(function(data) {
|
||||||
$scope.filterData();
|
$scope.filterData();
|
||||||
});
|
});
|
||||||
board.status.edit = false;
|
board.status.edit = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.boardDelete = function(board) {
|
$scope.boardDelete = function(board) {
|
||||||
BoardService.delete(board.id).then(function (data) {
|
BoardService.delete(board.id).then(function (data) {
|
||||||
$scope.filterData();
|
$scope.filterData();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user