<!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="css">
  <style>
    .orderNumInput{
      width:60px;
      text-align: center;
    }
  </style>
</th:block>
<th:block layout:fragment="script">
  <script type="text/javascript" th:src="@{/js/user/info.js}"></script>
</th:block>
<div layout:fragment="content">
  <main class="pt-3">
    <h4>마이페이지</h4>
    <input type="hidden" name="_csrf_header" th:value="${_csrf.headerName}"/>
    <input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}"/>
    <div class="row mx-0">
      <div class="col-12 card text-center">
        <div class="card-body">
          <ul class="nav nav-tabs" id="userTab" role="tablist">
            <li class="nav-item" role="presentation">
              <button class="nav-link active" id="infoTab" data-bs-toggle="tab" data-bs-target="#infoTabPanel" type="button" role="tab" aria-controls="infoTabPanel" aria-selected="true">개인정보</button>
            </li>
            <li class="nav-item" role="presentation">
              <button class="nav-link" id="dashboardTab" data-bs-toggle="tab" data-bs-target="#dashboardTabPanel" type="button" role="tab" aria-controls="dashboardTabPanel" aria-selected="false">대시보드</button>
            </li>
          </ul>
          <div class="tab-content border border-top-0 p-2">
            <div class="tab-pane fade p-2 show active" id="infoTabPanel" role="tabpanel" aria-labelledby="infoTabPanel" tabindex="0">

            </div>
            <div class="tab-pane fade p-2" id="dashboardTabPanel" role="tabpanel" aria-labelledby="dashboardTab" tabindex="0">
              <div class="row justify-content-end">
                <div class="col-auto">
                  <button type="button" class="btn btn-outline-info" data-bs-toggle="modal" data-bs-target="#questionModal">
                    <i class="bi bi-question-lg"></i>
                  </button>
                </div>
              </div>
              <table class="table table-hover">
                <thead>
                <tr>
                  <th><input type="checkbox" class="allChk"></th>
                  <th>순번</th>
                  <th>대분류</th>
                  <th>중분류</th>
                  <th>소분류</th>
                  <th>url</th>
                  <th>위치변경</th>
                </tr>
                </thead>
                <tbody id="dashboardConfigTbody">
                <tr class="configTr" th:each="dashboardConfig, idx:${dashboardConfigList}">
                  <td><input type="checkbox" class="configChkBox" th:data-menukey="${dashboardConfig.menuKey}"></td>
                  <td>
                    <input type="text" class="border-0 orderNumInput" th:value="${dashboardConfig.orderNum}" readonly>
                  </td>
                  <th:block th:each="commonCode:${session.commonCode.get('CAT1')}">
                    <td th:if="${commonCode.itemCd eq dashboardConfig.cat1Cd}" th:text="${commonCode.itemValue}"></td>
                  </th:block>
                  <th:block th:if="${#strings.isEmpty(dashboardConfig.cat2Cd)}"><td></td></th:block>
                  <th:block th:unless="${#strings.isEmpty(dashboardConfig.cat2Cd)}" th:each="commonCode:${session.commonCode.get('CAT2')}">
                    <td th:if="${commonCode.itemCd eq dashboardConfig.cat2Cd}" th:text="${commonCode.itemValue}"></td>
                  </th:block>
                  <th:block th:if="${#strings.isEmpty(dashboardConfig.cat3Cd)}"><td></td></th:block>
                  <th:block th:unless="${#strings.isEmpty(dashboardConfig.cat3Cd)}" th:each="commonCode:${session.commonCode.get('CAT3')}">
                    <td th:if="${commonCode.itemCd eq dashboardConfig.cat3Cd}" th:text="${commonCode.itemValue}"></td>
                  </th:block>
                  <td th:text="${dashboardConfig.menuUrl}"></td>
                  <td class="moveTd">
                    <input type="button" class="btn btn-sm btn-outline-dark upBtn" value="▲">
                    <input type="button" class="btn btn-sm btn-outline-dark downBtn" value="▼">
                  </td>
                </tr>
                </tbody>
              </table>
              <div class="row justify-content-between">
                <div class="col-auto">
                  <input type="button" class="btn btn-danger" id="configDeleteBtn" value="삭제">
                </div>
                <div class="col-auto">
                  <input type="button" class="btn btn-success" id="configAddBtn" value="추가">
                  <input type="button" class="btn btn-primary" id="configSaveBtn" value="저장">
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </main>
  <div class="modal fade" id="passwordModifyModal" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="passwordModifyModalLabel" aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <h5 class="modal-title" id="passwordModifyModalLabel">비밀번호 변경</h5>
          <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
        </div>
        <div class="modal-body mx-4">
          <form action="#" method="post" id="modifyPasswordForm">
            <div class="mb-3 row">
              <label for="password" class="col-sm-4 col-form-label text-end">현재 비밀번호</label>
              <div class="col-sm-7">
                <input type="password" class="form-control" id="password" name="password">
              </div>
            </div>
            <div class="mb-3 row">
              <label for="modifyPassword" class="col-sm-4 col-form-label text-end">새 비밀번호</label>
              <div class="col-sm-7">
                <input type="password" class="form-control" id="modifyPassword" name="modifyPassword">
              </div>
            </div>
            <div class="mb-3 row">
              <label for="passwordConfirm" class="col-sm-4 col-form-label text-end">새 비밀번호 확인</label>
              <div class="col-sm-7">
                <input type="password" class="form-control" id="passwordConfirm">
              </div>
            </div>
          </form>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">닫기</button>
          <button type="button" class="btn btn-primary" id="savePasswordBtn">저장</button>
        </div>
      </div>
    </div>
  </div>
  <div class="modal fade" id="menuModal" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="menuModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-xl modal-dialog-scrollable">
      <div class="modal-content">
        <div class="modal-header">
          <h5 class="modal-title" id="menuModalLabel">메뉴 추가</h5>
          <input type="hidden" id="modalUrl" value="/modal/menuModal">
          <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
        </div>
        <div class="modal-body" id="modalBody">
          <div class="row">
            <div class="col-12">
              <form method="get" action="#" id="modalSearchForm">
                <input type="hidden" name="pageIndex" id="pageIndex" value="1">
                <div class="row justify-content-between pe-3 py-1">
                  <div class="col-auto">
                    <input type="hidden" name="rowCnt" value="10">
                  </div>
                </div>
              </form>
            </div>
          </div>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-primary" id="getMenuBtn">추가</button>
          <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">닫기</button>
        </div>
      </div>
    </div>
  </div>
  <div class="modal fade" id="questionModal" tabindex="-1" aria-labelledby="questionModalLabel" aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <h1 class="modal-title fs-5" id="questionModalLabel">안내</h1>
          <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
        </div>
        <div class="modal-body">
          <p>대시보드에 노출될 게시판을 선택하여 저장합니다.</p>
          <p>저장에 제한은 없으나 상위 5건과 공지사항만 대시보드에 노출됩니다.</p>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
        </div>
      </div>
    </div>
  </div>
</div>
</html>