UX: show date of last edit on wiki topics
This commit is contained in:
parent
07bfe3d053
commit
85ef3696de
|
@ -35,6 +35,7 @@ export function transformBasicPost(post) {
|
|||
primary_group_flair_bg_color: post.primary_group_flair_bg_color,
|
||||
primary_group_flair_color: post.primary_group_flair_color,
|
||||
wiki: post.wiki,
|
||||
lastWikiEdit: post.last_wiki_edit,
|
||||
firstPost: post.post_number === 1,
|
||||
post_number: post.post_number,
|
||||
cooked: post.cooked,
|
||||
|
|
|
@ -171,19 +171,22 @@ createWidget('post-meta-data', {
|
|||
}, iconNode('eye-slash')));
|
||||
}
|
||||
|
||||
const lastWikiEdit = attrs.wiki && attrs.lastWikiEdit && new Date(attrs.lastWikiEdit);
|
||||
const createdAt = new Date(attrs.created_at);
|
||||
if (createdAt) {
|
||||
result.push(h('div.post-info',
|
||||
h('a.post-date', {
|
||||
attributes: {
|
||||
href: attrs.shareUrl,
|
||||
'data-share-url': attrs.shareUrl,
|
||||
'data-post-number': attrs.post_number,
|
||||
}
|
||||
}, dateNode(createdAt))
|
||||
));
|
||||
const date = lastWikiEdit ? dateNode(lastWikiEdit) : dateNode(createdAt);
|
||||
const attributes = {
|
||||
class: "post-date",
|
||||
href: attrs.shareUrl,
|
||||
'data-share-url': attrs.shareUrl,
|
||||
'data-post-number': attrs.post_number
|
||||
};
|
||||
|
||||
if (lastWikiEdit) {
|
||||
attributes["class"] += " last-wiki-edit";
|
||||
}
|
||||
|
||||
result.push(h('div.post-info', h('a', { attributes }, date)));
|
||||
|
||||
if (attrs.via_email) {
|
||||
result.push(this.attach('post-email-indicator', attrs));
|
||||
}
|
||||
|
|
|
@ -247,7 +247,8 @@ aside.quote {
|
|||
}
|
||||
}
|
||||
|
||||
.wiki {
|
||||
.wiki,
|
||||
.last-wiki-edit {
|
||||
color: green !important;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,8 @@ class PostSerializer < BasicPostSerializer
|
|||
:via_email,
|
||||
:is_auto_generated,
|
||||
:action_code,
|
||||
:action_code_who
|
||||
:action_code_who,
|
||||
:last_wiki_edit
|
||||
|
||||
def initialize(object, opts)
|
||||
super(object, opts)
|
||||
|
@ -353,6 +354,14 @@ class PostSerializer < BasicPostSerializer
|
|||
include_action_code? && action_code_who.present?
|
||||
end
|
||||
|
||||
def last_wiki_edit
|
||||
object.revisions.last.updated_at
|
||||
end
|
||||
|
||||
def include_last_wiki_edit?
|
||||
object.wiki && object.post_number == 1
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def post_actions
|
||||
|
|
Loading…
Reference in New Issue