When editing a post that is in reply to another post, show display meta data to that effect.

This commit is contained in:
Robin Ward 2013-03-13 12:00:38 -04:00
parent 8e6a8eae66
commit 42c7a65a05
2 changed files with 23 additions and 14 deletions

View File

@ -78,6 +78,10 @@ Discourse.Utilities = {
(extraClasses || "") + "' title='" + (Handlebars.Utils.escapeExpression(title || "")) + "'>";
},
tinyAvatar: function(username) {
return Discourse.Utilities.avatarImg({ username: username, size: 'tiny' });
},
postUrl: function(slug, topicId, postNumber) {
var url;
url = "/t/";

View File

@ -112,12 +112,24 @@ Discourse.Composer = Discourse.Model.extend({
topicLink = "<a href='" + (topic.get('url')) + "'> " + (Handlebars.Utils.escapeExpression(topic.get('title'))) + "</a>";
}
var replyAvatar;
if (this.get('post')) {
replyAvatar = Discourse.Utilities.avatarImg({
username: this.get('post.username'),
size: 'tiny'
var postDescription,
post = this.get('post');
if (post) {
postDescription = Em.String.i18n('post.' + this.get('action'), {
link: postLink,
replyAvatar: Discourse.Utilities.tinyAvatar(post.get('username')),
username: this.get('post.username')
});
var replyUsername = post.get('reply_to_user.username');
if (replyUsername && this.get('action') === EDIT) {
postDescription += " " + Em.String.i18n("post.in_reply_to") + " " +
Discourse.Utilities.tinyAvatar(replyUsername) + " " + replyUsername;
}
}
switch (this.get('action')) {
@ -127,15 +139,8 @@ Discourse.Composer = Discourse.Model.extend({
return Em.String.i18n('topic.create_long');
case REPLY:
case EDIT:
if (replyAvatar) {
return Em.String.i18n('post.' + this.get('action'), {
link: postLink,
replyAvatar: replyAvatar,
username: this.get('post.username')
});
} else if (topic) {
return Em.String.i18n('post.reply_topic', { link: topicLink });
}
if (postDescription) return postDescription;
if (topic) return Em.String.i18n('post.reply_topic', { link: topicLink });
}
}).property('action', 'post', 'topic', 'topic.title'),