mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
ES6: More controllers converted to ES6
This commit is contained in:
parent
4640b9d653
commit
a0221ce5e5
13 changed files with 34 additions and 34 deletions
|
@ -6,7 +6,7 @@
|
|||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.DiscoveryCategoriesController = Discourse.DiscoveryController.extend({
|
||||
export default Discourse.DiscoveryController.extend({
|
||||
needs: ['modal', 'discovery'],
|
||||
|
||||
actions: {
|
|
@ -6,7 +6,7 @@
|
|||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.DiscoveryTopController = Discourse.DiscoveryController.extend({
|
||||
export default Discourse.DiscoveryController.extend({
|
||||
needs: ['discovery'],
|
||||
|
||||
actions: {
|
|
@ -6,7 +6,7 @@
|
|||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.DiscoveryTopicsController = Discourse.DiscoveryController.extend({
|
||||
export default Discourse.DiscoveryController.extend({
|
||||
needs: ['discovery'],
|
||||
bulkSelectEnabled: false,
|
||||
selected: [],
|
|
@ -1,6 +1,6 @@
|
|||
Discourse.DiscoverySortableController = Discourse.Controller.extend({
|
||||
needs: ['discoveryTopics'],
|
||||
needs: ['discovery/topics'],
|
||||
queryParams: ['order', 'ascending'],
|
||||
order: Em.computed.alias('controllers.discoveryTopics.order'),
|
||||
ascending: Em.computed.alias('controllers.discoveryTopics.ascending')
|
||||
order: Em.computed.alias('controllers.discovery/topics.order'),
|
||||
ascending: Em.computed.alias('controllers.discovery/topics.ascending')
|
||||
});
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
@uses Discourse.ModalFunctionality
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.EditCategoryController = Discourse.ObjectController.extend(Discourse.ModalFunctionality, {
|
||||
export default Discourse.ObjectController.extend(Discourse.ModalFunctionality, {
|
||||
generalSelected: Ember.computed.equal('selectedTab', 'general'),
|
||||
securitySelected: Ember.computed.equal('selectedTab', 'security'),
|
||||
settingsSelected: Ember.computed.equal('selectedTab', 'settings'),
|
|
@ -7,8 +7,7 @@
|
|||
@uses Discourse.ModalFunctionality
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.EditTopicAutoCloseController = Discourse.ObjectController.extend(Discourse.ModalFunctionality, {
|
||||
|
||||
export default Discourse.ObjectController.extend(Discourse.ModalFunctionality, {
|
||||
auto_close_valid: true,
|
||||
auto_close_invalid: Em.computed.not('auto_close_valid'),
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
@module Discourse
|
||||
**/
|
||||
Discourse.TopicBulkActionsController = Ember.ArrayController.extend(Discourse.ModalFunctionality, {
|
||||
needs: ['discoveryTopics'],
|
||||
needs: ['discovery/topics'],
|
||||
|
||||
onShow: function() {
|
||||
this.set('controllers.modal.modalClass', 'topic-bulk-actions-modal small');
|
||||
|
@ -45,7 +45,7 @@ Discourse.TopicBulkActionsController = Ember.ArrayController.extend(Discourse.Mo
|
|||
performAndRefresh: function(operation) {
|
||||
var self = this;
|
||||
return this.perform(operation).then(function() {
|
||||
self.get('controllers.discoveryTopics').send('refresh');
|
||||
self.get('controllers.discovery/topics').send('refresh');
|
||||
self.send('closeModal');
|
||||
});
|
||||
},
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
@module Discourse
|
||||
**/
|
||||
Discourse.TopicListItemController = Ember.ObjectController.extend({
|
||||
needs: ['discoveryTopics'],
|
||||
needs: ['discovery/topics'],
|
||||
|
||||
canStar: Em.computed.alias('controllers.discoveryTopics.currentUser.id'),
|
||||
bulkSelectEnabled: Em.computed.alias('controllers.discoveryTopics.bulkSelectEnabled'),
|
||||
canStar: Em.computed.alias('controllers.discovery/topics.currentUser.id'),
|
||||
bulkSelectEnabled: Em.computed.alias('controllers.discovery/topics.bulkSelectEnabled'),
|
||||
|
||||
checked: function(key, value) {
|
||||
var selected = this.get('controllers.discoveryTopics.selected'),
|
||||
var selected = this.get('controllers.discovery/topics.selected'),
|
||||
topic = this.get('model');
|
||||
|
||||
if (arguments.length > 1) {
|
||||
|
@ -24,17 +24,17 @@ Discourse.TopicListItemController = Ember.ObjectController.extend({
|
|||
}
|
||||
}
|
||||
return selected.contains(topic);
|
||||
}.property('controllers.discoveryTopics.selected.length'),
|
||||
}.property('controllers.discovery/topics.selected.length'),
|
||||
|
||||
titleColSpan: function() {
|
||||
// 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);
|
||||
}.property('controllers.discoveryTopics.hideCategory', 'model.isPinnedUncategorized'),
|
||||
}.property('controllers.discovery/topics.hideCategory', 'model.isPinnedUncategorized'),
|
||||
|
||||
hideCategory: function() {
|
||||
return this.get('controllers.discoveryTopics.hideCategory') || this.get('titleColSpan') > 1;
|
||||
}.property('controllers.discoveryTopics.hideCategory', 'titleColSpan'),
|
||||
return this.get('controllers.discovery/topics.hideCategory') || this.get('titleColSpan') > 1;
|
||||
}.property('controllers.discovery/topics.hideCategory', 'titleColSpan'),
|
||||
|
||||
actions: {
|
||||
toggleStar: function() {
|
||||
|
|
|
@ -195,9 +195,9 @@ Discourse.URL = Em.Object.createWithMixins({
|
|||
if (path === "/" && (oldPath === "/" || oldPath === "/" + homepage)) {
|
||||
// refresh the list
|
||||
switch (homepage) {
|
||||
case "top" : { this.controllerFor('discoveryTop').send('refresh'); break; }
|
||||
case "categories": { this.controllerFor('discoveryCategories').send('refresh'); break; }
|
||||
default: { this.controllerFor('discoveryTopics').send('refresh'); break; }
|
||||
case "top" : { this.controllerFor('discovery/top').send('refresh'); break; }
|
||||
case "categories": { this.controllerFor('discovery/categories').send('refresh'); break; }
|
||||
default: { this.controllerFor('discovery/topics').send('refresh'); break; }
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ Discourse.DiscoveryRoute = Discourse.Route.extend(Discourse.ScrollTop, Discourse
|
|||
},
|
||||
|
||||
createTopic: function() {
|
||||
this.openComposer(this.controllerFor('discoveryTopics'));
|
||||
this.openComposer(this.controllerFor('discovery/topics'));
|
||||
},
|
||||
|
||||
changeBulkTemplate: function(w) {
|
||||
|
@ -57,7 +57,7 @@ Discourse.DiscoveryRoute = Discourse.Route.extend(Discourse.ScrollTop, Discourse
|
|||
},
|
||||
|
||||
showBulkActions: function() {
|
||||
var selected = this.controllerFor('discoveryTopics').get('selected');
|
||||
var selected = this.controllerFor('discovery/topics').get('selected');
|
||||
Discourse.Route.showModal(this, 'topicBulkActions', selected);
|
||||
this.send('changeBulkTemplate', 'modal/bulk_actions_buttons');
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ function buildTopicRoute(filter) {
|
|||
Discourse.set('title', I18n.t('filters.with_topics', {filter: filterText}));
|
||||
}
|
||||
|
||||
this.controllerFor('discoveryTopics').setProperties({
|
||||
this.controllerFor('discovery/topics').setProperties({
|
||||
model: model,
|
||||
category: null,
|
||||
period: period,
|
||||
|
@ -78,7 +78,7 @@ function buildTopicRoute(filter) {
|
|||
|
||||
renderTemplate: function() {
|
||||
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() }));
|
||||
|
||||
this.controllerFor('navigationCategory').set('canCreateTopic', topics.get('can_create_topic'));
|
||||
this.controllerFor('discoveryTopics').setProperties({
|
||||
this.controllerFor('discovery/topics').setProperties({
|
||||
model: topics,
|
||||
category: model,
|
||||
period: period,
|
||||
|
@ -144,7 +144,7 @@ function buildCategoryRoute(filter, params) {
|
|||
|
||||
renderTemplate: function() {
|
||||
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() {
|
||||
|
|
|
@ -18,7 +18,7 @@ Discourse.DiscoveryTopRoute = Discourse.Route.extend(Discourse.OpenComposer, {
|
|||
setupController: function(controller, model) {
|
||||
var filterText = I18n.t('filters.top.title');
|
||||
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'));
|
||||
|
||||
// If there's a draft, open the create topic composer
|
||||
|
@ -40,7 +40,7 @@ Discourse.DiscoveryTopRoute = Discourse.Route.extend(Discourse.OpenComposer, {
|
|||
actions: {
|
||||
|
||||
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');
|
||||
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('discoveryTop').setProperties({
|
||||
this.controllerFor('discovery/top').setProperties({
|
||||
model: topList,
|
||||
category: model,
|
||||
noSubcategories: this.get('no_subcategories')
|
||||
|
@ -100,7 +100,7 @@ Discourse.DiscoveryTopCategoryRoute = Discourse.Route.extend(Discourse.OpenCompo
|
|||
|
||||
renderTemplate: function() {
|
||||
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() {
|
||||
|
@ -111,7 +111,7 @@ Discourse.DiscoveryTopCategoryRoute = Discourse.Route.extend(Discourse.OpenCompo
|
|||
actions: {
|
||||
|
||||
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}/app/assets/javascripts/**/*.js", "app/assets/javascripts/") %>
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue