mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 20:36:39 +08:00
FEATURE: added UI for tracking categories
This commit is contained in:
parent
3a2ae0061b
commit
f91163e146
|
@ -181,8 +181,9 @@ Discourse.User = Discourse.Model.extend({
|
|||
'external_links_in_new_tab',
|
||||
'watch_new_topics',
|
||||
'enable_quoting');
|
||||
data.watched_category_ids = this.get('watchedCategories').map(function(c){ return c.get('id')});
|
||||
data.muted_category_ids = this.get('mutedCategories').map(function(c){ return c.get('id')});
|
||||
_.each(['muted','watched','tracked'], function(s){
|
||||
data[s + '_category_ids'] = user.get(s + 'Categories').map(function(c){ return c.get('id')});
|
||||
});
|
||||
|
||||
return Discourse.ajax("/users/" + this.get('username_lower'), {
|
||||
data: data,
|
||||
|
@ -362,6 +363,12 @@ Discourse.User = Discourse.Model.extend({
|
|||
}));
|
||||
}.observes("muted_category_ids"),
|
||||
|
||||
updateTrackedCategories: function() {
|
||||
this.set("trackedCategories", _.map(this.tracked_category_ids, function(id){
|
||||
return Discourse.Category.findById(id);
|
||||
}));
|
||||
}.observes("tracked_category_ids"),
|
||||
|
||||
updateWatchedCategories: function() {
|
||||
this.set("watchedCategories", _.map(this.watched_category_ids, function(id){
|
||||
return Discourse.Category.findById(id);
|
||||
|
|
|
@ -141,6 +141,11 @@
|
|||
{{category-group categories=watchedCategories}}
|
||||
<div class="instructions">{{i18n user.watched_categories_instructions}}</div>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<label>{{i18n user.tracked_categories}}</label>
|
||||
{{category-group categories=trackedCategories}}
|
||||
<div class="instructions">{{i18n user.tracked_categories_instructions}}</div>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<label>{{i18n user.muted_categories}}</label>
|
||||
{{category-group categories=mutedCategories}}
|
||||
|
|
|
@ -62,6 +62,7 @@ class UserSerializer < BasicUserSerializer
|
|||
:gravatar_template,
|
||||
:uploaded_avatar_template,
|
||||
:muted_category_ids,
|
||||
:tracked_category_ids,
|
||||
:watched_category_ids
|
||||
|
||||
|
||||
|
@ -112,6 +113,10 @@ class UserSerializer < BasicUserSerializer
|
|||
CategoryUser.lookup(object, :muted).pluck(:category_id)
|
||||
end
|
||||
|
||||
def tracked_category_ids
|
||||
CategoryUser.lookup(object, :tracking).pluck(:category_id)
|
||||
end
|
||||
|
||||
def watched_category_ids
|
||||
CategoryUser.lookup(object, :watching).pluck(:category_id)
|
||||
end
|
||||
|
|
|
@ -15,6 +15,10 @@ class UserUpdater
|
|||
CategoryUser.batch_set(user, :watching, ids)
|
||||
end
|
||||
|
||||
if ids = attributes[:tracked_category_ids]
|
||||
CategoryUser.batch_set(user, :tracking, ids)
|
||||
end
|
||||
|
||||
if ids = attributes[:muted_category_ids]
|
||||
CategoryUser.batch_set(user, :muted, ids)
|
||||
end
|
||||
|
|
|
@ -230,6 +230,8 @@ en:
|
|||
watch_new_topics: "Automatically watch all new topics posted on the forum"
|
||||
watched_categories: "Watched"
|
||||
watched_categories_instructions: "You will automatically watch all topics in these categories"
|
||||
tracked_categories: "Tracked"
|
||||
tracked_categories_instructions: "You will automatically recieve notifications for topics in these categories"
|
||||
muted_categories: "Muted"
|
||||
muted_categories_instructions: "You will automatically mute all topics in these categories"
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user