2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-06 10:50:21 +08:00

Merge pull request #5610 from discourse/pm-tags

FEATURE: Allow staffs to tag PMs
This commit is contained in:
Guo Xiang Tan 2018-02-23 07:07:41 +08:00 committed by GitHub
commit dd26bbe868
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
33 changed files with 279 additions and 158 deletions

View file

@ -140,7 +140,8 @@ export default Ember.Controller.extend({
return !this.site.mobileView &&
this.site.get('can_tag_topics') &&
canEditTitle &&
!creatingPrivateMessage;
!creatingPrivateMessage &&
(!this.get('model.topic.isPrivateMessage') || this.site.get('can_tag_pms'));
},
@computed('model.whisper', 'model.unlistTopic')

View file

@ -104,7 +104,7 @@ export default Ember.Controller.extend(BufferedContent, {
@computed('model.isPrivateMessage')
canEditTags(isPrivateMessage) {
return !isPrivateMessage && this.site.get('can_tag_topics');
return this.site.get('can_tag_topics') && (!isPrivateMessage || this.site.get('can_tag_pms'));
},
actions: {

View file

@ -3,7 +3,12 @@ export default function renderTag(tag, params) {
tag = Handlebars.Utils.escapeExpression(tag);
const classes = ['tag-' + tag, 'discourse-tag'];
const tagName = params.tagName || "a";
const href = (tagName === "a" && !params.noHref) ? " href='" + Discourse.getURL("/tags/" + tag) + "' " : "";
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}`;
}
const href = path ? ` href='${Discourse.getURL(path)}' ` : "";
if (Discourse.SiteSettings.tag_style || params.style) {
classes.push(params.style || Discourse.SiteSettings.tag_style);

View file

@ -20,6 +20,7 @@ export function addTagsHtmlCallback(callback, options) {
export default function(topic, params){
let tags = topic.tags;
let buffer = "";
const isPrivateMessage = topic.get('isPrivateMessage');
if (params && params.mode === "list") {
tags = topic.get("visibleListTags");
@ -43,7 +44,7 @@ export default function(topic, params){
buffer = "<div class='discourse-tags'>";
if (tags) {
for(let i=0; i<tags.length; i++){
buffer += renderTag(tags[i]) + ' ';
buffer += renderTag(tags[i], { isPrivateMessage }) + ' ';
}
}

View file

@ -96,6 +96,7 @@ 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('preferences', { resetNamespace: true }, function() {

View file

@ -0,0 +1,10 @@
import createPMRoute from "discourse/routes/build-private-messages-route";
export default createPMRoute('tags', 'private-messages-tags').extend({
model(params) {
const username = this.modelFor("user").get("username_lower");
return this.store.findFiltered("topicList", {
filter: `topics/private-messages-tag/${username}/${params.id}`
});
}
});

View file

@ -1,13 +1,13 @@
{{#if topic.category.parentCategory}}
{{bound-category-link topic.category.parentCategory}}
{{/if}}
{{bound-category-link topic.category hideParent=true}}
{{#unless topic.isPrivateMessage}}
{{#if topic.category.parentCategory}}
{{bound-category-link topic.category.parentCategory}}
{{/if}}
{{bound-category-link topic.category hideParent=true}}
{{/unless}}
<div class="topic-header-extra">
{{#if siteSettings.tagging_enabled}}
<div class="list-tags">
{{#each topic.tags as |t|}}
{{discourse-tag t}}
{{/each}}
{{discourse-tags topic mode="list"}}
</div>
{{/if}}
{{#if siteSettings.topic_featured_link_enabled}}

View file

@ -63,9 +63,7 @@
{{/if}}
</h1>
{{#unless model.isPrivateMessage}}
{{topic-category topic=model class="topic-category"}}
{{/unless}}
{{topic-category topic=model class="topic-category"}}
{{/if}}
{{/topic-title}}
{{/if}}

View file

@ -189,7 +189,7 @@
.category-input {
display: flex;
flex: 1 0 35%;
margin: 0 0 5px 10px;
margin: 0 5px 5px 10px;
@media screen and (max-width: 955px) {
flex: 1 0 100%;
margin-left: 0;
@ -223,7 +223,7 @@
.mini-tag-chooser {
flex: 1 1 25%;
margin: 0 0 5px 5px;
margin: 0 0 5px 0;
background: $secondary;
@media all and (max-width: 900px) {
margin: 0;

View file

@ -122,6 +122,10 @@ a.badge-category {
}
}
.archetype-private_message #topic-title .edit-topic-title .tag-chooser {
margin-left: 19px;
}
.private_message {
#topic-title {
.edit-topic-title {