Browse Source

Add a proper flow when clicking on the Comment button on a Post card

master
Timothée Jaussoin 4 days ago
parent
commit
fe440c972f
  1. 2
      app/Widgets/Post/Post.php
  2. 4
      app/Widgets/Post/_post_card.tpl
  3. 8
      app/Widgets/Post/post.js

2
app/Widgets/Post/Post.php

@ -41,6 +41,7 @@ class Post extends Base
$this->prepareComments($parent)
);
$this->rpc('MovimUtils.applyAutoheight');
$this->rpc('Post.checkCommentAction');
} else {
$this->rpc(
'MovimTpl.fill',
@ -90,6 +91,7 @@ class Post extends Base
$this->prepareComments($post)
);
$this->rpc('MovimUtils.applyAutoheight');
$this->rpc('Post.checkCommentAction');
}
}

4
app/Widgets/Post/_post_card.tpl

@ -185,7 +185,7 @@
{$liked = $post->isLiked()}
{if="$liked"}
<a class="button narrow icon flat red" href="{$c->route('post', [$post->server, $post->node, $post->nodeid])}">
<a class="button narrow icon flat red" onclick="MovimUtils.reload('{$c->route('post', [$post->server, $post->node, $post->nodeid])}')" href="#">
{if="$post->likes->count() > 0"}{$post->likes->count()}{/if}
<i class="material-symbols fill">favorite</i>
</a>
@ -200,7 +200,7 @@
{/if}
</a>
{/if}
<a class="button narrow icon flat gray" href="{$c->route('post', [$post->server, $post->node, $post->nodeid])}">
<a class="button narrow icon flat gray" onclick="MovimUtils.reload('{$c->route('post', [$post->server, $post->node, $post->nodeid], [], 'comment')}')" href="#">
{if="$post->comments->count() > 0"}{$post->comments->count()}{/if}
<i class="material-symbols">chat_bubble_outline</i>
</a>

8
app/Widgets/Post/post.js

@ -1,6 +1,8 @@
var Post = {
comment: function() {
document.querySelector('#comment_add').classList.remove('hide');
document.querySelector('#comment_add textarea').focus();
document.querySelector('#comment_add').scrollIntoView();
},
share : function() {
var parts = MovimUtils.urlParts();
@ -15,6 +17,12 @@ var Post = {
if (parts.params.length) {
Post_ajaxGetPostComments(parts.params[0], parts.params[1], parts.params[2]);
}
},
checkCommentAction: function() {
var parts = MovimUtils.urlParts();
if (parts.hash == 'comment') {
Post.comment();
}
}
};

Loading…
Cancel
Save