mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
FIX: Don't lose focus on site settings text field (was changing routes
during filtering)
This commit is contained in:
parent
c7bda41dda
commit
8366fcd78f
2 changed files with 10 additions and 16 deletions
|
@ -3,29 +3,16 @@ export default Ember.ObjectController.extend({
|
||||||
needs: ['adminSiteSettings'],
|
needs: ['adminSiteSettings'],
|
||||||
|
|
||||||
filteredContent: function() {
|
filteredContent: function() {
|
||||||
if (!this.get('categoryNameKey')) { return Em.A(); }
|
if (!this.get('categoryNameKey')) { return []; }
|
||||||
|
|
||||||
var category = this.get('controllers.adminSiteSettings.content').find(function(siteSettingCategory) {
|
|
||||||
return siteSettingCategory.nameKey === this.get('categoryNameKey');
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
|
var category = this.get('controllers.adminSiteSettings.content').findProperty('nameKey', this.get('categoryNameKey'));
|
||||||
if (category) {
|
if (category) {
|
||||||
return category.siteSettings;
|
return category.siteSettings;
|
||||||
} else {
|
} else {
|
||||||
return Em.A();
|
return [];
|
||||||
}
|
}
|
||||||
}.property('controllers.adminSiteSettings.content', 'categoryNameKey'),
|
}.property('controllers.adminSiteSettings.content', 'categoryNameKey'),
|
||||||
|
|
||||||
emptyContentHandler: function() {
|
|
||||||
if (this.get('filteredContent').length < 1) {
|
|
||||||
if ( this.get('controllers.adminSiteSettings.filtered') ) {
|
|
||||||
this.transitionToRoute('adminSiteSettingsCategory', 'all_results');
|
|
||||||
} else {
|
|
||||||
this.transitionToRoute('adminSiteSettings');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}.observes('filteredContent'),
|
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -8,6 +8,13 @@
|
||||||
**/
|
**/
|
||||||
Discourse.AdminSiteSettingsCategoryRoute = Discourse.Route.extend({
|
Discourse.AdminSiteSettingsCategoryRoute = Discourse.Route.extend({
|
||||||
model: function(params) {
|
model: function(params) {
|
||||||
|
if (params.category_id === "all_results") {
|
||||||
|
var category = this.controllerFor('adminSiteSettings').get('content').findProperty('nameKey', 'all_results');
|
||||||
|
if (!category || !category.siteSettings.length) {
|
||||||
|
this.replaceWith('adminSiteSettings.index');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
// The model depends on user input, so let the controller do the work:
|
// The model depends on user input, so let the controller do the work:
|
||||||
this.controllerFor('adminSiteSettingsCategory').set('categoryNameKey', params.category_id);
|
this.controllerFor('adminSiteSettingsCategory').set('categoryNameKey', params.category_id);
|
||||||
return Em.Object.create({
|
return Em.Object.create({
|
||||||
|
|
Loading…
Reference in a new issue