Tighten up tags intersection page

This commit is contained in:
James Kiesel 2016-08-12 15:51:09 -04:00
parent 7e73b933c7
commit 3471499613
3 changed files with 19 additions and 8 deletions

View File

@ -43,6 +43,7 @@ export default Ember.Controller.extend(BulkTopicSelection, {
needs: ["application"], needs: ["application"],
tag: null, tag: null,
secondaryTag: null,
list: null, list: null,
canAdminTag: Ember.computed.alias("currentUser.staff"), canAdminTag: Ember.computed.alias("currentUser.staff"),
filterMode: null, filterMode: null,
@ -72,7 +73,7 @@ export default Ember.Controller.extend(BulkTopicSelection, {
}.property(), }.property(),
showAdminControls: function() { showAdminControls: function() {
return this.get('canAdminTag') && !this.get('category'); return !this.get('secondaryTag') && this.get('canAdminTag') && !this.get('category');
}.property('canAdminTag', 'category'), }.property('canAdminTag', 'category'),
loadMoreTopics() { loadMoreTopics() {

View File

@ -12,9 +12,12 @@ export default Discourse.Route.extend({
model(params) { model(params) {
var tag = this.store.createRecord("tag", { id: Handlebars.Utils.escapeExpression(params.tag_id) }), var tag = this.store.createRecord("tag", { id: Handlebars.Utils.escapeExpression(params.tag_id) }),
secondaryTag = null,
f = ''; f = '';
this.set("secondaryTagId", params.secondary_tag_id) if (params.secondary_tag_id) {
this.set("secondaryTag", this.store.createRecord("tag", { id: Handlebars.Utils.escapeExpression(params.secondary_tag_id) }))
}
if (params.category) { if (params.category) {
f = 'c/'; f = 'c/';
@ -45,10 +48,10 @@ export default Discourse.Route.extend({
const params = controller.getProperties('order', 'ascending'); const params = controller.getProperties('order', 'ascending');
const categorySlug = this.get('categorySlug'); const categorySlug = this.get('categorySlug');
const secondaryTagId = this.get('secondaryTagId')
const parentCategorySlug = this.get('parentCategorySlug'); const parentCategorySlug = this.get('parentCategorySlug');
const filter = this.get('navMode'); const filter = this.get('navMode');
const tag_id = (tag ? tag.id : 'none'); const tag_id = (tag ? tag.id : 'none');
const secondary_tag_id = this.get('secondaryTag.id')
if (categorySlug) { if (categorySlug) {
var category = Discourse.Category.findBySlug(categorySlug, parentCategorySlug); var category = Discourse.Category.findBySlug(categorySlug, parentCategorySlug);
@ -59,8 +62,8 @@ export default Discourse.Route.extend({
} }
this.set('category', category); this.set('category', category);
} else if (secondaryTagId) { } else if (secondary_tag_id) {
params.filter = `tags/intersection/${tag_id}/${secondaryTagId}`; params.filter = `tags/intersection/${tag_id}/${secondary_tag_id}`;
this.set('category', null); this.set('category', null);
} else { } else {
params.filter = `tags/${tag_id}/l/${filter}`; params.filter = `tags/${tag_id}/l/${filter}`;
@ -100,6 +103,7 @@ export default Discourse.Route.extend({
this.controllerFor('tags.show').setProperties({ this.controllerFor('tags.show').setProperties({
model, model,
tag: model, tag: model,
secondaryTag: this.get('secondaryTag'),
category: this.get('category'), category: this.get('category'),
filterMode: this.get('filterMode'), filterMode: this.get('filterMode'),
navMode: this.get('navMode'), navMode: this.get('navMode'),
@ -129,7 +133,7 @@ export default Discourse.Route.extend({
// Pre-fill the tags input field // Pre-fill the tags input field
if (controller.get('model.id')) { if (controller.get('model.id')) {
var c = self.controllerFor('composer').get('model'); var c = self.controllerFor('composer').get('model');
c.set('tags', [controller.get('model.id')]); c.set('tags', _.compact([controller.get('model.id'), controller.get('secondaryTag.id')]));
} }
}); });
}, },

View File

@ -5,8 +5,10 @@
<div class="list-controls"> <div class="list-controls">
<div class="container"> <div class="container">
{{#if tagNotification}} {{#if tagNotification}}
{{tag-notifications-button action="changeTagNotification" {{#unless secondaryTag}}
notificationLevel=tagNotification.notification_level}} {{tag-notifications-button action="changeTagNotification"
notificationLevel=tagNotification.notification_level}}
{{/unless}}
{{/if}} {{/if}}
{{#if showAdminControls}} {{#if showAdminControls}}
@ -31,6 +33,10 @@
{{#link-to 'tags'}}{{i18n "tagging.tags"}}{{/link-to}} {{#link-to 'tags'}}{{i18n "tagging.tags"}}{{/link-to}}
{{fa-icon "angle-right"}} {{fa-icon "angle-right"}}
{{discourse-tag-bound tagRecord=tag style="simple"}} {{discourse-tag-bound tagRecord=tag style="simple"}}
{{#if secondaryTag}}
<span>&</span>
{{discourse-tag-bound tagRecord=secondaryTag style="simple"}}
{{/if}}
</h2> </h2>
{{/if}} {{/if}}
</div> </div>