Merge pull request #2245 from ligthyear/category-double-selection-fix

Bugfix: double selection of categories in user preferences
This commit is contained in:
Régis Hanol 2014-04-10 10:52:57 +02:00
commit d0591c18f8
3 changed files with 9 additions and 4 deletions

View File

@ -11,6 +11,7 @@ Discourse.CategoryGroupComponent = Ember.Component.extend({
return Discourse.Category.list().filter(function(category){
var regex = new RegExp(term, "i");
return category.get("name").match(regex) &&
!_.contains(self.get('blacklist') || [], category) &&
!_.contains(self.get('categories'), category) ;
});
},

View File

@ -15,6 +15,10 @@ Discourse.PreferencesController = Discourse.ObjectController.extend({
return Discourse.SiteSettings.allow_user_locale;
}.property(),
selectedCategories: function(){
return [].concat(this.get("watchedCategories"), this.get("trackedCategories"), this.get("mutedCategories"));
}.property("watchedCategories", "trackedCategories", "mutedCategories"),
// By default we haven't saved anything
saved: false,

View File

@ -187,17 +187,17 @@
<label class="control-label">{{i18n user.categories_settings}}</label>
<div class="controls category-controls">
<label>{{i18n user.watched_categories}}</label>
{{category-group categories=watchedCategories}}
{{category-group categories=watchedCategories blacklist=selectedCategories}}
</div>
<div class="instructions">{{i18n user.watched_categories_instructions}}</div>
<div class="controls category-controls">
<label>{{i18n user.tracked_categories}}</label>
{{category-group categories=trackedCategories}}
{{category-group categories=trackedCategories blacklist=selectedCategories}}
</div>
<div class="instructions">{{i18n user.tracked_categories_instructions}}</div>
<div class="controls category-controls">
<label>{{i18n user.muted_categories}}</label>
{{category-group categories=mutedCategories}}
{{category-group categories=mutedCategories blacklist=selectedCategories}}
</div>
<div class="instructions">{{i18n user.muted_categories_instructions}}</div>
</div>