Skip to content

Commit

Permalink
Revert "Merge pull request #77 from lmw7414/feature/#76-n-comments"
Browse files Browse the repository at this point in the history
n차 대댓글 기능을 롤백한다.
실제로 서비스해보니 유저 반응이 좋지 않았음.
더 나은 서비스를 위해 1차 대댓글 기능만 제공하기로 논의함.


48e1944
  • Loading branch information
lmw7414 committed Jan 15, 2023
1 parent 48e1944 commit b7ee102
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 11 deletions.
25 changes: 22 additions & 3 deletions src/main/resources/templates/articles/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ <h1>첫번째 글</h1>
</div>
</form>

<ul class="article-comments">
<li class="article-comment">
<ul id="article-comments" class="row col-md-10 col-lg-8 pt-3">
<li class="parent-comment">
<form class="comment-delete-form">
<input type="hidden" class="article-id">
<div class="row">
Expand All @@ -80,7 +80,26 @@ <h1>첫번째 글</h1>
</div>
</form>

<ul class="child-comments"></ul>
<ul class="row me-0">
<li class="child-comment">
<form class="comment-delete-form">
<input type="hidden" class="article-id">
<div class="row">
<div class="col-md-10 col-lg-9">
<strong>Uno</strong>
<small><time>2022-01-01</time></small>
<p class="mb-1">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.<br>
Lorem ipsum dolor sit amet
</p>
</div>
<div class="col-2 mb-3 align-self-center">
<button type="submit" class="btn btn-outline-danger">삭제</button>
</div>
</div>
</form>
</li>
</ul>

<div class="row">
<details class="col-md-10 col-lg-9 mb-4">
Expand Down
20 changes: 12 additions & 8 deletions src/main/resources/templates/articles/detail.th.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,24 @@
<attr sel=".comment-textbox" th:name="content" />
</attr>

<attr sel=".article-comments"
th:remove="all-but-first"
th:fragment="articleComments(childComments)"
th:classappend="${childComments} != null ? 'row me-0' : 'row col-md-10 col-lg-8 pt-3'"
>
<attr sel=".article-comment[0]" th:each="articleComment : ${childComments} ?: ${articleComments}">
<attr sel="#article-comments" th:remove="all-but-first">
<attr sel=".parent-comment[0]" th:each="articleComment : ${articleComments}">
<attr sel=".comment-delete-form" th:action="'/comments/' + ${articleComment.id} + '/delete'" th:method="post">
<attr sel="div/strong" th:text="${articleComment.nickname}" />
<attr sel="div/small/time" th:datetime="${articleComment.createdAt}" th:text="${#temporals.format(articleComment.createdAt, 'yyyy-MM-dd HH:mm:ss')}" />
<attr sel="div/p" th:text="${articleComment.content}" />
<attr sel="button" th:if="${#authorization.expression('isAuthenticated()')} and ${articleComment.userId} == ${#authentication.name}" />
</attr>

<attr sel=".child-comments" th:unless="${articleComment.childComments.isEmpty}" th:replace=":: articleComments(${articleComment.childComments})" />
<attr sel="ul" th:if="${!articleComment.childComments.isEmpty}" th:remove="all-but-first">
<attr sel=".child-comment[0]" th:each="childComment : ${articleComment.childComments}">
<attr sel=".comment-delete-form" th:action="'/comments/' + ${childComment.id} + '/delete'" th:method="post">
<attr sel="div/strong" th:text="${childComment.nickname}" />
<attr sel="div/small/time" th:datetime="${childComment.createdAt}" th:text="${#temporals.format(childComment.createdAt, 'yyyy-MM-dd HH:mm:ss')}" />
<attr sel="div/p" th:text="${childComment.content}" />
<attr sel="button" th:if="${#authorization.expression('isAuthenticated()')} and ${childComment.userId} == ${#authentication.name}" />
</attr>
</attr>
</attr>
</attr>
<attr sel=".parent-comment-id" th:name="parentCommentId" th:value="${articleComment.id}" />
</attr>
Expand Down

0 comments on commit b7ee102

Please sign in to comment.