<!DOCTYPE html>
<html lang="ko" xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorate="~{layout/layout}">
<th:block layout:fragment="script">
  <script type="text/javascript" th:src="@{/js/board/contentList.js}"></script>
</th:block>
<div layout:fragment="content">
  <main class="pt-3">
    <input type="hidden" name="_csrf_header" th:value="${_csrf.headerName}"/>
    <input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}"/>
    <h4 th:text="${pageTitle}"></h4>
    <div class="row mx-0">
      <div class="col-12 card">
        <div class="card-body">
          <div class="row justify-content-start">
            <div class="col-7">
              <!--검색 form-->
              <form method="get" th:action="@{/board/contentList}">
                <input type="hidden" name="categorySeq" id="categorySeq" th:value="${searchParams.categorySeq}">
                <input type="hidden" name="pageIndex" id="pageIndex" th:value="${searchParams.pageIndex}">
                <div class="row justify-content-between">
                  <div class="col-auto row">
                    <div class="col-auto">
                      <label for="rowCnt" class="col-form-label">데이터 수</label>
                    </div>
                    <div class="col-auto">
                      <select class="form-select form-control-sm" name="rowCnt" id="rowCnt">
                        <th:block th:each="num : ${#numbers.sequence(1,5)}">
                          <option th:value="${num*10}" th:text="${num*10}" th:selected="${searchParams.rowCnt==num*10}"></option>
                        </th:block>
                      </select>
                    </div>
                  </div>
                  <div class="col-auto card">
                    <div class="row justify-content-end pt-1">
                      <div class="col-auto">
                        <div class="row mb-1">
                          <label for="title" class="col-sm-2 col-form-label">제목</label>
                          <div class="col-sm-4">
                            <input type="text" class="form-control form-control-sm" id="title" name="title" th:value="${searchParams.title}">
                          </div>
                          <label for="createName" class="col-sm-2 col-form-label">작성자</label>
                          <div class="col-sm-4">
                            <input type="text" class="form-control form-control-sm" id="createName" name="createName" th:value="${searchParams.createName}">
                          </div>
                        </div>
                        <div class="row mb-1">
                          <label for="tagName" class="col-sm-2 col-form-label" data-bs-toggle="tooltip" data-bs-placement="top" title="# 없이 ,로 구분하여 태그 입력">해시태그</label>
                          <div class="col-sm-4">
                            <input type="text" class="form-control form-control-sm" id="tagName" name="tagName" th:value="${searchParams.hashTagStr}">
                          </div>
                          <label for="originalName" class="col-sm-2 col-form-label">첨부파일</label>
                          <div class="col-sm-4">
                            <input type="text" class="form-control form-control-sm" id="originalName" name="originalName" th:value="${searchParams.originalName}">
                          </div>
                        </div>
                        <div class="row">
                          <label for="startDate" class="col-sm-2 col-form-label">작성일</label>
                          <div class="col-sm-6">
                            <div class="col-auto input-group w-auto input-daterange" id="dateSelectorDiv">
                              <input type="text" class="form-control form-control-sm" id="startDate" name="startDate" placeholder="시작일" autocomplete="off" th:value="${searchParams.startDate}" readonly>
                              <input type="text" class="form-control form-control-sm" id="endDate" name="endDate" placeholder="종료일" autocomplete="off" th:value="${searchParams.endDate}" readonly>
                            </div>
                          </div>
                        </div>
                      </div>
                      <div class="col-auto my-auto">
                        <input type="submit" class="btn btn-primary py-4" id="searchBtn" value="검색">
                      </div>
                    </div>
                  </div>
                </div>
              </form>
              <div class="row-cols-6">
                <table class="table table-striped text-center">
                  <thead>
                  <tr>
                    <th></th>
                    <th>제목</th>
                    <th>파일 수</th>
                    <th>작성자</th>
                    <th>작성일</th>
                    <th>조회수</th>
                  </tr>
                  </thead>
                  <tbody>
                  <tr class="contentTr" th:each="content:${contentList}">
                    <td>
                      <input type="checkbox" class="contentCheckBox" th:value="${content.contentSeq}">
                    </td>
                    <td th:text="${content.title}"></td>
                    <td th:text="${content.fileCnt}"></td>
                    <td th:text="${content.createName}"></td>
                    <th:block th:if="${#dates.format(#dates.createNow(), 'yyyy-MM-dd')} == ${#temporals.format(content.createDate, 'yyyy-MM-dd')}">
                      <td th:text="${#temporals.format(content.createDate, 'HH:mm:ss')}"></td>
                    </th:block>
                    <th:block th:if="${#dates.format(#dates.createNow(), 'yyyy-MM-dd')} != ${#temporals.format(content.createDate, 'yyyy-MM-dd')}">
                      <td th:text="${#temporals.format(content.createDate, 'yyyy-MM-dd')}"></td>
                    </th:block>
                    <td class="viewCntTd" th:text="${content.viewCnt}"></td>
                  </tr>
                  </tbody>
                </table>
              </div>
              <div class="row justify-content-center">
                <div class="col-auto">
                  <nav aria-label="Page navigation">
                    <ul class="pagination">
                      <th:block th:if="${searchParams.pageIndex>3}">
                        <li class="page-item" th:data-pageindex="${(searchParams.pageIndex)-3}">
                          <a class="page-link" href="#" aria-label="Previous">
                            <span aria-hidden="true">&laquo;</span>
                          </a>
                        </li>
                      </th:block>
                      <th:block th:each="num : ${#numbers.sequence(searchParams.startNum, searchParams.endNum)}">
                        <li class="page-item" th:data-pageindex="${num}" th:classappend="${searchParams.pageIndex==num?'active':''}">
                          <a class="page-link" href="#" th:text="${num}"></a>
                        </li>
                      </th:block>
                      <th:block th:if="${searchParams.maxNum>searchParams.endNum+2}">
                        <li class="page-item" th:data-pageindex="${(searchParams.pageIndex)+3}">
                          <a class="page-link" href="#" aria-label="Next">
                            <span aria-hidden="true">&raquo;</span>
                          </a>
                        </li>
                      </th:block>
                    </ul>
                  </nav>
                </div>
              </div>
            </div>
            <div class="col-5">
              <ul class="nav nav-tabs" id="boardTab" role="tablist">
                <li class="nav-item" role="presentation">
                  <button class="nav-link active" id="contentTab" data-bs-toggle="tab" data-bs-target="#contentDiv" type="button" role="tab">내용</button>
                </li>
                <li class="nav-item" role="presentation">
                  <button class="nav-link" id="logTab" data-bs-toggle="tab" data-bs-target="#logDiv" type="button" role="tab">이력</button>
                </li>
              </ul>
              <div class="tab-content border border-top-0" id="boardDiv">
                <div class="tab-pane fade show active" id="contentDiv" role="tabpanel" aria-labelledby="contentTab">
                  <div class="py-5 text-center">
                    <h3>왼쪽 목록에서 선택해주세요.</h3>
                  </div>
                </div>
                <div class="tab-pane fade" id="logDiv" role="tabpanel" aria-labelledby="logTab">
                  <div class="py-5 text-center">
                    <h3>왼쪽 목록에서 선택해주세요.</h3>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </main>
</div>
</html>