forked from Archives/Athou_commafeed
save settings on read mode change
This commit is contained in:
@@ -81,23 +81,26 @@ module.controller('CategoryTreeCtrl', function($scope, $routeParams, $location,
|
||||
});
|
||||
|
||||
module.controller('FeedListCtrl', function($scope, $routeParams, $http,
|
||||
EntryService) {
|
||||
EntryService, SettingsService) {
|
||||
|
||||
$scope.selectedType = $routeParams._type;
|
||||
$scope.selectedId = $routeParams._id;
|
||||
|
||||
$scope.readType = 'all';
|
||||
$scope.settings = SettingsService.settings;
|
||||
$scope.$watch('settings.readingMode', function() {
|
||||
$scope.refreshList();
|
||||
});
|
||||
|
||||
$scope.refreshList = function() {
|
||||
$scope.entryList = EntryService.get({
|
||||
_type : $scope.selectedType,
|
||||
_id : $scope.selectedId,
|
||||
_readtype : $scope.readType
|
||||
});
|
||||
if ($scope.settings.readingMode) {
|
||||
$scope.entryList = EntryService.get({
|
||||
_type : $scope.selectedType,
|
||||
_id : $scope.selectedId,
|
||||
_readtype : $scope.settings.readingMode
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$scope.refreshList();
|
||||
|
||||
$scope.mark = function(entry, read) {
|
||||
if (entry.read != read) {
|
||||
entry.read = read;
|
||||
|
||||
@@ -23,4 +23,21 @@ module.directive('category', function($compile) {
|
||||
$compile(ul.contents())(scope);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
module.directive('toolbar', function(SettingsService) {
|
||||
return {
|
||||
scope : {},
|
||||
restrict : 'E',
|
||||
replace : true,
|
||||
templateUrl : 'directives/toolbar.html',
|
||||
controller : function($scope, SettingsService) {
|
||||
$scope.settings = SettingsService.settings;
|
||||
},
|
||||
link : function($scope, element) {
|
||||
element.find('button').bind('click', function() {
|
||||
SettingsService.save();
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -2,13 +2,7 @@ var module = angular.module('commafeed.services', [ 'ngResource' ]);
|
||||
|
||||
module.factory('CategoryService', [ '$resource', '$http',
|
||||
function($resource, $http) {
|
||||
var actions = {
|
||||
'get' : {
|
||||
method : 'GET'
|
||||
}
|
||||
};
|
||||
res = $resource('rest/subscriptions', {}, actions);
|
||||
return res;
|
||||
return $resource('rest/subscriptions');
|
||||
} ]);
|
||||
|
||||
module.factory('EntryService', [
|
||||
@@ -16,7 +10,7 @@ module.factory('EntryService', [
|
||||
'$http',
|
||||
function($resource, $http) {
|
||||
var actions = {
|
||||
'get' : {
|
||||
get : {
|
||||
method : 'GET',
|
||||
params : {
|
||||
_method : 'get'
|
||||
@@ -32,4 +26,13 @@ module.factory('EntryService', [
|
||||
res = $resource('rest/entries/:_method/:_type/:_id/:_readtype', {},
|
||||
actions);
|
||||
return res;
|
||||
} ]);
|
||||
} ]);
|
||||
|
||||
module.service('SettingsService', function($resource) {
|
||||
var s = {}
|
||||
s.settings = $resource('rest/settings/get').get();
|
||||
s.save = function() {
|
||||
$resource('rest/settings/save').save(s.settings);
|
||||
};
|
||||
return s;
|
||||
});
|
||||
Reference in New Issue
Block a user