FEATURE: replace PM tags dropdown with a dedicated tags page
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
export default Ember.Component.extend({
|
||||
classNameBindings: [':tag-list', 'categoryClass'],
|
||||
|
||||
isPrivateMessage: false,
|
||||
sortedTags: Ember.computed.sort('tags', 'sortProperties'),
|
||||
|
||||
title: function() {
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
export default Ember.Controller.extend({
|
||||
sortProperties: ['count:desc', 'id'],
|
||||
|
||||
actions: {
|
||||
sortByCount() {
|
||||
this.set('sortProperties', ['count:desc', 'id']);
|
||||
},
|
||||
|
||||
sortById() {
|
||||
this.set('sortProperties', ['id']);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -12,7 +12,7 @@ export default Ember.Controller.extend({
|
||||
currentPath: Em.computed.alias('application.currentPath'),
|
||||
selected: Em.computed.alias('userTopicsList.selected'),
|
||||
bulkSelectEnabled: Em.computed.alias('userTopicsList.bulkSelectEnabled'),
|
||||
pmTags: Em.computed.alias('userTopicsList.model.topic_list.pm_tags'),
|
||||
showToggleBulkSelect: true,
|
||||
pmTaggingEnabled: Ember.computed.alias('site.can_tag_pms'),
|
||||
tagId: null,
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ export default function renderTag(tag, params) {
|
||||
let path;
|
||||
if (tagName === "a" && !params.noHref) {
|
||||
const current_user = Discourse.User.current();
|
||||
path = params.isPrivateMessage ? `/u/${current_user.username}/messages/tag/${tag}` : `/tags/${tag}`;
|
||||
path = params.isPrivateMessage ? `/u/${current_user.username}/messages/tags/${tag}` : `/tags/${tag}`;
|
||||
}
|
||||
const href = path ? ` href='${Discourse.getURL(path)}' ` : "";
|
||||
|
||||
|
||||
@@ -96,7 +96,8 @@ export default function() {
|
||||
this.route('archive');
|
||||
this.route('group', { path: 'group/:name'});
|
||||
this.route('groupArchive', { path: 'group/:name/archive'});
|
||||
this.route('tag', { path: 'tag/:id'});
|
||||
this.route('tags');
|
||||
this.route('tagsShow', { path: 'tags/:id'});
|
||||
});
|
||||
|
||||
this.route('preferences', { resetNamespace: true }, function() {
|
||||
|
||||
@@ -35,8 +35,12 @@ export default (viewName, path, channel) => {
|
||||
selected: []
|
||||
});
|
||||
|
||||
this.controllerFor("user-private-messages").set("archive", false);
|
||||
this.controllerFor("user-private-messages").set("pmView", viewName);
|
||||
this.controllerFor("user-private-messages").setProperties({
|
||||
archive: false,
|
||||
pmView: viewName,
|
||||
showToggleBulkSelect: true
|
||||
});
|
||||
|
||||
this.searchService.set('contextType', 'private_messages');
|
||||
},
|
||||
|
||||
|
||||
+1
-2
@@ -2,10 +2,9 @@ import createPMRoute from "discourse/routes/build-private-messages-route";
|
||||
|
||||
export default createPMRoute('tags', 'private-messages-tags').extend({
|
||||
model(params) {
|
||||
this.controllerFor('user-private-messages').set('tagId', params.id);
|
||||
const username = this.modelFor("user").get("username_lower");
|
||||
return this.store.findFiltered("topicList", {
|
||||
filter: `topics/private-messages-tag/${username}/${params.id}`
|
||||
filter: `topics/private-messages-tags/${username}/${params.id}`
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,22 @@
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
import { popupAjaxError } from 'discourse/lib/ajax-error';
|
||||
|
||||
export default Discourse.Route.extend({
|
||||
model() {
|
||||
return ajax('/tags/personal_messages').then(result => {
|
||||
return result.tags.map(tag => Ember.Object.create(tag));
|
||||
}).catch(popupAjaxError);
|
||||
},
|
||||
|
||||
titleToken() {
|
||||
return [I18n.t("tagging.tags"), I18n.t("user.private_messages")];
|
||||
},
|
||||
|
||||
setupController(controller, model) {
|
||||
this.controllerFor('user-private-messages-tags').setProperties({
|
||||
model,
|
||||
sortProperties: this.siteSettings.tags_sort_alphabetically ? ['id'] : ['count:desc', 'id']
|
||||
});
|
||||
this.controllerFor("user-private-messages").set("showToggleBulkSelect", false);
|
||||
}
|
||||
});
|
||||
@@ -10,7 +10,7 @@
|
||||
{{#each sortedTags as |tag|}}
|
||||
<div class='tag-box'>
|
||||
{{#if tag.count}}
|
||||
{{discourse-tag tag.id}} <span class='tag-count'>x {{tag.count}}</span>
|
||||
{{discourse-tag tag.id isPrivateMessage=isPrivateMessage}} <span class='tag-count'>x {{tag.count}}</span>
|
||||
{{else}}
|
||||
{{discourse-tag tag.id}}
|
||||
{{/if}}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<div class="list-controls">
|
||||
<div class="container">
|
||||
<h2>{{i18n "tagging.tags"}}</h2>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class='tag-sort-options'>
|
||||
{{i18n "tagging.sort_by"}}
|
||||
<a {{action "sortByCount"}}>{{i18n "tagging.sort_by_count"}}</a>
|
||||
<a {{action "sortById"}}>{{i18n "tagging.sort_by_name"}}</a>
|
||||
</div>
|
||||
|
||||
<hr/>
|
||||
|
||||
{{#if model}}
|
||||
{{tag-list tags=model sortProperties=sortProperties titleKey="tagging.all_tags" isPrivateMessage=true}}
|
||||
{{/if}}
|
||||
@@ -23,29 +23,39 @@
|
||||
</li>
|
||||
{{plugin-outlet name="user-messages-nav" connectorTagName='li' args=(hash model=model)}}
|
||||
{{#each model.groups as |group|}}
|
||||
{{#if group.has_messages}}
|
||||
<li>
|
||||
{{#link-to 'userPrivateMessages.group' group.name}}
|
||||
{{d-icon "group" class="glyph"}}
|
||||
{{capitalize-string group.name}}
|
||||
{{/link-to}}
|
||||
</li>
|
||||
<li class='archive'>
|
||||
{{#link-to 'userPrivateMessages.groupArchive' group.name}}
|
||||
{{i18n 'user.messages.archive'}}
|
||||
{{#if group.has_messages}}
|
||||
<li>
|
||||
{{#link-to 'userPrivateMessages.group' group.name}}
|
||||
{{d-icon "group" class="glyph"}}
|
||||
{{capitalize-string group.name}}
|
||||
{{/link-to}}
|
||||
</li>
|
||||
<li class='archive'>
|
||||
{{#link-to 'userPrivateMessages.groupArchive' group.name}}
|
||||
{{i18n 'user.messages.archive'}}
|
||||
{{/link-to}}
|
||||
</li>
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
|
||||
{{#if pmTaggingEnabled}}
|
||||
<li class="noGlyph">
|
||||
{{#link-to 'userPrivateMessages.tags' model}}
|
||||
{{i18n 'user.messages.tags'}}
|
||||
{{/link-to}}
|
||||
</li>
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
{{/mobile-nav}}
|
||||
{{/d-section}}
|
||||
|
||||
<section class='user-right messages'>
|
||||
|
||||
<div class="clearfix list-actions">
|
||||
<button {{action "toggleBulkSelect"}} class="btn bulk-select" title="{{i18n "user.messages.bulk_select"}}">
|
||||
{{d-icon "list"}}
|
||||
</button>
|
||||
{{#if showToggleBulkSelect}}
|
||||
<button {{action "toggleBulkSelect"}} class="btn bulk-select" title="{{i18n "user.messages.bulk_select"}}">
|
||||
{{d-icon "list"}}
|
||||
</button>
|
||||
{{/if}}
|
||||
|
||||
{{#if site.mobileView}}
|
||||
{{#if showNewPM}}
|
||||
@@ -74,10 +84,6 @@
|
||||
{{#if isGroup}}
|
||||
{{group-notifications-button value=group.group_user.notification_level group=group user=model}}
|
||||
{{/if}}
|
||||
|
||||
{{#if pmTaggingEnabled}}
|
||||
{{pm-tag-drop pmTags=pmTags tagId=tagId}}
|
||||
{{/if}}
|
||||
</div>
|
||||
|
||||
{{outlet}}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
import TagDropComponent from "select-kit/components/tag-drop";
|
||||
import DiscourseURL from "discourse/lib/url";
|
||||
import { default as computed } from "ember-addons/ember-computed-decorators";
|
||||
|
||||
export default TagDropComponent.extend({
|
||||
@computed
|
||||
allTagsUrl() {
|
||||
return `/u/${this.currentUser.username}/messages/`;
|
||||
},
|
||||
|
||||
content: Ember.computed.alias("pmTags"),
|
||||
|
||||
actions: {
|
||||
onSelect(tagId) {
|
||||
const url = `/u/${this.currentUser.username}/messages/tag/${tagId}`;
|
||||
DiscourseURL.routeTo(url);
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user