FIX: If categories page is the default, don't add it to the title
This commit is contained in:
parent
0f4693b7eb
commit
e684d7689e
|
@ -2,7 +2,7 @@ import { queryParams } from 'discourse/controllers/discovery-sortable';
|
|||
|
||||
// A helper to build a topic route for a filter
|
||||
function filterQueryParams(params, defaultParams) {
|
||||
var findOpts = defaultParams || {};
|
||||
const findOpts = defaultParams || {};
|
||||
if (params) {
|
||||
Ember.keys(queryParams).forEach(function(opt) {
|
||||
if (params[opt]) { findOpts[opt] = params[opt]; }
|
||||
|
@ -16,47 +16,47 @@ export default function(filter, extras) {
|
|||
return Discourse.Route.extend({
|
||||
queryParams: queryParams,
|
||||
|
||||
beforeModel: function() {
|
||||
beforeModel() {
|
||||
this.controllerFor('navigation/default').set('filterMode', filter);
|
||||
},
|
||||
|
||||
model: function(data, transition) {
|
||||
model(data, transition) {
|
||||
|
||||
// attempt to stop early cause we need this to be called before .sync
|
||||
Discourse.ScreenTrack.current().stop();
|
||||
|
||||
var findOpts = filterQueryParams(transition.queryParams),
|
||||
extras = { cached: this.isPoppedState(transition) };
|
||||
const findOpts = filterQueryParams(transition.queryParams),
|
||||
extras = { cached: this.isPoppedState(transition) };
|
||||
|
||||
return Discourse.TopicList.list(filter, findOpts, extras);
|
||||
},
|
||||
|
||||
titleToken: function() {
|
||||
titleToken() {
|
||||
if (filter === Discourse.Utilities.defaultHomepage()) { return; }
|
||||
|
||||
var filterText = I18n.t('filters.' + filter.replace('/', '.') + '.title', {count: 0});
|
||||
const filterText = I18n.t('filters.' + filter.replace('/', '.') + '.title', {count: 0});
|
||||
return I18n.t('filters.with_topics', {filter: filterText});
|
||||
},
|
||||
|
||||
setupController: function(controller, model, trans) {
|
||||
setupController(controller, model, trans) {
|
||||
if (trans) {
|
||||
controller.setProperties(Em.getProperties(trans, _.keys(queryParams).map(function(v){
|
||||
return 'queryParams.' + v;
|
||||
})));
|
||||
}
|
||||
|
||||
var periods = this.controllerFor('discovery').get('periods'),
|
||||
periodId = model.get('for_period') || (filter.indexOf('/') > 0 ? filter.split('/')[1] : '');
|
||||
const periods = this.controllerFor('discovery').get('periods'),
|
||||
periodId = model.get('for_period') || (filter.indexOf('/') > 0 ? filter.split('/')[1] : '');
|
||||
|
||||
var topicOpts = {
|
||||
model: model,
|
||||
const topicOpts = {
|
||||
model,
|
||||
category: null,
|
||||
period: periods.findBy('id', periodId),
|
||||
selected: [],
|
||||
expandGloballyPinned: true
|
||||
};
|
||||
|
||||
var params = model.get('params');
|
||||
const params = model.get('params');
|
||||
if (params && Object.keys(params).length) {
|
||||
topicOpts.order = params.order;
|
||||
topicOpts.ascending = params.ascending;
|
||||
|
@ -67,7 +67,7 @@ export default function(filter, extras) {
|
|||
this.controllerFor('navigation/default').set('canCreateTopic', model.get('can_create_topic'));
|
||||
},
|
||||
|
||||
renderTemplate: function() {
|
||||
renderTemplate() {
|
||||
this.render('navigation/default', { outlet: 'navigation-bar' });
|
||||
this.render('discovery/topics', { controller: 'discovery/topics', outlet: 'list-container' });
|
||||
}
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
import ShowFooter from "discourse/mixins/show-footer";
|
||||
|
||||
Discourse.DiscoveryCategoriesRoute = Discourse.Route.extend(Discourse.OpenComposer, ShowFooter, {
|
||||
renderTemplate: function() {
|
||||
renderTemplate() {
|
||||
this.render('navigation/categories', { outlet: 'navigation-bar' });
|
||||
this.render('discovery/categories', { outlet: 'list-container' });
|
||||
},
|
||||
|
||||
beforeModel: function() {
|
||||
beforeModel() {
|
||||
this.controllerFor('navigation/categories').set('filterMode', 'categories');
|
||||
},
|
||||
|
||||
model: function() {
|
||||
model() {
|
||||
// TODO: Remove this and ensure server side does not supply `topic_list`
|
||||
// if default page is categories
|
||||
PreloadStore.remove("topic_list");
|
||||
|
||||
return Discourse.CategoryList.list('categories').then(function(list) {
|
||||
var tracking = Discourse.TopicTrackingState.current();
|
||||
const tracking = Discourse.TopicTrackingState.current();
|
||||
if (tracking) {
|
||||
tracking.sync(list, 'categories');
|
||||
tracking.trackIncoming('categories');
|
||||
|
@ -25,11 +25,12 @@ Discourse.DiscoveryCategoriesRoute = Discourse.Route.extend(Discourse.OpenCompos
|
|||
});
|
||||
},
|
||||
|
||||
titleToken: function() {
|
||||
titleToken() {
|
||||
if (Discourse.Utilities.defaultHomepage() === "categories") { return; }
|
||||
return I18n.t('filters.categories.title');
|
||||
},
|
||||
|
||||
setupController: function(controller, model) {
|
||||
setupController(controller, model) {
|
||||
controller.set('model', model);
|
||||
|
||||
// Only show either the Create Category or Create Topic button
|
||||
|
@ -40,22 +41,19 @@ Discourse.DiscoveryCategoriesRoute = Discourse.Route.extend(Discourse.OpenCompos
|
|||
},
|
||||
|
||||
actions: {
|
||||
createCategory: function() {
|
||||
var groups = Discourse.Site.current().groups;
|
||||
var everyone_group = groups.findBy('id', 0);
|
||||
var group_names = groups.map(function(group) {
|
||||
return group.name;
|
||||
});
|
||||
createCategory() {
|
||||
const groups = this.site.groups,
|
||||
everyoneName = groups.findBy('id', 0).name;
|
||||
|
||||
Discourse.Route.showModal(this, 'editCategory', Discourse.Category.create({
|
||||
color: 'AB9364', text_color: 'FFFFFF', group_permissions: [{group_name: everyone_group.name, permission_type: 1}],
|
||||
available_groups: group_names,
|
||||
color: 'AB9364', text_color: 'FFFFFF', group_permissions: [{group_name: everyoneName, permission_type: 1}],
|
||||
available_groups: groups.map(g => g.name),
|
||||
allow_badges: true
|
||||
}));
|
||||
this.controllerFor('editCategory').set('selectedTab', 'general');
|
||||
},
|
||||
|
||||
createTopic: function() {
|
||||
createTopic() {
|
||||
this.openComposer(this.controllerFor('discovery/categories'));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue