<!DOCTYPE html>
<html lang="ko" xmlns:th="http://www.thymeleaf.org">
<div class="row">
  <div class="col-12">
    <form method="get" action="#" id="modalSearchForm">
      <input type="hidden" name="pageIndex" id="pageIndex" th:value="${searchParams.pageIndex}">
      <div class="row justify-content-between pe-3 py-1">
        <div class="col-auto">
          <select class="form-select" 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 eq num*10}"></option>
            </th:block>
          </select>
        </div>
        <div class="col-auto">
          <div class="row justify-content-end">
            <div class="col-auto">
              <select class="form-select form-select-sm" name="cat1Cd">
                <option value="">대분류 선택</option>
                <th:block th:each="commonCode:${session.commonCode.get('CAT1')}">
                  <option th:value="${commonCode.itemCd}" th:text="${commonCode.itemValue}" th:selected="${searchParams.cat1Cd eq commonCode.itemCd}"></option>
                </th:block>
              </select>
            </div>
            <div class="col-auto">
              <select class="form-select form-select-sm" name="cat2Cd">
                <option value="">중분류 선택</option>
                <th:block th:each="commonCode:${session.commonCode.get('CAT2')}">
                  <option th:value="${commonCode.itemCd}" th:text="${commonCode.itemValue}" th:selected="${searchParams.cat2Cd eq commonCode.itemCd}"></option>
                </th:block>
              </select>
            </div>
            <div class="col-auto">
              <select class="form-select form-select-sm" name="cat3Cd">
                <option value="">소분류 선택</option>
                <th:block th:each="commonCode:${session.commonCode.get('CAT3')}">
                  <option th:value="${commonCode.itemCd}" th:text="${commonCode.itemValue}" th:selected="${searchParams.cat3Cd eq commonCode.itemCd}"></option>
                </th:block>
              </select>
            </div>
            <div class="col-auto">
              <input type="text" class="form-control form-control-sm" name="menuUrl" placeholder="url" th:value="${searchParams.menuUrl}">
            </div>
            <input type="button" class="btn btn-sm btn-primary col-auto" id="searchModalBtn" value="검색">
          </div>
        </div>
      </div>
    </form>
  </div>
</div>
<div class="row">
  <div class="col-12">
    <table class="table table-striped">
      <thead>
      <tr>
        <th></th>
        <th>대분류</th>
        <th>중분류</th>
        <th>소분류</th>
        <th>url</th>
      </tr>
      </thead>
      <tbody>
      <tr class="menuTr" th:each="menuMgt:${menuMgtList}">
        <input type="hidden" class="menuKey" th:value="${menuMgt.menuKey}">
        <input type="hidden" class="cat1Cd" th:value="${menuMgt.cat1Cd}">
        <input type="hidden" class="cat2Cd" th:value="${menuMgt.cat2Cd}">
        <input type="hidden" class="cat3Cd" th:value="${menuMgt.cat3Cd}">
        <input type="hidden" class="menuUrl" th:value="${menuMgt.menuUrl}">
        <input type="hidden" class="approvalChk" th:value="${menuMgt.approvalChk}">
        <td>
          <input type="checkbox" class="menuCheckBox" th:value="${menuMgt.menuKey}">
        </td>
        <th:block th:if="${menuMgt.cat1RowspanCnt ne 0}" th:each="commonCode:${session.commonCode.get('CAT1')}">
          <th:block th:if="${commonCode.itemCd  eq  menuMgt.cat1Cd}">
            <td th:text="${commonCode.itemValue}" th:rowspan="${menuMgt.cat1RowspanCnt}"></td>
          </th:block>
        </th:block>
        <th:block th:if="${menuMgt.cat2RowspanCnt ne 0}" th:each="commonCode:${session.commonCode.get('CAT2')}">
          <th:block th:if="${commonCode.itemCd  eq  menuMgt.cat2Cd}">
            <td th:text="${commonCode.itemValue}" th:rowspan="${menuMgt.cat2RowspanCnt}"></td>
          </th:block>
        </th:block>
        <th:block th:each="commonCode:${session.commonCode.get('CAT3')}">
          <th:block th:if="${commonCode.itemCd  eq  menuMgt.cat3Cd}">
            <td th:text="${commonCode.itemValue}"></td>
          </th:block>
        </th:block>
        <th:block th:if="${#strings.isEmpty(menuMgt.cat3Cd)}">
          <td></td>
        </th:block>
        <td th:text="${menuMgt.menuUrl}"></td>
      </tr>
      </tbody>
    </table>
  </div>
</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 modalPage" 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 modalPage" th:data-pageindex="${num}" th:classappend="${searchParams.pageIndex eq 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 modalPage" 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>
</html>