forked from Archives/Athou_commafeed
search for entries
This commit is contained in:
@@ -110,6 +110,7 @@ module.controller('FeedListCtrl', function($scope, $stateParams, $http, $route,
|
||||
|
||||
$scope.selectedType = $stateParams._type;
|
||||
$scope.selectedId = $stateParams._id;
|
||||
$scope.keywords = $stateParams._keywords;
|
||||
|
||||
$scope.name = null;
|
||||
$scope.message = null;
|
||||
@@ -140,13 +141,8 @@ module.controller('FeedListCtrl', function($scope, $stateParams, $http, $route,
|
||||
limit = $window.height() / 33;
|
||||
limit = parseInt(limit, 10) + 5;
|
||||
}
|
||||
EntryService.get({
|
||||
type : $scope.selectedType,
|
||||
id : $scope.selectedId,
|
||||
readType : $scope.settingsService.settings.readingMode,
|
||||
offset : $scope.entries.length,
|
||||
limit : limit
|
||||
}, function(data) {
|
||||
|
||||
var callback = function(data) {
|
||||
for ( var i = 0; i < data.entries.length; i++) {
|
||||
$scope.entries.push(data.entries[i]);
|
||||
}
|
||||
@@ -154,7 +150,22 @@ module.controller('FeedListCtrl', function($scope, $stateParams, $http, $route,
|
||||
$scope.message = data.message;
|
||||
$scope.busy = false;
|
||||
$scope.hasMore = data.entries.length == limit;
|
||||
});
|
||||
};
|
||||
if (!$scope.keywords) {
|
||||
EntryService.get({
|
||||
type : $scope.selectedType,
|
||||
id : $scope.selectedId,
|
||||
readType : $scope.settingsService.settings.readingMode,
|
||||
offset : $scope.entries.length,
|
||||
limit : limit
|
||||
}, callback);
|
||||
} else {
|
||||
EntryService.search({
|
||||
keywords : $scope.keywords,
|
||||
offset : $scope.entries.length,
|
||||
limit : limit
|
||||
}, callback);
|
||||
}
|
||||
};
|
||||
|
||||
$scope.mark = function(entry, read) {
|
||||
@@ -282,8 +293,8 @@ module.controller('ManageUsersCtrl', function($scope, $state, $location,
|
||||
};
|
||||
});
|
||||
|
||||
module.controller('ManageUserCtrl', function($scope, $state, $stateParams, $dialog,
|
||||
AdminUsersService) {
|
||||
module.controller('ManageUserCtrl', function($scope, $state, $stateParams,
|
||||
$dialog, AdminUsersService) {
|
||||
$scope.user = $stateParams._id ? AdminUsersService.get({
|
||||
id : $stateParams._id
|
||||
}) : {
|
||||
|
||||
@@ -173,7 +173,7 @@ module.directive('category', function($compile) {
|
||||
};
|
||||
});
|
||||
|
||||
module.directive('toolbar', function($stateParams, $route, $location,
|
||||
module.directive('toolbar', function($state, $stateParams, $route, $location,
|
||||
SettingsService, EntryService, SubscriptionService, SessionService) {
|
||||
return {
|
||||
scope : {},
|
||||
@@ -208,6 +208,21 @@ module.directive('toolbar', function($stateParams, $route, $location,
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.keywords = $stateParams._keywords;
|
||||
$scope.search = function() {
|
||||
if ($scope.keywords == $stateParams._keywords) {
|
||||
$scope.refresh();
|
||||
} else {
|
||||
$state.transitionTo('feeds.search', {
|
||||
_keywords : $scope.keywords
|
||||
});
|
||||
}
|
||||
};
|
||||
$scope.showButtons = function() {
|
||||
return !$stateParams._keywords;
|
||||
}
|
||||
|
||||
$scope.toAdmin = function() {
|
||||
$location.path('admin');
|
||||
};
|
||||
|
||||
@@ -13,6 +13,11 @@ app.config(function($routeProvider, $stateProvider, $urlRouterProvider) {
|
||||
templateUrl : 'templates/feeds.view.html',
|
||||
controller : 'FeedListCtrl'
|
||||
});
|
||||
$stateProvider.state('feeds.search', {
|
||||
url : '/search/:_keywords',
|
||||
templateUrl : 'templates/feeds.view.html',
|
||||
controller : 'FeedListCtrl'
|
||||
});
|
||||
|
||||
$stateProvider.state('admin', {
|
||||
abstract : true,
|
||||
|
||||
@@ -147,6 +147,12 @@ module.factory('EntryService', function($resource, $http) {
|
||||
params : {
|
||||
_method : 'mark'
|
||||
}
|
||||
},
|
||||
search : {
|
||||
method : 'GET',
|
||||
params : {
|
||||
_method : 'search'
|
||||
}
|
||||
}
|
||||
};
|
||||
var res = $resource('rest/entries/:_method', {}, actions);
|
||||
|
||||
Reference in New Issue
Block a user