client/home: fix missing info on featured post

This commit is contained in:
rr- 2016-07-06 00:07:30 +02:00
parent 7e62751e4e
commit 99011b02d7
3 changed files with 18 additions and 10 deletions

View File

@ -16,16 +16,7 @@
</div> </div>
</form> </form>
<% } %> <% } %>
<% if (ctx.featuredPost) { %> <div class='post-info-container'></div>
<aside>
Featured post: <%= ctx.makePostLink(ctx.featuredPost.id) %>,
posted
<%= ctx.makeRelativeTime(ctx.featuredPost.creationTime) %>
by
<%= ctx.makeUserLink(ctx.featuredPost.user) %>
</aside>
<% } %>
<div class='post-container'></div>
<footer> <footer>
Build <a class='version' href='https://github.com/rr-/szurubooru/commits/master'><%- ctx.version %></a> Build <a class='version' href='https://github.com/rr-/szurubooru/commits/master'><%- ctx.version %></a>
from <%= ctx.makeRelativeTime(ctx.buildDate) %> from <%= ctx.makeRelativeTime(ctx.buildDate) %>

View File

@ -0,0 +1,10 @@
<% if (ctx.featuredPost) { %>
<aside>
Featured post: <%= ctx.makePostLink(ctx.featuredPost.id) %>,
posted
<%= ctx.makeRelativeTime(ctx.featuredPost.creationTime) %>
by
<%= ctx.makeUserLink(ctx.featuredPost.user) %>
</aside>
<% } %>
<div class='post-container'></div>

View File

@ -11,6 +11,7 @@ const TagAutoCompleteControl =
const template = views.getTemplate('home'); const template = views.getTemplate('home');
const statsTemplate = views.getTemplate('home-stats'); const statsTemplate = views.getTemplate('home-stats');
const featuredPostTemplate = views.getTemplate('home-featured-post');
class HomeView { class HomeView {
constructor(ctx) { constructor(ctx) {
@ -44,6 +45,8 @@ class HomeView {
} }
setFeaturedPost(postInfo) { setFeaturedPost(postInfo) {
views.replaceContent(
this._postInfoContainerNode, featuredPostTemplate(postInfo));
if (this._postContainerNode && postInfo.featuredPost) { if (this._postContainerNode && postInfo.featuredPost) {
this._postContentControl = new PostContentControl( this._postContentControl = new PostContentControl(
this._postContainerNode, this._postContainerNode,
@ -65,6 +68,10 @@ class HomeView {
return this._hostNode.querySelector('.stats-container'); return this._hostNode.querySelector('.stats-container');
} }
get _postInfoContainerNode() {
return this._hostNode.querySelector('.post-info-container');
}
get _postContainerNode() { get _postContainerNode() {
return this._hostNode.querySelector('.post-container'); return this._hostNode.querySelector('.post-container');
} }