Skip to content

Commit

Permalink
Revert "Merge pull request #91 from GGHDMS/feature/#65-n-comments"
Browse files Browse the repository at this point in the history
n차 대댓글 기능을 롤백한다.
더 나은 서비스를 위해 1차 대댓글 기능을 제공하기로 함

f782eb8
  • Loading branch information
GGHDMS committed Mar 4, 2023
1 parent f782eb8 commit d38ac2c
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 37 deletions.
28 changes: 23 additions & 5 deletions project-board/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 @@ -82,16 +82,34 @@ <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>Hno</strong>
<small><time>2023-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">
<summary>댓글 달기</summary>
<form class="comment-form">
<input type="hidden" class="article-id">
<input type="hidden" class="parent-comment-id">
<textarea class="form-control comment-textbox" placeholder="댓글 쓰기.." rows="2"
required></textarea>
<textarea class="form-control comment-textbox" placeholder="댓글 쓰기.." rows="2" required></textarea>
<button class="form-control btn btn-primary mt-2" type="submit">쓰기</button>
</form>
</details>
Expand Down
61 changes: 29 additions & 32 deletions project-board/src/main/resources/templates/articles/detail.th.xml
Original file line number Diff line number Diff line change
@@ -1,56 +1,53 @@
<?xml version="1.0"?>
<thlogic>
<attr sel="#header" th:replace="header :: header"/>
<attr sel="#footer" th:replace="footer :: footer"/>
<attr sel="#header" th:replace="header :: header" />
<attr sel="#footer" th:replace="footer :: footer" />

<attr sel="#article-main" th:object="${article}">
<attr sel="#article-header/h1" th:text="*{title}"/>
<attr sel="#nickname" th:text="*{nickname}"/>
<attr sel="#email" th:text="*{email}"/>
<attr sel="#created-at" th:datetime="*{createdAt}"
th:text="*{#temporals.format(createdAt, 'yyyy-MM-dd HH:mm:ss')}"/>
<attr sel="#article-header/h1" th:text="*{title}" />
<attr sel="#nickname" th:text="*{nickname}" />
<attr sel="#email" th:text="*{email}" />
<attr sel="#created-at" th:datetime="*{createdAt}" th:text="*{#temporals.format(createdAt, 'yyyy-MM-dd HH:mm:ss')}" />
<attr sel="#hashtag" th:each="hashtag : ${article.hashtags}">
<attr sel="a"
th:text="'#' + ${hashtag}"
th:href="@{/articles(searchType=${searchTypeHashtag},searchValue=${hashtag})}"
/>
</attr>

<attr sel="#article-content/pre" th:text="*{content}"/>
<attr sel="#article-content/pre" th:text="*{content}" />

<attr sel="#article-buttons"
th:if="${#authorization.expression('isAuthenticated()')} and *{userId} == ${#authentication.name}">
<attr sel="#article-buttons" th:if="${#authorization.expression('isAuthenticated()')} and *{userId} == ${#authentication.name}">
<attr sel="#delete-article-form" th:action="'/articles/' + *{id} + '/delete'" th:method="post">
<attr sel="#update-article" th:href="'/articles/' + *{id} + '/form'"/>
<attr sel="#update-article" th:href="'/articles/' + *{id} + '/form'" />
</attr>
</attr>

<attr sel=".article-id" th:name="articleId" th:value="*{id}"/>
<attr sel=".article-id" th:name="articleId" th:value="*{id}" />
<attr sel=".comment-form" th:action="@{/comments/new}" th:method="post">
<attr sel=".comment-textbox" th:name="content"/>
<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=".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 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="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 sel=".child-comments" th:unless="${articleComment.childComments.isEmpty}" th:replace=":: articleComments(${articleComment.childComments})"/>

</attr>

<attr sel=".parent-comment-id" th:name="parentCommentId" th:value="${articleComment.id}"/>
<attr sel=".parent-comment-id" th:name="parentCommentId" th:value="${articleComment.id}" />
</attr>

<attr sel="#pagination">
Expand Down

0 comments on commit d38ac2c

Please sign in to comment.