FIX: do not display used categories as selectable in categories notifications preferences
This commit is contained in:
parent
5e1545fb7f
commit
3090c016d0
|
@ -1,5 +1,6 @@
|
||||||
import PreferencesTabController from "discourse/mixins/preferences-tab-controller";
|
import PreferencesTabController from "discourse/mixins/preferences-tab-controller";
|
||||||
import { popupAjaxError } from 'discourse/lib/ajax-error';
|
import { popupAjaxError } from 'discourse/lib/ajax-error';
|
||||||
|
import { default as computed } from "ember-addons/ember-computed-decorators";
|
||||||
|
|
||||||
export default Ember.Controller.extend(PreferencesTabController, {
|
export default Ember.Controller.extend(PreferencesTabController, {
|
||||||
saveAttrNames: [
|
saveAttrNames: [
|
||||||
|
@ -9,6 +10,11 @@ export default Ember.Controller.extend(PreferencesTabController, {
|
||||||
'watched_first_post_category_ids'
|
'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() {
|
canSave: function() {
|
||||||
return this.get('currentUser.id') === this.get('model.id') ||
|
return this.get('currentUser.id') === this.get('model.id') ||
|
||||||
this.get('currentUser.admin');
|
this.get('currentUser.admin');
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import PreferencesTabController from "discourse/mixins/preferences-tab-controller";
|
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 { NotificationLevels } from 'discourse/lib/notification-levels';
|
||||||
import { popupAjaxError } from 'discourse/lib/ajax-error';
|
import { popupAjaxError } from 'discourse/lib/ajax-error';
|
||||||
|
|
||||||
|
@ -14,11 +13,6 @@ export default Ember.Controller.extend(PreferencesTabController, {
|
||||||
'allow_private_messages',
|
'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 },
|
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_and_daily'), value: 1 },
|
||||||
{ name: I18n.t('user.like_notification_frequency.first_time'), value: 2 },
|
{ name: I18n.t('user.like_notification_frequency.first_time'), value: 2 },
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<div class="control-group category-notifications">
|
<div class="control-group category-notifications">
|
||||||
|
|
||||||
<label class="control-label">{{i18n 'user.categories_settings'}}</label>
|
<label class="control-label">{{i18n 'user.categories_settings'}}</label>
|
||||||
|
|
||||||
<div class="controls category-controls">
|
<div class="controls category-controls">
|
||||||
|
@ -22,7 +21,7 @@
|
||||||
|
|
||||||
<div class="controls category-controls">
|
<div class="controls category-controls">
|
||||||
<label>{{d-icon "d-watching-first"}} {{i18n 'user.watched_first_post_categories'}}</label>
|
<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>
|
||||||
<div class="instructions">{{i18n 'user.watched_first_post_categories_instructions'}}</div>
|
<div class="instructions">{{i18n 'user.watched_first_post_categories_instructions'}}</div>
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,9 @@ export default MultiSelectComponent.extend({
|
||||||
|
|
||||||
computeContent() {
|
computeContent() {
|
||||||
const blacklist = Ember.makeArray(this.get("blacklist"));
|
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);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue