starring support (#43)

This commit is contained in:
Athou
2013-04-30 11:29:02 +02:00
parent 2cbf51c287
commit bfde9241eb
8 changed files with 55 additions and 6 deletions

View File

@@ -99,6 +99,11 @@ function($scope, $timeout, $stateParams, $window, $location, $state, $route, Cat
$scope.selectedType = $stateParams._type;
$scope.selectedId = $stateParams._id;
$scope.starred = {
id: 'starred',
name: 'Starred'
};
$scope.$on('$stateChangeSuccess', function() {
$scope.selectedType = $stateParams._type;
$scope.selectedId = $stateParams._id;
@@ -339,6 +344,18 @@ function($scope, $stateParams, $http, $route, $window, EntryService, SettingsSer
});
}
};
$scope.star = function(entry, star, event) {
event.preventDefault();
event.stopPropagation();
if (entry.starred != star) {
entry.starred = star;
EntryService.star({
id : entry.id,
starred : star
});
}
};
$scope.isOpen = false;
$scope.entryClicked = function(entry, event) {

View File

@@ -95,6 +95,8 @@ module.directive('category', [ function() {
node : '=',
selectedType : '=',
selectedId : '=',
showLabel : '=',
showChildren : '=',
unreadCount : '&'
},
restrict : 'E',

View File

@@ -186,6 +186,12 @@ function($resource, $http) {
params : {
_method : 'mark'
}
},
star : {
method : 'POST',
params : {
_method : 'star'
}
}
};
var res = $resource('rest/entry/:_method', {}, actions);