Upgrade topics to modern ES6
This commit is contained in:
parent
9cf77bc01d
commit
92f97fa94f
|
@ -2,7 +2,7 @@ import DiscoveryController from 'discourse/controllers/discovery';
|
||||||
import { queryParams } from 'discourse/controllers/discovery-sortable';
|
import { queryParams } from 'discourse/controllers/discovery-sortable';
|
||||||
import BulkTopicSelection from 'discourse/mixins/bulk-topic-selection';
|
import BulkTopicSelection from 'discourse/mixins/bulk-topic-selection';
|
||||||
|
|
||||||
var controllerOpts = {
|
const controllerOpts = {
|
||||||
needs: ['discovery'],
|
needs: ['discovery'],
|
||||||
period: null,
|
period: null,
|
||||||
|
|
||||||
|
@ -24,10 +24,10 @@ var controllerOpts = {
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
|
||||||
changeSort: function(sortBy) {
|
changeSort(sortBy) {
|
||||||
if (this.get('isSearch')) {
|
if (this.get('isSearch')) {
|
||||||
var term = this.get('searchTerm');
|
let term = this.get('searchTerm');
|
||||||
var order;
|
let order;
|
||||||
|
|
||||||
if (sortBy === 'activity') { order = 'latest'; }
|
if (sortBy === 'activity') { order = 'latest'; }
|
||||||
if (sortBy === 'views') { order = 'views'; }
|
if (sortBy === 'views') { order = 'views'; }
|
||||||
|
@ -51,7 +51,7 @@ var controllerOpts = {
|
||||||
|
|
||||||
// Show newly inserted topics
|
// Show newly inserted topics
|
||||||
showInserted: function() {
|
showInserted: function() {
|
||||||
var tracker = Discourse.TopicTrackingState.current();
|
const tracker = Discourse.TopicTrackingState.current();
|
||||||
|
|
||||||
// Move inserted into topics
|
// Move inserted into topics
|
||||||
this.get('content').loadBefore(tracker.get('newIncoming'));
|
this.get('content').loadBefore(tracker.get('newIncoming'));
|
||||||
|
@ -60,7 +60,7 @@ var controllerOpts = {
|
||||||
},
|
},
|
||||||
|
|
||||||
refresh: function() {
|
refresh: function() {
|
||||||
var filter = this.get('model.filter'),
|
const filter = this.get('model.filter'),
|
||||||
self = this;
|
self = this;
|
||||||
|
|
||||||
this.setProperties({ order: 'default', ascending: false });
|
this.setProperties({ order: 'default', ascending: false });
|
||||||
|
@ -79,7 +79,7 @@ var controllerOpts = {
|
||||||
self.setProperties({ model: list });
|
self.setProperties({ model: list });
|
||||||
self.resetSelected();
|
self.resetSelected();
|
||||||
|
|
||||||
var tracking = Discourse.TopicTrackingState.current();
|
const tracking = Discourse.TopicTrackingState.current();
|
||||||
if (tracking) {
|
if (tracking) {
|
||||||
tracking.sync(list, filter);
|
tracking.sync(list, filter);
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ var controllerOpts = {
|
||||||
|
|
||||||
|
|
||||||
resetNew: function() {
|
resetNew: function() {
|
||||||
var self = this;
|
const self = this;
|
||||||
|
|
||||||
Discourse.TopicTrackingState.current().resetNew();
|
Discourse.TopicTrackingState.current().resetNew();
|
||||||
Discourse.Topic.resetNew().then(function() {
|
Discourse.Topic.resetNew().then(function() {
|
||||||
|
@ -135,11 +135,11 @@ var controllerOpts = {
|
||||||
footerMessage: function() {
|
footerMessage: function() {
|
||||||
if (!this.get('allLoaded')) { return; }
|
if (!this.get('allLoaded')) { return; }
|
||||||
|
|
||||||
var category = this.get('category');
|
const category = this.get('category');
|
||||||
if( category ) {
|
if( category ) {
|
||||||
return I18n.t('topics.bottom.category', {category: category.get('name')});
|
return I18n.t('topics.bottom.category', {category: category.get('name')});
|
||||||
} else {
|
} else {
|
||||||
var split = (this.get('model.filter') || '').split('/');
|
const split = (this.get('model.filter') || '').split('/');
|
||||||
if (this.get('model.topics.length') === 0) {
|
if (this.get('model.topics.length') === 0) {
|
||||||
return I18n.t("topics.none." + split[0], {
|
return I18n.t("topics.none." + split[0], {
|
||||||
category: split[1]
|
category: split[1]
|
||||||
|
@ -155,7 +155,7 @@ var controllerOpts = {
|
||||||
footerEducation: function() {
|
footerEducation: function() {
|
||||||
if (!this.get('allLoaded') || this.get('model.topics.length') > 0 || !Discourse.User.current()) { return; }
|
if (!this.get('allLoaded') || this.get('model.topics.length') > 0 || !Discourse.User.current()) { return; }
|
||||||
|
|
||||||
var split = (this.get('model.filter') || '').split('/');
|
const split = (this.get('model.filter') || '').split('/');
|
||||||
|
|
||||||
if (split[0] !== 'new' && split[0] !== 'unread') { return; }
|
if (split[0] !== 'new' && split[0] !== 'unread') { return; }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue