Add support for `max_posts` query param. Also make it easier to let
Ember support query params for sorting our tables. Just add it in one place.
This commit is contained in:
parent
4dfe5fd1ca
commit
649329e420
|
@ -1,10 +1,24 @@
|
|||
import DiscourseController from 'discourse/controllers/controller';
|
||||
|
||||
export default DiscourseController.extend({
|
||||
// Just add query params here to have them automatically passed to topic list filters.
|
||||
export var queryParams = {
|
||||
order: { replace: true },
|
||||
ascending: { replace: true },
|
||||
status: { replace: true },
|
||||
state: { replace: true },
|
||||
search: { replace: true },
|
||||
max_posts: { replace: true }
|
||||
};
|
||||
|
||||
// Basic controller options
|
||||
var controllerOpts = {
|
||||
needs: ['discovery/topics'],
|
||||
queryParams: ['order', 'ascending', 'status', 'state', 'search'],
|
||||
order: Em.computed.alias('controllers.discovery/topics.order'),
|
||||
ascending: Em.computed.alias('controllers.discovery/topics.ascending'),
|
||||
status: Em.computed.alias('controllers.discovery/topics.status'),
|
||||
search: Em.computed.alias('controllers.discovery/topics.search')
|
||||
queryParams: Ember.keys(queryParams)
|
||||
};
|
||||
|
||||
// Aliases for the values
|
||||
controllerOpts.queryParams.forEach(function(p) {
|
||||
controllerOpts[p] = Em.computed.alias('controllers.discovery/topics.' + p);
|
||||
});
|
||||
|
||||
export default DiscourseController.extend(controllerOpts);
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
import DiscoveryController from 'discourse/controllers/discovery';
|
||||
import { queryParams } from 'discourse/controllers/discovery-sortable';
|
||||
|
||||
export default DiscoveryController.extend({
|
||||
var controllerOpts = {
|
||||
needs: ['discovery'],
|
||||
bulkSelectEnabled: false,
|
||||
selected: [],
|
||||
|
||||
order: 'default',
|
||||
ascending: false,
|
||||
status: null,
|
||||
search: null,
|
||||
|
||||
actions: {
|
||||
|
||||
|
@ -149,4 +148,13 @@ export default DiscoveryController.extend({
|
|||
loadMoreTopics: function() {
|
||||
return this.get('model').loadMore();
|
||||
}
|
||||
};
|
||||
|
||||
Ember.keys(queryParams).forEach(function(p) {
|
||||
// If we don't have a default value, initialize it to null
|
||||
if (typeof controllerOpts[p] === 'undefined') {
|
||||
controllerOpts[p] = null;
|
||||
}
|
||||
});
|
||||
|
||||
export default DiscoveryController.extend(controllerOpts);
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
// A helper to build a topic route for a filter
|
||||
|
||||
export var queryParams = {
|
||||
sort: { replace: true },
|
||||
ascending: { replace: true },
|
||||
status: { replace: true },
|
||||
state: { replace: true },
|
||||
search: { replace: true }
|
||||
};
|
||||
import { queryParams } from 'discourse/controllers/discovery-sortable';
|
||||
|
||||
export function filterQueryParams(params, defaultParams) {
|
||||
var findOpts = defaultParams || {};
|
||||
|
|
Loading…
Reference in New Issue