Implemented "goto subscription".

TODO:
 * Neither navigation with arrows nor selection with ENTER implemented,
   must click a subscription.
This commit is contained in:
Risto Kankkunen
2013-05-27 21:32:19 +03:00
parent 4e7bcd004d
commit 2ba050a167
5 changed files with 83 additions and 1 deletions

View File

@@ -49,6 +49,10 @@ view.error_while_loading_feed=Error while loading this feed
view.keep_unread=Keep unread
view.no_unread_items=has no unread items.
feedsearch.hint=Type in a subscription...
feedsearch.help=Use the return key to select and arrow keys to navigate.
feedsearch.result_prefix=Your subscriptions:
settings.general=General
settings.general.language=Language
settings.general.language.contribute=Contribute with translations

View File

@@ -556,6 +556,26 @@ function($scope, $http, $state, $stateParams, $route, $location,
};
}]);
module.controller('FeedCtrl', ['$scope', '$state', 'CategoryService',
function($scope, $state, CategoryService) {
$scope.CategoryService = CategoryService;
$scope.feedSearchModal = false;
$scope.goToFeed = function(id) {
$state.transitionTo('feeds.view', {_type : 'feed', _id : id});
$scope.feedSearchModal=false;
$scope.feedFilter='';
};
Mousetrap.bind('g u', function(e) {
$scope.$apply(function() {
$scope.feedSearchModal = true;
});
return false;
});
}]);
module.controller('FeedListCtrl', ['$scope', '$stateParams', '$http', '$route',
'$window', 'EntryService', 'SettingsService', 'FeedService', 'CategoryService', 'AnalyticsService',
function($scope, $stateParams, $http, $route, $window, EntryService, SettingsService, FeedService, CategoryService, AnalyticsService) {

View File

@@ -131,6 +131,27 @@ function($resource, $http) {
}
return array;
};
var traverse = function(fn, category, parentName) {
var subs = [];
fn(category, parentName);
var children = category.children;
for ( var c = 0; c < children.length; c++) {
traverse(fn, children[c], category.name);
}
return subs;
};
var flatfeeds = function(category) {
// TODO: This is a bit silly: We flatten the hierarchical list of
// subscriptions which was build from the flat list of subscriptions
// in CategoryREST.getSubscriptions(). It would be nice to have
// direct access to feedSubscriptionDAO.findAll().
var subs = [];
var cb = function(category) {
subs.push.apply(subs, category.feeds);
};
traverse(cb, category);
return subs;
};
var actions = {
get : {
method : 'GET',
@@ -178,11 +199,13 @@ function($resource, $http) {
var res = $resource('rest/category/:_method', {}, actions);
res.subscriptions = {};
res.flatCategories = {};
res.feeds = [];
res.init = function(callback) {
res.get(function(data) {
res.subscriptions = data;
res.flatCategories = flatten(data);
res.feeds = flatfeeds(data);
if (callback)
callback(data);
});

View File

@@ -59,4 +59,8 @@
.favicon {
width: 16px;
height: 16px;
}
.item-filter-dialog .modal-body {
overflow: hidden;
}

View File

@@ -1,4 +1,4 @@
<div class="container-fluid">
<div class="container-fluid" ng-controller="FeedCtrl">
<div class="row-fluid">
<div class="span2 left-menu">
<div class="sidebar-nav-fixed" mousewheel-scrolling>
@@ -13,5 +13,36 @@
</div>
</div>
</div>
<div
modal="feedSearchModal"
close="feedSearchModal=false"
options="{dialogClass: 'modal item-filter-dialog'}"
>
<div class="modal-header">
<button
type="button"
class="close"
ng-click="feedSearchModal=false"
>&times;</button>
<h4><input
ng-model="feedFilter"
style="width: 90%"
placeholder="${feedsearch.hint}"
autofocus=""
></h4>
<small>${feedsearch.help}</small>
</div>
<div class="modal-body">
<strong>${feedsearch.result_prefix}</strong>
<span ng-repeat="feed in CategoryService.feeds | filter:feedFilter | limitTo:40">
<a
style="font-size: large; margin: 10px;"
ng-click="goToFeed(feed.id)"
>
<favicon url="feed.iconUrl" />&nbsp;{{feed.name}}
</a> &bull;
</span>
</div>
</div>
<div ng-include="'templates/_footer.html'"></div>
</div>