changes
This commit is contained in:
@@ -1,72 +1,33 @@
|
||||
|
||||
app.controller('BoardController', function ($rootScope, $scope, $location, $http, $route, $stateParams, BoardService, StackService) {
|
||||
app.controller('BoardController', function ($rootScope, $scope, $stateParams, StatusService, BoardService, StackService, CardService) {
|
||||
|
||||
|
||||
$scope.sidebar = $rootScope.sidebar;
|
||||
|
||||
$scope.id = $stateParams.boardId;
|
||||
|
||||
$scope.stackservice = StackService;
|
||||
$scope.boardservice = BoardService;
|
||||
$scope.statusservice = StatusService;
|
||||
|
||||
// fetch data
|
||||
StackService.clear();
|
||||
|
||||
console.log("foo");
|
||||
StackService.fetchAll($scope.id).then(function(data) {
|
||||
console.log($scope.stackservice.data)
|
||||
$scope.releaseWaiting();
|
||||
$scope.statusservice.releaseWaiting();
|
||||
}, function(error) {
|
||||
$scope.setError('Error occured', error);
|
||||
$scope.statusservice.setError('Error occured', error);
|
||||
});
|
||||
|
||||
BoardService.fetchOne($scope.id).then(function(data) {
|
||||
$scope.releaseWaiting();
|
||||
$scope.statusservice.releaseWaiting();
|
||||
}, function(error) {
|
||||
$scope.setError('Error occured', error);
|
||||
$scope.statusservice.setError('Error occured', error);
|
||||
});
|
||||
|
||||
$scope.newStack = { 'boardId': $scope.id};
|
||||
$scope.newCard = {};
|
||||
|
||||
|
||||
// Status Helper
|
||||
$scope.status = {
|
||||
'active': true,
|
||||
'icon': 'loading',
|
||||
'title': 'Bitte warten',
|
||||
'text': 'Es dauert noch einen kleinen Moment',
|
||||
'counter': 2,
|
||||
};
|
||||
|
||||
$scope.setStatus = function($icon, $title, $text='') {
|
||||
$scope.status.active = true;
|
||||
$scope.status.icon = $icon;
|
||||
$scope.status.title = $title;
|
||||
$scope.status.text = $text;
|
||||
}
|
||||
|
||||
$scope.setError = function($title, $text) {
|
||||
$scope.status.active = true;
|
||||
$scope.status.icon = 'error';
|
||||
$scope.status.title = $title;
|
||||
$scope.status.text = $text;
|
||||
$scope.status.counter = 0;
|
||||
}
|
||||
|
||||
$scope.releaseWaiting = function() {
|
||||
if($scope.status.counter>0)
|
||||
$scope.status.counter--;
|
||||
if($scope.status.counter==0) {
|
||||
$scope.status = {
|
||||
'active': false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$scope.unsetStatus = function() {
|
||||
$scope.status = {
|
||||
'active': false
|
||||
}
|
||||
}
|
||||
|
||||
// Create a new Stack
|
||||
$scope.createStack = function () {
|
||||
@@ -75,6 +36,18 @@ app.controller('BoardController', function ($rootScope, $scope, $location, $http
|
||||
});
|
||||
};
|
||||
|
||||
$scope.createCard = function(stack, title) {
|
||||
var newCard = {
|
||||
'title': title,
|
||||
'stackId': stack,
|
||||
'type': 'plain',
|
||||
};
|
||||
CardService.create(newCard).then(function (data) {
|
||||
$scope.stackservice.addCard(data);
|
||||
$scope.newCard.title = "";
|
||||
});
|
||||
}
|
||||
|
||||
// Lighten Color of the board for background usage
|
||||
$scope.rgblight = function (hex) {
|
||||
var result = /^([A-Fa-f\d]{2})([A-Fa-f\d]{2})([A-Fa-f\d]{2})$/i.exec(hex);
|
||||
@@ -95,10 +68,23 @@ app.controller('BoardController', function ($rootScope, $scope, $location, $http
|
||||
// settings for card sorting
|
||||
$scope.sortOptions = {
|
||||
itemMoved: function (event) {
|
||||
// TODO: Implement reodering here
|
||||
event.source.itemScope.modelValue.status = event.dest.sortableScope.$parent.column;
|
||||
console.log(event.dest.sortableScope.$parent);
|
||||
var order = event.dest.index;
|
||||
var card = event.source.itemScope.c;
|
||||
var newStack = event.dest.sortableScope.$parent.s.id;
|
||||
card.stackId = newStack;
|
||||
CardService.update(card);
|
||||
|
||||
CardService.reorder(card, order).then(function(data) {
|
||||
StackService.data[newStack].cards = data;
|
||||
});
|
||||
},
|
||||
orderChanged: function (event) {
|
||||
// TODO: Implement ordering here
|
||||
var order = event.dest.index;
|
||||
var card = event.source.itemScope.c;
|
||||
CardService.reorder(card, order);
|
||||
},
|
||||
scrollableContainer: '#board',
|
||||
containerPositioning: 'relative',
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
|
||||
|
||||
app.controller('CardController', function ($scope, $rootScope, $routeParams, $location, $stateParams) {
|
||||
app.controller('CardController', function ($scope, $rootScope, $routeParams, $location, $stateParams, CardService) {
|
||||
$scope.sidebar = $rootScope.sidebar;
|
||||
|
||||
$scope.location = $location;
|
||||
$scope.card = {'id': 1, 'title': 'We should implement all the useful things, that a kanban like project managemnt system needs for having success', 'description': 'Non et quibusdam officiis expedita excepturi. Tenetur ea et dignissimos qui. Rerum quis commodi aperiam amet dolorum suscipit asperiores. Enim dolorem ea nisi voluptate. \
|
||||
Consequatur enim iste dolore autem est unde voluptatum. Aut sit et iure. Suscipit deserunt nisi repellat in officiis alias. Nihil beatae ea ut laudantium at.\
|
||||
Doloribus nihil ipsa consequatur laudantium qui enim eveniet quo. Voluptatum tenetur sunt quis sint aliquam et molestias. Quae voluptatem tempora qui eaque qui esse possimus magni. Animi dolorem maiores iste.\
|
||||
Totam ut tempora officiis ipsam dolorem modi. Dolores hic aut itaque. Earum in est voluptas voluptatum. Cumque pariatur qui omnis placeat. Eius sed sunt corrupti dolorem quo.'};
|
||||
$scope.cardservice = CardService;
|
||||
$scope.cardId = $stateParams.cardId;
|
||||
|
||||
console.log($stateParams);
|
||||
CardService.fetchOne($scope.cardId).then(function(data) {
|
||||
console.log(data);
|
||||
}, function(error) {
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,70 +1,39 @@
|
||||
|
||||
app.controller('ListController', function ($scope, $location, boardFactory, BoardService) {
|
||||
app.controller('ListController', function ($scope, $location, BoardService) {
|
||||
$scope.boards = null;
|
||||
$scope.newBoard = {};
|
||||
$scope.status = {};
|
||||
$scope.colors = ['31CC7C', '317CCC', 'FF7A66', 'F1DB50', '7C31CC', 'CC317C', '3A3B3D', 'CACBCD'];
|
||||
|
||||
$scope.boardservice = BoardService;
|
||||
BoardService.fetchAll().then(function(data) {
|
||||
console.log($scope.boardservice);
|
||||
console.log(data);
|
||||
}, function(error) {
|
||||
//$scope.setStatus('error','Error occured', error);
|
||||
});
|
||||
|
||||
$scope.getBoards = function() {
|
||||
boardFactory.getBoards()
|
||||
.then(function (response) {
|
||||
$scope.boards = response.data;
|
||||
for (var i = 0; i < $scope.boards.length; i++) {
|
||||
$scope.boards[i].status = {
|
||||
'edit': false,
|
||||
}
|
||||
}
|
||||
}, function (error) {
|
||||
$scope.status.getBoards = 'Unable to load customer data: ' + error.message;
|
||||
});
|
||||
}
|
||||
BoardService.fetchAll(); // TODO: show error when loading fails
|
||||
|
||||
$scope.selectColor = function(color) {
|
||||
$scope.newBoard.color = color;
|
||||
};
|
||||
|
||||
$scope.createBoard = function () {
|
||||
boardFactory.createBoard($scope.newBoard)
|
||||
BoardService.create($scope.newBoard)
|
||||
.then(function (response) {
|
||||
$scope.boards.push(response.data);
|
||||
$scope.newBoard = {};
|
||||
$scope.status.addBoard=false;
|
||||
}, function(error) {
|
||||
$scope.status.createBoard = 'Unable to insert board: ' + error.message;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.updateBoard = function(board) {
|
||||
boardFactory.updateBoard(board)
|
||||
.then(function (response) {
|
||||
board = response.data;
|
||||
}, function(error) {
|
||||
$scope.status.createBoard = 'Unable to insert board: ' + error.message;
|
||||
});
|
||||
BoardService.update(board);
|
||||
board.status.edit = false;
|
||||
$scope.$apply();
|
||||
};
|
||||
$scope.deleteBoard = function(board) {
|
||||
// TODO: Ask for confirmation
|
||||
//if (confirm('Are you sure you want to delete this?')) {
|
||||
BoardService.delete(board.id);
|
||||
//}
|
||||
};
|
||||
|
||||
$scope.selectColor = function(color) {
|
||||
$scope.newBoard.color = color;
|
||||
};
|
||||
|
||||
$scope.deleteBoard = function (index) {
|
||||
var board = $scope.boards[index];
|
||||
boardFactory.deleteBoard(board.id)
|
||||
.then(function (response) {
|
||||
$scope.status.deleteBoard = 'Deleted Board';
|
||||
$scope.boards.splice( index, 1 );
|
||||
|
||||
}, function(error) {
|
||||
$scope.status.deleteBoard = 'Unable to insert board: ' + error.message;
|
||||
});
|
||||
};
|
||||
$scope.getBoards();
|
||||
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user