mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
toggle between unread and all entries
This commit is contained in:
@@ -46,12 +46,11 @@ public class FeedEntryService extends GenericDAO<FeedEntry, Long> {
|
|||||||
return typedQuery.getResultList();
|
return typedQuery.getResultList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<FeedEntry> getAllEntries(Feed feed, User user) {
|
public List<FeedEntry> getAllEntries(Feed feed) {
|
||||||
String query = "select e from FeedEntry e where e.feed=:feed";
|
String query = "select e from FeedEntry e where e.feed=:feed";
|
||||||
TypedQuery<FeedEntry> typedQuery = em.createQuery(query,
|
TypedQuery<FeedEntry> typedQuery = em.createQuery(query,
|
||||||
FeedEntry.class);
|
FeedEntry.class);
|
||||||
typedQuery.setParameter("feed", feed);
|
typedQuery.setParameter("feed", feed);
|
||||||
typedQuery.setParameter("user", user);
|
|
||||||
return typedQuery.getResultList();
|
return typedQuery.getResultList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,11 +30,13 @@ public class EntriesREST extends AbstractREST {
|
|||||||
@PathParam("id") String id, @PathParam("readType") String readType) {
|
@PathParam("id") String id, @PathParam("readType") String readType) {
|
||||||
|
|
||||||
Entries entries = new Entries();
|
Entries entries = new Entries();
|
||||||
|
boolean unreadOnly = "unread".equals(readType);
|
||||||
|
|
||||||
if ("feed".equals(type)) {
|
if ("feed".equals(type)) {
|
||||||
FeedSubscription subscription = feedSubscriptionService
|
FeedSubscription subscription = feedSubscriptionService
|
||||||
.findById(Long.valueOf(id));
|
.findById(Long.valueOf(id));
|
||||||
entries.setName(subscription.getTitle());
|
entries.setName(subscription.getTitle());
|
||||||
entries.getEntries().addAll(buildEntries(subscription));
|
entries.getEntries().addAll(buildEntries(subscription, unreadOnly));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
FeedCategory feedCategory = "all".equals(id) ? null
|
FeedCategory feedCategory = "all".equals(id) ? null
|
||||||
@@ -45,7 +47,8 @@ public class EntriesREST extends AbstractREST {
|
|||||||
|
|
||||||
entries.setName("all".equals(id) ? "All" : feedCategory.getName());
|
entries.setName("all".equals(id) ? "All" : feedCategory.getName());
|
||||||
for (FeedSubscription subscription : subscriptions) {
|
for (FeedSubscription subscription : subscriptions) {
|
||||||
entries.getEntries().addAll(buildEntries(subscription));
|
entries.getEntries().addAll(
|
||||||
|
buildEntries(subscription, unreadOnly));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,9 +62,17 @@ public class EntriesREST extends AbstractREST {
|
|||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Entry> buildEntries(FeedSubscription subscription) {
|
private List<Entry> buildEntries(FeedSubscription subscription,
|
||||||
List<FeedEntry> feedEntries = feedEntryService.getUnreadEntries(
|
boolean unreadOnly) {
|
||||||
subscription.getFeed(), getUser());
|
List<FeedEntry> feedEntries = null;
|
||||||
|
|
||||||
|
if (unreadOnly) {
|
||||||
|
feedEntries = feedEntryService.getUnreadEntries(
|
||||||
|
subscription.getFeed(), getUser());
|
||||||
|
} else {
|
||||||
|
feedEntries = feedEntryService.getAllEntries(
|
||||||
|
subscription.getFeed());
|
||||||
|
}
|
||||||
|
|
||||||
List<Entry> entries = Lists.newArrayList();
|
List<Entry> entries = Lists.newArrayList();
|
||||||
for (FeedEntry feedEntry : feedEntries) {
|
for (FeedEntry feedEntry : feedEntries) {
|
||||||
|
|||||||
@@ -86,12 +86,18 @@ module.controller('FeedListCtrl', function($scope, $routeParams, $http,
|
|||||||
$scope.selectedType = $routeParams._type;
|
$scope.selectedType = $routeParams._type;
|
||||||
$scope.selectedId = $routeParams._id;
|
$scope.selectedId = $routeParams._id;
|
||||||
|
|
||||||
$scope.entryList = EntryService.get({
|
$scope.readType = 'all';
|
||||||
_type : $scope.selectedType,
|
|
||||||
_id : $scope.selectedId,
|
|
||||||
_readtype : 'unread'
|
|
||||||
})
|
|
||||||
|
|
||||||
|
$scope.refreshList = function() {
|
||||||
|
$scope.entryList = EntryService.get({
|
||||||
|
_type : $scope.selectedType,
|
||||||
|
_id : $scope.selectedId,
|
||||||
|
_readtype : $scope.readType
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.refreshList();
|
||||||
|
|
||||||
$scope.mark = function(entry, read) {
|
$scope.mark = function(entry, read) {
|
||||||
if (entry.read != read) {
|
if (entry.read != read) {
|
||||||
entry.read = read;
|
entry.read = read;
|
||||||
|
|||||||
@@ -1,4 +1,14 @@
|
|||||||
<div ng-controller="FeedListCtrl">
|
<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>
|
||||||
|
|
||||||
|
|
||||||
<span>{{entryList.name}}</span><span
|
<span>{{entryList.name}}</span><span
|
||||||
ng-show="selectedType == 'category'"> »</span>
|
ng-show="selectedType == 'category'"> »</span>
|
||||||
<div class="accordion" id="feed-accordion">
|
<div class="accordion" id="feed-accordion">
|
||||||
|
|||||||
Reference in New Issue
Block a user