UX: show date of last edit on wiki topics

This commit is contained in:
Régis Hanol 2017-09-12 15:37:47 +02:00
parent 07bfe3d053
commit 85ef3696de
4 changed files with 26 additions and 12 deletions

View File

@ -35,6 +35,7 @@ export function transformBasicPost(post) {
primary_group_flair_bg_color: post.primary_group_flair_bg_color, primary_group_flair_bg_color: post.primary_group_flair_bg_color,
primary_group_flair_color: post.primary_group_flair_color, primary_group_flair_color: post.primary_group_flair_color,
wiki: post.wiki, wiki: post.wiki,
lastWikiEdit: post.last_wiki_edit,
firstPost: post.post_number === 1, firstPost: post.post_number === 1,
post_number: post.post_number, post_number: post.post_number,
cooked: post.cooked, cooked: post.cooked,

View File

@ -171,19 +171,22 @@ createWidget('post-meta-data', {
}, iconNode('eye-slash'))); }, iconNode('eye-slash')));
} }
const lastWikiEdit = attrs.wiki && attrs.lastWikiEdit && new Date(attrs.lastWikiEdit);
const createdAt = new Date(attrs.created_at); const createdAt = new Date(attrs.created_at);
if (createdAt) { const date = lastWikiEdit ? dateNode(lastWikiEdit) : dateNode(createdAt);
result.push(h('div.post-info', const attributes = {
h('a.post-date', { class: "post-date",
attributes: { href: attrs.shareUrl,
href: attrs.shareUrl, 'data-share-url': attrs.shareUrl,
'data-share-url': attrs.shareUrl, 'data-post-number': attrs.post_number
'data-post-number': attrs.post_number, };
}
}, dateNode(createdAt)) if (lastWikiEdit) {
)); attributes["class"] += " last-wiki-edit";
} }
result.push(h('div.post-info', h('a', { attributes }, date)));
if (attrs.via_email) { if (attrs.via_email) {
result.push(this.attach('post-email-indicator', attrs)); result.push(this.attach('post-email-indicator', attrs));
} }

View File

@ -247,7 +247,8 @@ aside.quote {
} }
} }
.wiki { .wiki,
.last-wiki-edit {
color: green !important; color: green !important;
} }

View File

@ -68,7 +68,8 @@ class PostSerializer < BasicPostSerializer
:via_email, :via_email,
:is_auto_generated, :is_auto_generated,
:action_code, :action_code,
:action_code_who :action_code_who,
:last_wiki_edit
def initialize(object, opts) def initialize(object, opts)
super(object, opts) super(object, opts)
@ -353,6 +354,14 @@ class PostSerializer < BasicPostSerializer
include_action_code? && action_code_who.present? include_action_code? && action_code_who.present?
end end
def last_wiki_edit
object.revisions.last.updated_at
end
def include_last_wiki_edit?
object.wiki && object.post_number == 1
end
private private
def post_actions def post_actions