mirror of
https://github.com/discourse/discourse.git
synced 2025-06-10 17:33:42 +08:00
ES6: More controllers converted to ES6
This commit is contained in:
@ -6,7 +6,7 @@
|
|||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.DiscoveryCategoriesController = Discourse.DiscoveryController.extend({
|
export default Discourse.DiscoveryController.extend({
|
||||||
needs: ['modal', 'discovery'],
|
needs: ['modal', 'discovery'],
|
||||||
|
|
||||||
actions: {
|
actions: {
|
@ -6,7 +6,7 @@
|
|||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.DiscoveryTopController = Discourse.DiscoveryController.extend({
|
export default Discourse.DiscoveryController.extend({
|
||||||
needs: ['discovery'],
|
needs: ['discovery'],
|
||||||
|
|
||||||
actions: {
|
actions: {
|
@ -6,7 +6,7 @@
|
|||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.DiscoveryTopicsController = Discourse.DiscoveryController.extend({
|
export default Discourse.DiscoveryController.extend({
|
||||||
needs: ['discovery'],
|
needs: ['discovery'],
|
||||||
bulkSelectEnabled: false,
|
bulkSelectEnabled: false,
|
||||||
selected: [],
|
selected: [],
|
@ -1,6 +1,6 @@
|
|||||||
Discourse.DiscoverySortableController = Discourse.Controller.extend({
|
Discourse.DiscoverySortableController = Discourse.Controller.extend({
|
||||||
needs: ['discoveryTopics'],
|
needs: ['discovery/topics'],
|
||||||
queryParams: ['order', 'ascending'],
|
queryParams: ['order', 'ascending'],
|
||||||
order: Em.computed.alias('controllers.discoveryTopics.order'),
|
order: Em.computed.alias('controllers.discovery/topics.order'),
|
||||||
ascending: Em.computed.alias('controllers.discoveryTopics.ascending')
|
ascending: Em.computed.alias('controllers.discovery/topics.ascending')
|
||||||
});
|
});
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
@uses Discourse.ModalFunctionality
|
@uses Discourse.ModalFunctionality
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.EditCategoryController = Discourse.ObjectController.extend(Discourse.ModalFunctionality, {
|
export default Discourse.ObjectController.extend(Discourse.ModalFunctionality, {
|
||||||
generalSelected: Ember.computed.equal('selectedTab', 'general'),
|
generalSelected: Ember.computed.equal('selectedTab', 'general'),
|
||||||
securitySelected: Ember.computed.equal('selectedTab', 'security'),
|
securitySelected: Ember.computed.equal('selectedTab', 'security'),
|
||||||
settingsSelected: Ember.computed.equal('selectedTab', 'settings'),
|
settingsSelected: Ember.computed.equal('selectedTab', 'settings'),
|
@ -7,8 +7,7 @@
|
|||||||
@uses Discourse.ModalFunctionality
|
@uses Discourse.ModalFunctionality
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.EditTopicAutoCloseController = Discourse.ObjectController.extend(Discourse.ModalFunctionality, {
|
export default Discourse.ObjectController.extend(Discourse.ModalFunctionality, {
|
||||||
|
|
||||||
auto_close_valid: true,
|
auto_close_valid: true,
|
||||||
auto_close_invalid: Em.computed.not('auto_close_valid'),
|
auto_close_invalid: Em.computed.not('auto_close_valid'),
|
||||||
|
|
@ -8,7 +8,7 @@
|
|||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.TopicBulkActionsController = Ember.ArrayController.extend(Discourse.ModalFunctionality, {
|
Discourse.TopicBulkActionsController = Ember.ArrayController.extend(Discourse.ModalFunctionality, {
|
||||||
needs: ['discoveryTopics'],
|
needs: ['discovery/topics'],
|
||||||
|
|
||||||
onShow: function() {
|
onShow: function() {
|
||||||
this.set('controllers.modal.modalClass', 'topic-bulk-actions-modal small');
|
this.set('controllers.modal.modalClass', 'topic-bulk-actions-modal small');
|
||||||
@ -45,7 +45,7 @@ Discourse.TopicBulkActionsController = Ember.ArrayController.extend(Discourse.Mo
|
|||||||
performAndRefresh: function(operation) {
|
performAndRefresh: function(operation) {
|
||||||
var self = this;
|
var self = this;
|
||||||
return this.perform(operation).then(function() {
|
return this.perform(operation).then(function() {
|
||||||
self.get('controllers.discoveryTopics').send('refresh');
|
self.get('controllers.discovery/topics').send('refresh');
|
||||||
self.send('closeModal');
|
self.send('closeModal');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -7,13 +7,13 @@
|
|||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.TopicListItemController = Ember.ObjectController.extend({
|
Discourse.TopicListItemController = Ember.ObjectController.extend({
|
||||||
needs: ['discoveryTopics'],
|
needs: ['discovery/topics'],
|
||||||
|
|
||||||
canStar: Em.computed.alias('controllers.discoveryTopics.currentUser.id'),
|
canStar: Em.computed.alias('controllers.discovery/topics.currentUser.id'),
|
||||||
bulkSelectEnabled: Em.computed.alias('controllers.discoveryTopics.bulkSelectEnabled'),
|
bulkSelectEnabled: Em.computed.alias('controllers.discovery/topics.bulkSelectEnabled'),
|
||||||
|
|
||||||
checked: function(key, value) {
|
checked: function(key, value) {
|
||||||
var selected = this.get('controllers.discoveryTopics.selected'),
|
var selected = this.get('controllers.discovery/topics.selected'),
|
||||||
topic = this.get('model');
|
topic = this.get('model');
|
||||||
|
|
||||||
if (arguments.length > 1) {
|
if (arguments.length > 1) {
|
||||||
@ -24,17 +24,17 @@ Discourse.TopicListItemController = Ember.ObjectController.extend({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return selected.contains(topic);
|
return selected.contains(topic);
|
||||||
}.property('controllers.discoveryTopics.selected.length'),
|
}.property('controllers.discovery/topics.selected.length'),
|
||||||
|
|
||||||
titleColSpan: function() {
|
titleColSpan: function() {
|
||||||
// Uncategorized pinned topics will span the title and category column in the topic list.
|
// Uncategorized pinned topics will span the title and category column in the topic list.
|
||||||
return (!this.get('controllers.discoveryTopics.hideCategory') &&
|
return (!this.get('controllers.discovery/topics.hideCategory') &&
|
||||||
this.get('model.isPinnedUncategorized') ? 2 : 1);
|
this.get('model.isPinnedUncategorized') ? 2 : 1);
|
||||||
}.property('controllers.discoveryTopics.hideCategory', 'model.isPinnedUncategorized'),
|
}.property('controllers.discovery/topics.hideCategory', 'model.isPinnedUncategorized'),
|
||||||
|
|
||||||
hideCategory: function() {
|
hideCategory: function() {
|
||||||
return this.get('controllers.discoveryTopics.hideCategory') || this.get('titleColSpan') > 1;
|
return this.get('controllers.discovery/topics.hideCategory') || this.get('titleColSpan') > 1;
|
||||||
}.property('controllers.discoveryTopics.hideCategory', 'titleColSpan'),
|
}.property('controllers.discovery/topics.hideCategory', 'titleColSpan'),
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
toggleStar: function() {
|
toggleStar: function() {
|
||||||
|
@ -195,9 +195,9 @@ Discourse.URL = Em.Object.createWithMixins({
|
|||||||
if (path === "/" && (oldPath === "/" || oldPath === "/" + homepage)) {
|
if (path === "/" && (oldPath === "/" || oldPath === "/" + homepage)) {
|
||||||
// refresh the list
|
// refresh the list
|
||||||
switch (homepage) {
|
switch (homepage) {
|
||||||
case "top" : { this.controllerFor('discoveryTop').send('refresh'); break; }
|
case "top" : { this.controllerFor('discovery/top').send('refresh'); break; }
|
||||||
case "categories": { this.controllerFor('discoveryCategories').send('refresh'); break; }
|
case "categories": { this.controllerFor('discovery/categories').send('refresh'); break; }
|
||||||
default: { this.controllerFor('discoveryTopics').send('refresh'); break; }
|
default: { this.controllerFor('discovery/topics').send('refresh'); break; }
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ Discourse.DiscoveryRoute = Discourse.Route.extend(Discourse.ScrollTop, Discourse
|
|||||||
},
|
},
|
||||||
|
|
||||||
createTopic: function() {
|
createTopic: function() {
|
||||||
this.openComposer(this.controllerFor('discoveryTopics'));
|
this.openComposer(this.controllerFor('discovery/topics'));
|
||||||
},
|
},
|
||||||
|
|
||||||
changeBulkTemplate: function(w) {
|
changeBulkTemplate: function(w) {
|
||||||
@ -57,7 +57,7 @@ Discourse.DiscoveryRoute = Discourse.Route.extend(Discourse.ScrollTop, Discourse
|
|||||||
},
|
},
|
||||||
|
|
||||||
showBulkActions: function() {
|
showBulkActions: function() {
|
||||||
var selected = this.controllerFor('discoveryTopics').get('selected');
|
var selected = this.controllerFor('discovery/topics').get('selected');
|
||||||
Discourse.Route.showModal(this, 'topicBulkActions', selected);
|
Discourse.Route.showModal(this, 'topicBulkActions', selected);
|
||||||
this.send('changeBulkTemplate', 'modal/bulk_actions_buttons');
|
this.send('changeBulkTemplate', 'modal/bulk_actions_buttons');
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ function buildTopicRoute(filter) {
|
|||||||
Discourse.set('title', I18n.t('filters.with_topics', {filter: filterText}));
|
Discourse.set('title', I18n.t('filters.with_topics', {filter: filterText}));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.controllerFor('discoveryTopics').setProperties({
|
this.controllerFor('discovery/topics').setProperties({
|
||||||
model: model,
|
model: model,
|
||||||
category: null,
|
category: null,
|
||||||
period: period,
|
period: period,
|
||||||
@ -78,7 +78,7 @@ function buildTopicRoute(filter) {
|
|||||||
|
|
||||||
renderTemplate: function() {
|
renderTemplate: function() {
|
||||||
this.render('navigation/default', { outlet: 'navigation-bar' });
|
this.render('navigation/default', { outlet: 'navigation-bar' });
|
||||||
this.render('discovery/topics', { controller: 'discoveryTopics', outlet: 'list-container' });
|
this.render('discovery/topics', { controller: 'discovery/topics', outlet: 'list-container' });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -131,7 +131,7 @@ function buildCategoryRoute(filter, params) {
|
|||||||
Discourse.set('title', I18n.t('filters.with_category', { filter: filterText, category: model.get('name').capitalize() }));
|
Discourse.set('title', I18n.t('filters.with_category', { filter: filterText, category: model.get('name').capitalize() }));
|
||||||
|
|
||||||
this.controllerFor('navigationCategory').set('canCreateTopic', topics.get('can_create_topic'));
|
this.controllerFor('navigationCategory').set('canCreateTopic', topics.get('can_create_topic'));
|
||||||
this.controllerFor('discoveryTopics').setProperties({
|
this.controllerFor('discovery/topics').setProperties({
|
||||||
model: topics,
|
model: topics,
|
||||||
category: model,
|
category: model,
|
||||||
period: period,
|
period: period,
|
||||||
@ -144,7 +144,7 @@ function buildCategoryRoute(filter, params) {
|
|||||||
|
|
||||||
renderTemplate: function() {
|
renderTemplate: function() {
|
||||||
this.render('navigation/category', { outlet: 'navigation-bar' });
|
this.render('navigation/category', { outlet: 'navigation-bar' });
|
||||||
this.render('discovery/topics', { controller: 'discoveryTopics', outlet: 'list-container' });
|
this.render('discovery/topics', { controller: 'discovery/topics', outlet: 'list-container' });
|
||||||
},
|
},
|
||||||
|
|
||||||
deactivate: function() {
|
deactivate: function() {
|
||||||
|
@ -18,7 +18,7 @@ Discourse.DiscoveryTopRoute = Discourse.Route.extend(Discourse.OpenComposer, {
|
|||||||
setupController: function(controller, model) {
|
setupController: function(controller, model) {
|
||||||
var filterText = I18n.t('filters.top.title');
|
var filterText = I18n.t('filters.top.title');
|
||||||
Discourse.set('title', I18n.t('filters.with_topics', {filter: filterText}));
|
Discourse.set('title', I18n.t('filters.with_topics', {filter: filterText}));
|
||||||
this.controllerFor('discoveryTop').setProperties({ model: model, category: null });
|
this.controllerFor('discovery/top').setProperties({ model: model, category: null });
|
||||||
this.controllerFor('navigationDefault').set('canCreateTopic', model.get('can_create_topic'));
|
this.controllerFor('navigationDefault').set('canCreateTopic', model.get('can_create_topic'));
|
||||||
|
|
||||||
// If there's a draft, open the create topic composer
|
// If there's a draft, open the create topic composer
|
||||||
@ -40,7 +40,7 @@ Discourse.DiscoveryTopRoute = Discourse.Route.extend(Discourse.OpenComposer, {
|
|||||||
actions: {
|
actions: {
|
||||||
|
|
||||||
createTopic: function() {
|
createTopic: function() {
|
||||||
this.openComposer(this.controllerFor('discoveryTop'));
|
this.openComposer(this.controllerFor('discovery/top'));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -90,7 +90,7 @@ Discourse.DiscoveryTopCategoryRoute = Discourse.Route.extend(Discourse.OpenCompo
|
|||||||
var filterText = I18n.t('filters.top.title');
|
var filterText = I18n.t('filters.top.title');
|
||||||
Discourse.set('title', I18n.t('filters.with_category', {filter: filterText, category: model.get('name').capitalize()}));
|
Discourse.set('title', I18n.t('filters.with_category', {filter: filterText, category: model.get('name').capitalize()}));
|
||||||
this.controllerFor('navigationCategory').set('canCreateTopic', topList.get('can_create_topic'));
|
this.controllerFor('navigationCategory').set('canCreateTopic', topList.get('can_create_topic'));
|
||||||
this.controllerFor('discoveryTop').setProperties({
|
this.controllerFor('discovery/top').setProperties({
|
||||||
model: topList,
|
model: topList,
|
||||||
category: model,
|
category: model,
|
||||||
noSubcategories: this.get('no_subcategories')
|
noSubcategories: this.get('no_subcategories')
|
||||||
@ -100,7 +100,7 @@ Discourse.DiscoveryTopCategoryRoute = Discourse.Route.extend(Discourse.OpenCompo
|
|||||||
|
|
||||||
renderTemplate: function() {
|
renderTemplate: function() {
|
||||||
this.render('navigation/category', { outlet: 'navigation-bar' });
|
this.render('navigation/category', { outlet: 'navigation-bar' });
|
||||||
this.render('discovery/top', { controller: 'discoveryTop', outlet: 'list-container' });
|
this.render('discovery/top', { controller: 'discovery/top', outlet: 'list-container' });
|
||||||
},
|
},
|
||||||
|
|
||||||
deactivate: function() {
|
deactivate: function() {
|
||||||
@ -111,7 +111,7 @@ Discourse.DiscoveryTopCategoryRoute = Discourse.Route.extend(Discourse.OpenCompo
|
|||||||
actions: {
|
actions: {
|
||||||
|
|
||||||
createTopic: function() {
|
createTopic: function() {
|
||||||
this.openComposer(this.controllerFor('discoveryTop'));
|
this.openComposer(this.controllerFor('discovery/top'));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -115,3 +115,4 @@ qHint.sendRequest = function (url, callback) {
|
|||||||
<%= jshint("#{Rails.root}/test/**/*.js", "test/javascripts/") %>
|
<%= jshint("#{Rails.root}/test/**/*.js", "test/javascripts/") %>
|
||||||
<%= jshint("#{Rails.root}/app/assets/javascripts/**/*.js", "app/assets/javascripts/") %>
|
<%= jshint("#{Rails.root}/app/assets/javascripts/**/*.js", "app/assets/javascripts/") %>
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user