From fb5710b5d642059a6587823a9e51103949420fd8 Mon Sep 17 00:00:00 2001 From: tms Date: Sun, 17 Feb 2013 01:38:20 -0500 Subject: [PATCH] Improved action descriptions/links on user stream items --- .../discourse/models/user_action.js.coffee | 11 +++++++- .../templates/user/stream.js.handlebars | 26 +++++++++++++++++-- .../stylesheets/application/user.css.scss | 3 +++ app/models/user_action.rb | 1 + config/locales/client.en.yml | 8 +++++- 5 files changed, 45 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/discourse/models/user_action.js.coffee b/app/assets/javascripts/discourse/models/user_action.js.coffee index 88dc55073c6..1854434c264 100644 --- a/app/assets/javascripts/discourse/models/user_action.js.coffee +++ b/app/assets/javascripts/discourse/models/user_action.js.coffee @@ -2,10 +2,19 @@ window.Discourse.UserAction = Discourse.Model.extend postUrl:(-> Discourse.Utilities.postUrl(@get('slug'), @get('topic_id'), @get('post_number')) ).property() + + replyUrl: (-> + Discourse.Utilities.postUrl(@get('slug'), @get('topic_id'), @get('reply_to_post_number')) + ).property() isPM: (-> a = @get('action_type') - a == UserAction.NEW_PRIVATE_MESSAGE || UserAction.GOT_PRIVATE_MESSAGE + a == Discourse.UserAction.NEW_PRIVATE_MESSAGE || a == Discourse.UserAction.GOT_PRIVATE_MESSAGE + ).property() + + isPostAction: (-> + a = @get('action_type') + a == Discourse.UserAction.RESPONSE || a == Discourse.UserAction.POST || a == Discourse.UserAction.NEW_TOPIC ).property() addChild: (action)-> diff --git a/app/assets/javascripts/discourse/templates/user/stream.js.handlebars b/app/assets/javascripts/discourse/templates/user/stream.js.handlebars index 1890fb515fa..4a5d55f6182 100644 --- a/app/assets/javascripts/discourse/templates/user/stream.js.handlebars +++ b/app/assets/javascripts/discourse/templates/user/stream.js.handlebars @@ -5,9 +5,31 @@
{{avatar this imageSize="large" extraClasses="actor" avatarTemplatePath="avatar_template" ignoreTitle="true"}}
{{date path="created_at" leaveAgo="true"}} {{unbound title}}
+ {{#unless description}} + + {{#if isPM}} + + {{i18n user.stream.sent_by}} + {{else}} + {{i18n user.stream.posted_by}} + {{/if}} + + {{/unless}} {{personalizedName name usernamePath="username"}} - {{unbound description}} - #{{unbound post_number}} + {{#if description}} + {{unbound description}} + {{#if isPostAction}} + + {{#if reply_to_post_number}} + #{{unbound reply_to_post_number}} + {{else}} + {{i18n user.stream.the_topic}} + {{/if}} + + {{else}} + {{personalizedName view.parentView.parentView.user.name usernamePath="view.parentView.parentView.user.username"}} + {{/if}} + {{/if}}

{{{unbound excerpt}}} diff --git a/app/assets/stylesheets/application/user.css.scss b/app/assets/stylesheets/application/user.css.scss index adf60b25904..49a5b86d6a6 100644 --- a/app/assets/stylesheets/application/user.css.scss +++ b/app/assets/stylesheets/application/user.css.scss @@ -258,6 +258,9 @@ .type { color: lighten($black, 40%); } + span.name { + color: lighten($black, 40%); + } .time { display: block; float: right; diff --git a/app/models/user_action.rb b/app/models/user_action.rb index 00cb87c0ca4..1bbb1e15e4a 100644 --- a/app/models/user_action.rb +++ b/app/models/user_action.rb @@ -79,6 +79,7 @@ class UserAction < ActiveRecord::Base SELECT t.title, a.action_type, a.created_at, t.id topic_id, coalesce(p.post_number, 1) post_number, + p.reply_to_post_number, pu.email ,pu.username, pu.name, pu.id user_id, u.email acting_email, u.username acting_username, u.name acting_name, u.id acting_user_id, coalesce(p.cooked, p2.cooked) cooked diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index a564cc0db9d..6aef53d5b20 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -168,7 +168,13 @@ en: instructions: "We use Gravatar for avatars based on your email" filters: - all: "All" + all: "All" + + stream: + posted_by: "Posted by" + sent_by: "Sent by" + private_message: "private message" + the_topic: "the topic" loading: "Loading..." close: "Close"