Merge pull request #4387 from gdpelican/feature/tags-intersection

FEATURE: Tags intersection page
This commit is contained in:
Neil Lalonde
2016-08-15 16:24:29 -04:00
committed by GitHub
9 changed files with 92 additions and 11 deletions
@@ -43,6 +43,7 @@ export default Ember.Controller.extend(BulkTopicSelection, {
needs: ["application"],
tag: null,
additionalTags: null,
list: null,
canAdminTag: Ember.computed.alias("currentUser.staff"),
filterMode: null,
@@ -72,8 +73,8 @@ export default Ember.Controller.extend(BulkTopicSelection, {
}.property(),
showAdminControls: function() {
return this.get('canAdminTag') && !this.get('category');
}.property('canAdminTag', 'category'),
return this.get('additionalTags') && this.get('canAdminTag') && !this.get('category');
}.property('additionalTags', 'canAdminTag', 'category'),
loadMoreTopics() {
return this.get("list").loadMore();
@@ -132,6 +132,7 @@ export default function() {
this.route('showCategory' + filter.capitalize(), {path: '/c/:category/:tag_id/l/' + filter});
this.route('showParentCategory' + filter.capitalize(), {path: '/c/:parent_category/:category/:tag_id/l/' + filter});
});
this.route('show', {path: 'intersection/:tag_id/*additional_tags'});
});
this.resource('tagGroups', {path: '/tag_groups'}, function() {
@@ -14,6 +14,12 @@ export default Discourse.Route.extend({
var tag = this.store.createRecord("tag", { id: Handlebars.Utils.escapeExpression(params.tag_id) }),
f = '';
if (params.additional_tags) {
this.set("additionalTags", params.additional_tags.split('/').map((t) => {
return this.store.createRecord("tag", { id: Handlebars.Utils.escapeExpression(t) }).id;
}));
}
if (params.category) {
f = 'c/';
if (params.parent_category) { f += params.parent_category + '/'; }
@@ -56,6 +62,9 @@ export default Discourse.Route.extend({
}
this.set('category', category);
} else if (this.get("additionalTags")) {
params.filter = `tags/intersection/${tag_id}/${this.get('additionalTags').join('/')}`;
this.set('category', null);
} else {
params.filter = `tags/${tag_id}/l/${filter}`;
this.set('category', null);
@@ -94,6 +103,7 @@ export default Discourse.Route.extend({
this.controllerFor('tags.show').setProperties({
model,
tag: model,
additionalTags: this.get('additionalTags'),
category: this.get('category'),
filterMode: this.get('filterMode'),
navMode: this.get('navMode'),
@@ -123,7 +133,7 @@ export default Discourse.Route.extend({
// Pre-fill the tags input field
if (controller.get('model.id')) {
var c = self.controllerFor('composer').get('model');
c.set('tags', [controller.get('model.id')]);
c.set('tags', _.flatten([controller.get('model.id')], controller.get('additionalTags')));
}
});
},
@@ -5,8 +5,10 @@
<div class="list-controls">
<div class="container">
{{#if tagNotification}}
{{tag-notifications-button action="changeTagNotification"
notificationLevel=tagNotification.notification_level}}
{{#unless additionalTags}}
{{tag-notifications-button action="changeTagNotification"
notificationLevel=tagNotification.notification_level}}
{{/unless}}
{{/if}}
{{#if showAdminControls}}
@@ -31,6 +33,10 @@
{{#link-to 'tags'}}{{i18n "tagging.tags"}}{{/link-to}}
{{fa-icon "angle-right"}}
{{discourse-tag-bound tagRecord=tag style="simple"}}
{{#each additionalTags as |tag|}}
<span>&amp;</span>
{{discourse-tag-bound tagRecord=tag style="simple"}}
{{/each}}
</h2>
{{/if}}
</div>