FIX: do not display used categories as selectable in categories notifications preferences

This commit is contained in:
Joffrey JAFFEUX 2017-12-14 14:40:08 +01:00 committed by GitHub
parent 5e1545fb7f
commit 3090c016d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 9 deletions

View File

@ -1,5 +1,6 @@
import PreferencesTabController from "discourse/mixins/preferences-tab-controller";
import { popupAjaxError } from 'discourse/lib/ajax-error';
import { default as computed } from "ember-addons/ember-computed-decorators";
export default Ember.Controller.extend(PreferencesTabController, {
saveAttrNames: [
@ -9,6 +10,11 @@ export default Ember.Controller.extend(PreferencesTabController, {
'watched_first_post_category_ids'
],
@computed("model.watchedCategories", "model.watchedFirstPostCategories", "model.trackedCategories", "model.mutedCategories")
selectedCategories(watched, watchedFirst, tracked, muted) {
return [].concat(watched, watchedFirst, tracked, muted);
},
canSave: function() {
return this.get('currentUser.id') === this.get('model.id') ||
this.get('currentUser.admin');

View File

@ -1,5 +1,4 @@
import PreferencesTabController from "discourse/mixins/preferences-tab-controller";
import { default as computed } from "ember-addons/ember-computed-decorators";
import { NotificationLevels } from 'discourse/lib/notification-levels';
import { popupAjaxError } from 'discourse/lib/ajax-error';
@ -14,11 +13,6 @@ export default Ember.Controller.extend(PreferencesTabController, {
'allow_private_messages',
],
@computed("model.watchedCategories", "model.trackedCategories", "model.mutedCategories")
selectedCategories(watched, tracked, muted) {
return [].concat(watched, tracked, muted);
},
likeNotificationFrequencies: [{ name: I18n.t('user.like_notification_frequency.always'), value: 0 },
{ name: I18n.t('user.like_notification_frequency.first_time_and_daily'), value: 1 },
{ name: I18n.t('user.like_notification_frequency.first_time'), value: 2 },

View File

@ -1,5 +1,4 @@
<div class="control-group category-notifications">
<label class="control-label">{{i18n 'user.categories_settings'}}</label>
<div class="controls category-controls">
@ -22,7 +21,7 @@
<div class="controls category-controls">
<label>{{d-icon "d-watching-first"}} {{i18n 'user.watched_first_post_categories'}}</label>
{{category-selector categories=model.watchedFirstPostCategories}}
{{category-selector categories=model.watchedFirstPostCategories blacklist=selectedCategories}}
</div>
<div class="instructions">{{i18n 'user.watched_first_post_categories_instructions'}}</div>

View File

@ -35,6 +35,9 @@ export default MultiSelectComponent.extend({
computeContent() {
const blacklist = Ember.makeArray(this.get("blacklist"));
return Category.list().filter(category => !blacklist.includes(category));
return Category.list().filter(category => {
return this.get("computedValues").includes(category.id) ||
!blacklist.includes(category);
});
}
});