add categories

This commit is contained in:
Athou
2013-03-31 08:17:28 +02:00
parent 5a4d11c4de
commit 89c7a00ebf
8 changed files with 137 additions and 13 deletions

View File

@@ -88,6 +88,22 @@ module.directive('subscribe', function(SubscriptionService) {
SubscriptionService.init();
$scope.closeImport();
};
$scope.cat = {};
$scope.openCategory= function(){
$scope.isOpenCategory = true;
$scope.cat = {};
};
$scope.closeCategory= function(){
$scope.isOpenCategory = false;
};
$scope.saveCategory = function() {
SubscriptionService.addCategory($scope.cat);
$scope.closeCategory();
};
}
};
});
@@ -147,7 +163,7 @@ module.directive('category', function($compile) {
});
module.directive('toolbar', function($stateParams, $route, $location,
SettingsService, EntryService, SubscriptionService) {
SettingsService, EntryService, SubscriptionService, SessionService) {
return {
scope : {},
restrict : 'E',
@@ -158,6 +174,8 @@ module.directive('toolbar', function($stateParams, $route, $location,
function totalActiveAjaxRequests() {
return ($http.pendingRequests.length + $.active);
}
$scope.session = SessionService.get();
$scope.loading = true;
$scope.$watch(totalActiveAjaxRequests, function() {

View File

@@ -1,9 +1,10 @@
var module = angular.module('commafeed.services', [ 'ngResource' ]);
module.factory('SubscriptionService', [
'$resource',
'$http',
function($resource, $http) {
module.factory('SessionService', function($resource){
return $resource('rest/session/get');
});
module.factory('SubscriptionService', function($resource, $http) {
var flatten = function(category, parentName, array) {
if (!array)
@@ -50,6 +51,18 @@ module.factory('SubscriptionService', [
params : {
_method : 'collapse'
}
},
addCategory : {
method : 'GET',
params : {
_method : 'addCategory'
}
},
deleteCategory : {
method : 'GET',
params : {
_method : 'deleteCategory'
}
}
};
var s = {};
@@ -98,12 +111,19 @@ module.factory('SubscriptionService', [
id : id
});
};
s.addCategory = function(cat, callback) {
res.addCategory(cat, function(data) {
s.init();
if (callback)
callback(data);
});
};
s.collapse = res.collapse;
s.init();
return s;
} ]);
});
module.factory('EntryService', [ '$resource', '$http',
module.factory('EntryService',
function($resource, $http) {
var actions = {
get : {
@@ -121,7 +141,7 @@ module.factory('EntryService', [ '$resource', '$http',
};
var res = $resource('rest/entries/:_method', {}, actions);
return res;
} ]);
});
module.factory('SettingsService', function($resource) {
var s = {}