FIX: Include status=xyz in queryParams

This commit is contained in:
Robin Ward 2014-06-03 18:50:49 -04:00
parent 5bedc56387
commit 9453089b11
3 changed files with 15 additions and 4 deletions

View file

@ -13,6 +13,7 @@ export default Discourse.DiscoveryController.extend({
order: 'default', order: 'default',
ascending: false, ascending: false,
status: null,
actions: { actions: {

View file

@ -1,6 +1,7 @@
Discourse.DiscoverySortableController = Discourse.Controller.extend({ Discourse.DiscoverySortableController = Discourse.Controller.extend({
needs: ['discovery/topics'], needs: ['discovery/topics'],
queryParams: ['order', 'ascending'], queryParams: ['order', 'ascending', 'status'],
order: Em.computed.alias('controllers.discovery/topics.order'), order: Em.computed.alias('controllers.discovery/topics.order'),
ascending: Em.computed.alias('controllers.discovery/topics.ascending') ascending: Em.computed.alias('controllers.discovery/topics.ascending'),
status: Em.computed.alias('controllers.discovery/topics.status')
}); });

View file

@ -8,7 +8,8 @@ function buildTopicRoute(filter) {
return Discourse.Route.extend({ return Discourse.Route.extend({
queryParams: { queryParams: {
sort: { replace: true }, sort: { replace: true },
ascending: { replace: true } ascending: { replace: true },
status: { replace: true }
}, },
beforeModel: function() { beforeModel: function() {
@ -25,6 +26,7 @@ function buildTopicRoute(filter) {
var findOpts = {}; var findOpts = {};
if (params && params.order) { findOpts.order = params.order; } if (params && params.order) { findOpts.order = params.order; }
if (params && params.ascending) { findOpts.ascending = params.ascending; } if (params && params.ascending) { findOpts.ascending = params.ascending; }
if (params && params.status) { findOpts.status = params.status; }
return Discourse.TopicList.list(filter, findOpts).then(function(list) { return Discourse.TopicList.list(filter, findOpts).then(function(list) {
@ -96,7 +98,7 @@ function buildCategoryRoute(filter, params) {
return Discourse.Category.findBySlug(params.slug, params.parentSlug); return Discourse.Category.findBySlug(params.slug, params.parentSlug);
}, },
afterModel: function(model) { afterModel: function(model, transaction) {
var self = this, var self = this,
noSubcategories = params && !!params.no_subcategories, noSubcategories = params && !!params.no_subcategories,
filterMode = "category/" + Discourse.Category.slugFor(model) + (noSubcategories ? "/none" : "") + "/l/" + filter, filterMode = "category/" + Discourse.Category.slugFor(model) + (noSubcategories ? "/none" : "") + "/l/" + filter,
@ -111,6 +113,13 @@ function buildCategoryRoute(filter, params) {
opts.canChangeCategoryNotificationLevel = Discourse.User.current(); opts.canChangeCategoryNotificationLevel = Discourse.User.current();
this.controllerFor('navigation/category').setProperties(opts); this.controllerFor('navigation/category').setProperties(opts);
var queryParams = transaction.queryParams;
params = params || {};
if (queryParams && queryParams.order) { params.order = queryParams.order; }
if (queryParams && queryParams.ascending) { params.ascending = queryParams.ascending; }
if (queryParams && queryParams.status) { params.status = queryParams.status; }
return Discourse.TopicList.list(listFilter, params).then(function(list) { return Discourse.TopicList.list(listFilter, params).then(function(list) {
var tracking = Discourse.TopicTrackingState.current(); var tracking = Discourse.TopicTrackingState.current();
if (tracking) { if (tracking) {