mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
save settings on read mode change
This commit is contained in:
6
src/main/webapp/directives/toolbar.html
Normal file
6
src/main/webapp/directives/toolbar.html
Normal 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>
|
||||
@@ -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;
|
||||
});
|
||||
@@ -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'"> »</span>
|
||||
<div class="accordion" id="feed-accordion">
|
||||
|
||||
Reference in New Issue
Block a user