Fix getting permissions and active indicator

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2017-05-17 21:44:58 +02:00
parent 90eb9ce28e
commit 247b4dde0c
10 changed files with 62 additions and 20 deletions

View File

@@ -41,7 +41,7 @@ app.config(function ($provide, $routeProvider, $interpolateProvider, $httpProvid
templateUrl: "/boardlist.mainView.html",
controller: 'ListController',
params: {
filter: { value: '' }
filter: { value: '', dynamic: true }
}
})
.state('board', {

View File

@@ -20,11 +20,17 @@
*
*/
app.run(function ($document, $rootScope, $transitions) {
app.run(function ($document, $rootScope, $transitions, BoardService) {
'use strict';
$document.click(function (event) {
$rootScope.$broadcast('documentClicked', event);
});
$transitions.onEnter({from: 'list'}, function($state, $transition$) {
BoardService.unsetCurrrent();
});
$transitions.onEnter({to: 'list'}, function($state, $transition$) {
BoardService.unsetCurrrent();
});
$transitions.onEnter({to: 'board.card'}, function ($state, $transition$) {
$rootScope.sidebar.show = true;
});
@@ -40,9 +46,6 @@ app.run(function ($document, $rootScope, $transitions) {
$transitions.onExit({from: 'board.detail'}, function ($state) {
$rootScope.sidebar.show = false;
});
$transitions.onEnter({to: 'board.archive'}, function ($state) {
//BoardController.loadArchived();
});
$('link[rel="shortcut icon"]').attr(
'href',

View File

@@ -44,7 +44,9 @@ 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');
angular.copy($scope.boardservice.sorted, $scope.boardservice.sidebar);
$scope.boardservice.sidebar = $filter('orderBy')($scope.boardservice.sidebar, 'title');
$scope.boardservice.sidebar = $filter('cardFilter')($scope.boardservice.sidebar, {archived: false});
if ($scope.status.filter === 'archived') {
var filter = {};

View File

@@ -145,7 +145,13 @@ app.factory('ApiService', function($http, $q){
return this.data[this.id];
};
ApiService.prototype.getData = function() {
ApiService.prototype.unsetCurrrent = function () {
this.id = null;
};
ApiService.prototype.getData = function() {
return $.map(this.data, function(value, index) {
return [value];
});

View File

@@ -167,28 +167,31 @@ app.factory('BoardService', function(ApiService, $http, $q){
return false;
}
return this.getCurrent().permissions['PERMISSION_READ'];
}
};
BoardService.prototype.canEdit = function() {
if(!this.getCurrent() || !this.getCurrent().permissions) {
return false;
}
return this.getCurrent().permissions['PERMISSION_EDIT'];
}
};
BoardService.prototype.canManage = function() {
BoardService.prototype.canManage = function(board = null) {
if(board !== null) {
return board.permissions['PERMISSION_MANAGE'];
}
if(!this.getCurrent() || !this.getCurrent().permissions) {
return false;
}
return this.getCurrent().permissions['PERMISSION_MANAGE'];
}
};
BoardService.prototype.canShare = function() {
if(!this.getCurrent() || !this.getCurrent().permissions) {
return false;
}
return this.getCurrent().permissions['PERMISSION_SHARE'];
}
};
BoardService.prototype.isArchived = function () {
if(!this.getCurrent() || this.getCurrent().archived) {