FIX: share selected tags between tag-chooser in preferences

This commit is contained in:
Joffrey JAFFEUX 2018-03-14 16:01:44 +01:00 committed by GitHub
parent 8027096c09
commit fd7308e7f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 5 deletions

View File

@ -10,7 +10,7 @@ export default Ember.Controller.extend(PreferencesTabController, {
'watching_first_post_tags'
],
@computed("model.watched_tags", "model.watching_first_post_tags", "model.tracked_tags", "model.muted_tags")
@computed("model.watched_tags.[]", "model.watching_first_post_tags.[]", "model.tracked_tags.[]", "model.muted_tags.[]")
selectedTags(watched, watchedFirst, tracked, muted) {
return [].concat(watched, watchedFirst, tracked, muted).filter(t => t);
},

View File

@ -11,6 +11,7 @@ export default MultiSelectComponent.extend(Tags, {
filterable: true,
filterPlaceholder: "tagging.choose_for_topic",
limit: null,
blacklist: null,
attributeBindings: ["categoryId"],
allowAny: Ember.computed.alias("allowCreate"),
@ -21,6 +22,10 @@ export default MultiSelectComponent.extend(Tags, {
this.set("allowCreate", this.site.get("can_create_tag"));
}
if (!this.get("blacklist")) {
this.set("blacklist", []);
}
this.set("termMatchesForbidden", false);
this.set("templateForRow", (rowComponent) => {
@ -57,9 +62,7 @@ export default MultiSelectComponent.extend(Tags, {
},
onExpand() {
if (isEmpty(this.get("collectionComputedContent"))) {
this.set("searchDebounce", run.debounce(this, this.prepareSearch, this.get("filter"), 200));
}
this.set("searchDebounce", run.debounce(this, this.prepareSearch, this.get("filter"), 200));
},
onDeselect() {
@ -79,7 +82,12 @@ export default MultiSelectComponent.extend(Tags, {
limit: this.get("siteSettings.max_tag_search_results"),
categoryId: this.get("categoryId")
};
if (selectedTags) data.selected_tags = selectedTags.slice(0, 100);
if (selectedTags.length || this.get("blacklist").length) {
data.selected_tags = _.uniq(selectedTags.concat(this.get("blacklist")))
.slice(0, 100);
}
if (!this.get("everyTag")) data.filterForInput = true;
this.searchTags("/tags/filter/search", data, this._transformJson);