mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -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'],
|
||||
|
||||
filteredContent: function() {
|
||||
if (!this.get('categoryNameKey')) { return Em.A(); }
|
||||
|
||||
var category = this.get('controllers.adminSiteSettings.content').find(function(siteSettingCategory) {
|
||||
return siteSettingCategory.nameKey === this.get('categoryNameKey');
|
||||
}, this);
|
||||
if (!this.get('categoryNameKey')) { return []; }
|
||||
|
||||
var category = this.get('controllers.adminSiteSettings.content').findProperty('nameKey', this.get('categoryNameKey'));
|
||||
if (category) {
|
||||
return category.siteSettings;
|
||||
} else {
|
||||
return Em.A();
|
||||
return [];
|
||||
}
|
||||
}.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: {
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,6 +8,13 @@
|
|||
**/
|
||||
Discourse.AdminSiteSettingsCategoryRoute = Discourse.Route.extend({
|
||||
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:
|
||||
this.controllerFor('adminSiteSettingsCategory').set('categoryNameKey', params.category_id);
|
||||
return Em.Object.create({
|
||||
|
|
Loading…
Reference in a new issue