ES6: More controllers
This commit is contained in:
parent
29fa2d2fc2
commit
8a24a34b1b
|
@ -0,0 +1,3 @@
|
|||
import NavigationDefaultController from 'discourse/controllers/navigation/default';
|
||||
|
||||
export default NavigationDefaultController.extend({});
|
|
@ -0,0 +1,8 @@
|
|||
import NavigationDefaultController from 'discourse/controllers/navigation/default';
|
||||
|
||||
export default NavigationDefaultController.extend({
|
||||
navItems: function() {
|
||||
return Discourse.NavItem.buildList(this.get('category'), { noSubcategories: this.get('noSubcategories') });
|
||||
}.property('category', 'noSubcategories')
|
||||
});
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
/**
|
||||
Handles the controller for the default navigation within discovery.
|
||||
|
||||
@class NavigationDefaultController
|
||||
@extends Discourse.Controller
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
export default Discourse.Controller.extend({
|
||||
categories: function() {
|
||||
return Discourse.Category.list();
|
||||
}.property(),
|
||||
|
||||
navItems: function() {
|
||||
return Discourse.NavItem.buildList();
|
||||
}.property()
|
||||
});
|
|
@ -1,25 +0,0 @@
|
|||
/**
|
||||
Handles the controller for the default navigation within discovery.
|
||||
|
||||
@class NavigationDefaultController
|
||||
@extends Discourse.Controller
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.NavigationDefaultController = Discourse.Controller.extend({
|
||||
categories: function() {
|
||||
return Discourse.Category.list();
|
||||
}.property(),
|
||||
|
||||
navItems: function() {
|
||||
return Discourse.NavItem.buildList();
|
||||
}.property()
|
||||
});
|
||||
|
||||
Discourse.NavigationCategoryController = Discourse.NavigationDefaultController.extend({
|
||||
navItems: function() {
|
||||
return Discourse.NavItem.buildList(this.get('category'), { noSubcategories: this.get('noSubcategories') });
|
||||
}.property('category', 'noSubcategories')
|
||||
});
|
||||
|
||||
Discourse.NavigationCategoriesController = Discourse.NavigationDefaultController.extend({});
|
|
@ -0,0 +1,20 @@
|
|||
/**
|
||||
Modal displayed to a user when they are not active yet.
|
||||
|
||||
@class NotActivatedController
|
||||
@extends Discourse.Controller
|
||||
@namespace Discourse
|
||||
@uses Discourse.ModalFunctionality
|
||||
@module Discourse
|
||||
**/
|
||||
export default Discourse.Controller.extend(Discourse.ModalFunctionality, {
|
||||
emailSent: false,
|
||||
|
||||
actions: {
|
||||
sendActivationEmail: function() {
|
||||
Discourse.ajax('/users/' + this.get('username') + '/send_activation_email', {type: 'POST'});
|
||||
this.set('emailSent', true);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
|
@ -1,18 +0,0 @@
|
|||
/**
|
||||
Modal displayed to a user when they are not active yet.
|
||||
|
||||
@class NotActivatedController
|
||||
@extends Discourse.Controller
|
||||
@namespace Discourse
|
||||
@uses Discourse.ModalFunctionality
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.NotActivatedController = Discourse.Controller.extend(Discourse.ModalFunctionality, {
|
||||
emailSent: false,
|
||||
|
||||
sendActivationEmail: function() {
|
||||
Discourse.ajax('/users/' + this.get('username') + '/send_activation_email', {type: 'POST'});
|
||||
this.set('emailSent', true);
|
||||
}
|
||||
|
||||
});
|
|
@ -7,7 +7,7 @@
|
|||
@uses Discourse.ModalFunctionality
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.SplitTopicController = Discourse.ObjectController.extend(Discourse.SelectedPostsCount, Discourse.ModalFunctionality, {
|
||||
export default Discourse.ObjectController.extend(Discourse.SelectedPostsCount, Discourse.ModalFunctionality, {
|
||||
needs: ['topic'],
|
||||
|
||||
topicController: Em.computed.alias('controllers.topic'),
|
|
@ -13,7 +13,7 @@ Discourse.DiscoveryCategoriesRoute = Discourse.Route.extend({
|
|||
},
|
||||
|
||||
beforeModel: function() {
|
||||
this.controllerFor('navigationCategories').set('filterMode', 'categories');
|
||||
this.controllerFor('navigation/categories').set('filterMode', 'categories');
|
||||
},
|
||||
|
||||
model: function() {
|
||||
|
@ -34,7 +34,7 @@ Discourse.DiscoveryCategoriesRoute = Discourse.Route.extend({
|
|||
setupController: function(controller, model) {
|
||||
controller.set('model', model);
|
||||
Discourse.set('title', I18n.t('filters.categories.title'));
|
||||
this.controllerFor('navigationCategories').set('canCreateCategory', model.get('can_create_category'));
|
||||
this.controllerFor('navigation/categories').set('canCreateCategory', model.get('can_create_category'));
|
||||
},
|
||||
|
||||
actions: {
|
||||
|
|
|
@ -12,7 +12,7 @@ function buildTopicRoute(filter) {
|
|||
},
|
||||
|
||||
beforeModel: function() {
|
||||
this.controllerFor('navigationDefault').set('filterMode', filter);
|
||||
this.controllerFor('navigation/default').set('filterMode', filter);
|
||||
},
|
||||
|
||||
model: function(data, transaction) {
|
||||
|
@ -73,7 +73,7 @@ function buildTopicRoute(filter) {
|
|||
}
|
||||
}
|
||||
|
||||
this.controllerFor('navigationDefault').set('canCreateTopic', model.get('can_create_topic'));
|
||||
this.controllerFor('navigation/default').set('canCreateTopic', model.get('can_create_topic'));
|
||||
},
|
||||
|
||||
renderTemplate: function() {
|
||||
|
@ -107,7 +107,7 @@ function buildCategoryRoute(filter, params) {
|
|||
var opts = { category: model, filterMode: filterMode };
|
||||
opts.noSubcategories = params && params.no_subcategories;
|
||||
opts.canEditCategory = Discourse.User.currentProp('staff');
|
||||
this.controllerFor('navigationCategory').setProperties(opts);
|
||||
this.controllerFor('navigation/category').setProperties(opts);
|
||||
|
||||
return Discourse.TopicList.list(listFilter, params).then(function(list) {
|
||||
var tracking = Discourse.TopicTrackingState.current();
|
||||
|
@ -130,7 +130,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('navigation/category').set('canCreateTopic', topics.get('can_create_topic'));
|
||||
this.controllerFor('discovery/topics').setProperties({
|
||||
model: topics,
|
||||
category: model,
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
**/
|
||||
Discourse.DiscoveryTopRoute = Discourse.Route.extend(Discourse.OpenComposer, {
|
||||
beforeModel: function() {
|
||||
this.controllerFor('navigationDefault').set('filterMode', 'top');
|
||||
this.controllerFor('navigation/default').set('filterMode', 'top');
|
||||
},
|
||||
|
||||
model: function() {
|
||||
|
@ -19,7 +19,7 @@ Discourse.DiscoveryTopRoute = Discourse.Route.extend(Discourse.OpenComposer, {
|
|||
var filterText = I18n.t('filters.top.title');
|
||||
Discourse.set('title', I18n.t('filters.with_topics', {filter: filterText}));
|
||||
this.controllerFor('discovery/top').setProperties({ model: model, category: null });
|
||||
this.controllerFor('navigationDefault').set('canCreateTopic', model.get('can_create_topic'));
|
||||
this.controllerFor('navigation/default').set('canCreateTopic', model.get('can_create_topic'));
|
||||
|
||||
// If there's a draft, open the create topic composer
|
||||
if (model.draft) {
|
||||
|
@ -70,7 +70,7 @@ Discourse.DiscoveryTopCategoryRoute = Discourse.Route.extend(Discourse.OpenCompo
|
|||
var opts = { category: model, filterMode: filterMode };
|
||||
opts.noSubcategories = noSubcategories;
|
||||
opts.canEditCategory = Discourse.User.currentProp('staff');
|
||||
this.controllerFor('navigationCategory').setProperties(opts);
|
||||
this.controllerFor('navigation/category').setProperties(opts);
|
||||
|
||||
return Discourse.TopList.find(filterMode).then(function(list) {
|
||||
// If all the categories are the same, we can hide them
|
||||
|
@ -89,7 +89,7 @@ Discourse.DiscoveryTopCategoryRoute = Discourse.Route.extend(Discourse.OpenCompo
|
|||
var topList = this.get('topList');
|
||||
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('navigation/category').set('canCreateTopic', topList.get('can_create_topic'));
|
||||
this.controllerFor('discovery/top').setProperties({
|
||||
model: topList,
|
||||
category: model,
|
||||
|
|
|
@ -69,7 +69,7 @@ Discourse.TopicRoute = Discourse.Route.extend({
|
|||
},
|
||||
|
||||
splitTopic: function() {
|
||||
Discourse.Route.showModal(this, 'splitTopic', this.modelFor('topic'));
|
||||
Discourse.Route.showModal(this, 'split-topic', this.modelFor('topic'));
|
||||
},
|
||||
|
||||
changeOwner: function() {
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
//= require ./discourse/models/composer
|
||||
//= require ./discourse/controllers/controller
|
||||
//= require ./discourse/controllers/object_controller
|
||||
//= require ./discourse/controllers/navigation/default
|
||||
//= require ./discourse/views/modal/modal_body_view
|
||||
//= require ./discourse/views/modal/flag_view
|
||||
//= require ./discourse/views/combobox_view
|
||||
|
|
Loading…
Reference in New Issue