@@ -39,7 +39,10 @@ app.config(function ($provide, $routeProvider, $interpolateProvider, $httpProvid
|
||||
.state('list', {
|
||||
url: "/",
|
||||
templateUrl: "/boardlist.mainView.html",
|
||||
controller: 'ListController'
|
||||
controller: 'ListController',
|
||||
params: {
|
||||
filter: { value: '' }
|
||||
}
|
||||
})
|
||||
.state('board', {
|
||||
url: "/board/:boardId/:filter",
|
||||
|
||||
@@ -80,7 +80,7 @@ app.controller('BoardController', function ($rootScope, $scope, $stateParams, St
|
||||
}
|
||||
};
|
||||
$scope.checkCanEdit = function () {
|
||||
return !$scope.archived;
|
||||
return !BoardService.getCurrent().archived;
|
||||
};
|
||||
|
||||
// filter cards here, as ng-sortable will not work nicely with html-inline filters
|
||||
|
||||
@@ -48,9 +48,10 @@ app.controller('CardController', function ($scope, $rootScope, $routeParams, $lo
|
||||
}
|
||||
};
|
||||
$scope.cardEditDescriptionShow = function($event) {
|
||||
if(BoardService.isArchived() || CardService.getCurrent().archived) {
|
||||
return false;
|
||||
}
|
||||
var node = $event.target.nodeName;
|
||||
console.log($event);
|
||||
console.log(BoardService);
|
||||
if($scope.card.archived || !$scope.boardservice.canEdit()) {
|
||||
console.log(node);
|
||||
} else {
|
||||
|
||||
@@ -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);
|
||||
|
||||
33
js/filters/boardFilterAcl.js
Normal file
33
js/filters/boardFilterAcl.js
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* @copyright Copyright (c) 2017 Julius Härtl <jus@bitgrid.net>
|
||||
*
|
||||
* @author Julius Härtl <jus@bitgrid.net>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
app.filter('boardFilterAcl', function() {
|
||||
return function(boards) {
|
||||
var _result = [];
|
||||
angular.forEach(boards, function(board){
|
||||
if(board.acl !== null && Object.keys(board.acl).length > 0) {
|
||||
_result.push(board);
|
||||
}
|
||||
});
|
||||
return _result;
|
||||
};
|
||||
});
|
||||
@@ -24,15 +24,16 @@
|
||||
|
||||
app.filter('cardFilter', function() {
|
||||
return function(cards, rules) {
|
||||
var _result = {};
|
||||
var _result = [];
|
||||
angular.forEach(cards, function(card){
|
||||
var _card = card;
|
||||
angular.some(rules, function(rule, condition) {
|
||||
if(_card[rule]===condition) {
|
||||
var keys = Object.keys(rules);
|
||||
keys.some(function(key, condition) {
|
||||
if(_card[key]===rules[key]) {
|
||||
_result.push(_card);
|
||||
}
|
||||
});
|
||||
});
|
||||
return result;
|
||||
return _result;
|
||||
};
|
||||
});
|
||||
@@ -24,7 +24,7 @@ app.filter('textColorFilter', function() {
|
||||
return function (hex) {
|
||||
// RGB2HLS by Garry Tan
|
||||
// http://axonflux.com/handy-rgb-to-hsl-and-rgb-to-hsv-color-model-c
|
||||
var result = /^([A-Fa-f\d]{2})([A-Fa-f\d]{2})([A-Fa-f\d]{2})$/i.exec(hex);
|
||||
var result = /^#?([A-Fa-f\d]{2})([A-Fa-f\d]{2})([A-Fa-f\d]{2})$/i.exec(hex);
|
||||
var color = result ? {
|
||||
r: parseInt(result[1], 16),
|
||||
g: parseInt(result[2], 16),
|
||||
|
||||
@@ -190,6 +190,13 @@ app.factory('BoardService', function(ApiService, $http, $q){
|
||||
return this.getCurrent().permissions['PERMISSION_SHARE'];
|
||||
}
|
||||
|
||||
BoardService.prototype.isArchived = function () {
|
||||
if(!this.getCurrent() || this.getCurrent().archived) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
service = new BoardService($http, 'boards', $q);
|
||||
return service;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user