Added active status to Settings board list with filters. Fixes #95.
This commit is contained in:
parent
a354ea0909
commit
ebc9815561
@ -136,3 +136,23 @@ $app->post('/lanes/:laneId/toggle', function($laneId) use($app, $jsonResponse) {
|
||||
}
|
||||
$app->response->setBody($jsonResponse->asJson());
|
||||
})->conditions(['laneId' => '\d+']); // Numbers only.
|
||||
|
||||
$app->post('/boards/:boardId/toggleActive', function($boardId) use($app, $jsonResponse) {
|
||||
if (validateToken()) {
|
||||
$user = getUser();
|
||||
if ($user->isAdmin) {
|
||||
$board = R::load('board', $boardId);
|
||||
$before = $board->export();
|
||||
$board->active = !$board->active;
|
||||
R::store($board);
|
||||
|
||||
$state = $board->active ? 'active' : 'inactive';
|
||||
$jsonResponse->message = 'Set board ' . $board->name . ' ' . $state;
|
||||
$jsonResponse->addBeans(getBoards());
|
||||
|
||||
logAction($user->username . ' changed active status of board ' . $board->name,
|
||||
$before, $board->export());
|
||||
}
|
||||
}
|
||||
$app->response->setBody($jsonResponse->asJson());
|
||||
})->conditions(['boardId' => '\d+']); // Numbers only.
|
||||
|
@ -97,10 +97,10 @@ function addUserToBoard($boardId, $user) {
|
||||
}
|
||||
}
|
||||
|
||||
// Get all active boards.
|
||||
// Get all boards.
|
||||
function getBoards() {
|
||||
$user = getUser();
|
||||
$boards = R::find('board', ' active = 1 ');
|
||||
$boards = R::find('board');
|
||||
|
||||
foreach($boards as $board) {
|
||||
foreach($board->sharedUser as $boardUser) {
|
||||
|
@ -516,6 +516,9 @@ td > .list-group {
|
||||
fieldset > .list-group {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
span.filter {
|
||||
margin-left: 5px;
|
||||
}
|
||||
#change-password, #default-board, #change-username {
|
||||
width: 48%;
|
||||
float: left;
|
||||
|
@ -115,6 +115,17 @@ function ($scope, $routeParams, $location, $interval, $window,
|
||||
var pendingResponse = false,
|
||||
updateCounter = 0;
|
||||
|
||||
$scope.isActiveFilter = function(element) {
|
||||
var retVal = false;
|
||||
$scope.boards.forEach(function(board) {
|
||||
if (board.id === element.id) {
|
||||
retVal = (board.active === '1');
|
||||
}
|
||||
}, this);
|
||||
|
||||
return retVal;
|
||||
};
|
||||
|
||||
$scope.loadBoards = function() {
|
||||
// Don't update the boards if an update is pending.
|
||||
if (pendingResponse || updateCounter) {
|
||||
@ -188,6 +199,13 @@ function ($scope, $routeParams, $location, $interval, $window,
|
||||
if (boardFound) {
|
||||
$scope.filterChanged(); // Make sure any filters are still applied.
|
||||
$scope.currentBoard.loading = false;
|
||||
if ($scope.currentBoard.active === '0') {
|
||||
$scope.currentBoard = {
|
||||
loading: true,
|
||||
name: 'Kanban Board App',
|
||||
error: true
|
||||
};
|
||||
}
|
||||
} else {
|
||||
$scope.currentBoard.error = true;
|
||||
}
|
||||
|
@ -37,6 +37,34 @@ function ($scope, $interval, BoardService) {
|
||||
sort: 'name'
|
||||
};
|
||||
|
||||
$scope.boardFilter = {
|
||||
options: [
|
||||
{ filter: 'all', name: 'All Boards' },
|
||||
{ filter: 'active', name: 'Active' },
|
||||
{ filter: 'inactive', name: 'Inactive' },
|
||||
],
|
||||
filter: 'all'
|
||||
};
|
||||
|
||||
$scope.boardsFilter = function(element) {
|
||||
switch ($scope.boardFilter.filter) {
|
||||
case 'all':
|
||||
return true;
|
||||
case 'active':
|
||||
return element.active === '1';
|
||||
case 'inactive':
|
||||
return element.active === '0';
|
||||
}
|
||||
};
|
||||
|
||||
$scope.toggleActiveState = function(boardId) {
|
||||
BoardService.toggleActiveState(boardId)
|
||||
.success(function(data) {
|
||||
$scope.alerts.showAlerts(data.alerts);
|
||||
$scope.boards = data.data;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.isDeleting = [];
|
||||
$scope.removeBoard = function(boardId) {
|
||||
noty({
|
||||
@ -52,7 +80,7 @@ function ($scope, $interval, BoardService) {
|
||||
$noty.close();
|
||||
|
||||
$scope.boards.forEach(function(board) {
|
||||
if (board.id == boardId) {
|
||||
if (board.id === boardId) {
|
||||
$scope.isDeleting[boardId] = true;
|
||||
}
|
||||
});
|
||||
|
@ -35,6 +35,10 @@ function($http) {
|
||||
return $http.post('api/lanes/' + laneId + '/toggle');
|
||||
},
|
||||
|
||||
toggleActiveState: function(boardId) {
|
||||
return $http.post('api/boards/' + boardId + '/toggleActive');
|
||||
},
|
||||
|
||||
getAutoActions: function() {
|
||||
return $http.get('api/autoactions');
|
||||
},
|
||||
|
@ -1,9 +1,9 @@
|
||||
<div include-replace="partials/header.html"></div>
|
||||
<div id="board-nav">
|
||||
<p class="pull-left form-group form-inline" data-ng-if="!currentBoard.loading">
|
||||
<p class="pull-left form-group form-inline">
|
||||
Select Board:
|
||||
<select class="form-control" data-ng-model="boardNames.current" data-ng-change="selectBoard()"
|
||||
data-ng-options="board.id as board.name for board in boardNames">
|
||||
data-ng-options="board.id as board.name for board in boardNames | filter: isActiveFilter">
|
||||
</select>
|
||||
</p>
|
||||
<p class="pull-right form-group form-inline" data-ng-if="!currentBoard.loading">
|
||||
|
@ -1,5 +1,10 @@
|
||||
<div class="widget-content">
|
||||
<h4>Current Boards
|
||||
<span class="small pull-right form-group form-inline filter">Filter By:
|
||||
<select class="form-control" data-ng-model="boardFilter.filter"
|
||||
data-ng-options="option.filter as option.name for option in boardFilter.options">
|
||||
</select>
|
||||
</span>
|
||||
<span class="small pull-right form-group form-inline">Sort By:
|
||||
<select class="form-control" data-ng-model="boardSort.sort"
|
||||
data-ng-options="option.sort as option.name for option in boardSort.options">
|
||||
@ -21,7 +26,7 @@
|
||||
<td data-ng-if="currentUser.isAdmin == '0'" colspan="5" align="center">You are not assigned to any boards. Contact an admin user to be added to a board.</td>
|
||||
<td data-ng-if="currentUser.isAdmin == '1'" colspan="5" align="center">There are no current boards. Use the <strong>Add Board</strong> button below to add one.</td>
|
||||
</tr>
|
||||
<tr data-ng-repeat="board in boards | orderBy:boardSort.sort">
|
||||
<tr data-ng-repeat="board in boards | orderBy:boardSort.sort | filter:boardsFilter">
|
||||
<td><a title="Go To Board" href="#/boards/{{ board.id }}">{{ board.name }}</a></td>
|
||||
<td>
|
||||
<ul class="list-group">
|
||||
@ -47,6 +52,7 @@
|
||||
data-ng-click="boardFormData.setBoard(board)"></a>
|
||||
<a class="fa fa-trash-o" title="Remove Board"
|
||||
data-ng-click="removeBoard(board.id)"></a>
|
||||
<input type="checkbox" data-ng-checked="board.active == 1" data-ng-click="toggleActiveState(board.id)">
|
||||
</span>
|
||||
<span data-ng-if="isDeleting[board.id]" class="fa fa-refresh fa-spin"></span>
|
||||
</td>
|
||||
|
Reference in New Issue
Block a user