save settings on read mode change

This commit is contained in:
Athou
2013-03-23 23:14:14 +01:00
parent f0ac0d1722
commit 0b1241ebf9
11 changed files with 91 additions and 36 deletions

View File

@@ -0,0 +1,6 @@
<div class="toolbar">
<div class="btn-group" data-toggle="buttons-radio">
<button type="button" class="btn" ng-model="settings.readingMode" btn-radio="'unread'">Unread</button>
<button type="button" class="btn" ng-model="settings.readingMode" btn-radio="'all'">All</button>
</div>
</div>

View File

@@ -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;

View File

@@ -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();
});
}
};
});

View File

@@ -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;
});

View File

@@ -1,14 +1,5 @@
<div ng-controller="FeedListCtrl">
<div class="toolbar">
<div class="btn-group" data-toggle="buttons-radio">
<button type="button" class="btn" ng-model="readType" btn-radio="'all'" ng-click="refreshList()">All</button>
<button type="button" class="btn" ng-model="readType" btn-radio="'unread'" ng-click="refreshList()">Unread only</button>
</div>
</div>
{{readType}}
<span>{{entryList.name}}</span><span
ng-show="selectedType == 'category'"> &#187;</span>
<div class="accordion" id="feed-accordion">