mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 10:52:45 +08:00
FEATURE: Expand truncated posts in the user stream
This commit is contained in:
parent
ae7734707e
commit
a289ae67e1
|
@ -1,8 +1,20 @@
|
|||
import { propertyEqual } from 'discourse/lib/computed';
|
||||
import { actionDescription } from "discourse/components/small-action";
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
|
||||
export default Ember.Component.extend({
|
||||
classNameBindings: [":item", "item.hidden", "item.deleted:deleted", "moderatorAction"],
|
||||
moderatorAction: propertyEqual("item.post_type", "site.post_types.moderator_action"),
|
||||
actionDescription: actionDescription("item.action_code", "item.created_at", "item.username"),
|
||||
|
||||
actions: {
|
||||
expandItem() {
|
||||
const item = this.get('item');
|
||||
|
||||
return ajax(`/posts/${item.get('post_id')}/cooked.json`).then(result => {
|
||||
item.set('truncated', false);
|
||||
item.set('excerpt', result.cooked);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,11 +1,17 @@
|
|||
<div class='clearfix info'>
|
||||
<a href={{item.userUrl}} data-user-card={{item.username}} class='avatar-link'><div class='avatar-wrapper'>{{avatar item imageSize="large" extraClasses="actor" ignoreTitle="true"}}</div></a>
|
||||
<span class='time'>{{format-date item.created_at}}</span>
|
||||
{{#if item.truncated}}
|
||||
<a class="expand-item" href {{action "expandItem"}} title={{i18n "post.expand_collapse"}}>
|
||||
{{fa-icon "chevron-down"}}
|
||||
</a>
|
||||
{{/if}}
|
||||
{{topic-status topic=item disableActions=true}}
|
||||
<span class="title">
|
||||
<a href={{item.postUrl}}>{{{item.title}}}</a>
|
||||
</span>
|
||||
<div class="category">{{category-link item.category}}</div>
|
||||
|
||||
{{#if item.deleted_by}}
|
||||
<span class="delete-info">
|
||||
{{fa-icon "trash-o"}}
|
||||
|
|
|
@ -12,6 +12,12 @@
|
|||
.avatar-link {
|
||||
margin-right: 3px;
|
||||
}
|
||||
|
||||
}
|
||||
.user-stream .item .expand-item {
|
||||
float: right;
|
||||
margin-right: 0.5em;
|
||||
color: $primary;
|
||||
}
|
||||
|
||||
.user-main {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
// styles that apply to the user page
|
||||
|
||||
.groups {
|
||||
.group-link {
|
||||
color: $tertiary;
|
||||
|
|
|
@ -4,6 +4,7 @@ class AdminUserActionSerializer < ApplicationSerializer
|
|||
:id,
|
||||
:created_at,
|
||||
:post_number,
|
||||
:post_id,
|
||||
:name,
|
||||
:username,
|
||||
:avatar_template,
|
||||
|
@ -11,6 +12,7 @@ class AdminUserActionSerializer < ApplicationSerializer
|
|||
:slug,
|
||||
:title,
|
||||
:category_id,
|
||||
:truncated,
|
||||
:excerpt,
|
||||
:hidden,
|
||||
:moderator_action,
|
||||
|
@ -21,6 +23,18 @@ class AdminUserActionSerializer < ApplicationSerializer
|
|||
:action_type
|
||||
)
|
||||
|
||||
def truncated
|
||||
true
|
||||
end
|
||||
|
||||
def post_id
|
||||
object.id
|
||||
end
|
||||
|
||||
def include_truncated?
|
||||
object.excerpt != object.cooked
|
||||
end
|
||||
|
||||
def deleted
|
||||
deleted_at.present?
|
||||
end
|
||||
|
|
|
@ -44,7 +44,7 @@ class UserActionSerializer < ApplicationSerializer
|
|||
end
|
||||
|
||||
def include_truncated?
|
||||
excerpt != cooked
|
||||
cooked.length > 300
|
||||
end
|
||||
|
||||
def avatar_template
|
||||
|
|
Loading…
Reference in New Issue
Block a user