@page
@model Admin.Pages.Forum.Board.List.IndexModel
@{
    ViewData["Title"] = "게시판 관리";
}

<div class="container-fluid">
    <h3>@ViewData["Title"]</h3>
    <hr />

    <partial name="_StatusMessage" />

    <div class="row g-2 align-items-end">
        <div class="col">
            Total : @Model.Total
        </div>
        <div class="col text-end">
            <button type="button" id="btnListDelete" class="btn btn-danger" disabled form="fAdminList">삭제</button>
            <button type="button" id="btnListUpdate" class="btn btn-primary" disabled form="fAdminList">수정</button>
            <a class="btn btn-success" asp-page="/Forum/Board/List/Write">추가</a>
        </div>
    </div>

    <div class="table-responsive">
        <form name="f_admin_list" id="fAdminList" method="post" accept-charset="utf-8" autocomplete="off"></form>

        <table class="table table-bordered mt-3">
            <colgroup>
                <col width="8%"/>
                <col width="15%"/>
                <col width="15%"/>
                <col width="*"/>
                <col width="*"/>
                <col width="*"/>
                <col width="*"/>
                <col width="*"/>
                <col width="11%"/>
            </colgroup>
            <thead>
                <tr>
                    <th rowspan="2">
                        <div class="form-check-inline me-0">
                            <input type="checkbox" id="checkedAll" class="form-check-input" value="1" form="fAdminList" />
                            <label for="checkedAll" class="form-check-inline">ID</label>
                        </div>
                    </th>
                    <th rowspan="2">분류</th>
                    <th rowspan="2">Code</th>
                    <th rowspan="2">제목</th>
                    <th rowspan="2">순서</th>
                    <th>검색 여부</th>
                    <th>게시글 수</th>
                    <th>등록일시</th>
                    <th rowspan="2">비고</th>
                </tr>
                <tr>
                    <th>사용 여부</th>
                    <th>댓글 수</th>
                    <th>수정일시</th>
                </tr>
            </thead>

                @if (Model.Data == null || !Model.Data.Any())
                {
                    <tbody>
                        <tr>
                            <td colspan="9">No Data.</td>
                        </tr>
                    </tbody>
                }
                else
                {
                    @foreach (var row in Model.Data)
                    {
                        var index = row.ID;

                        <tbody class="striped">
                            <tr>
                                <td rowspan="2">
                                    <div class="form-check-inline me-0">
                                        <input type="checkbox" name="ids[]" id="ids_@row.ID" class="form-check-input list-check-box" value="@row.ID" form="fAdminList" />
                                        <label for="ids_@row.ID" class="form-check-inline">@row.ID</label>
                                    </div>
                                </td>
                                <td rowspan="2">
                                    <select name="request[@index].BoardGroupID" class="form-select" required asp-items="@row.SelectBoardGroup" form="fAdminList"></select>
                                </td>
                                <td rowspan="2">
                                    <input type="text" name="request[@index].Code" class="form-control" required maxlength="70" value="@row.Code" form="fAdminList" />
                                </td>
                                <td rowspan="2">
                                    <input type="text" name="request[@index].Name" class="form-control" required maxlength="70" value="@row.Name" form="fAdminList" />
                                </td>
                                <td rowspan="2">
                                    <input type="number" name="request[@index].Order" class="form-control" required min="-999" max="9999" value="@row.Order" form="fAdminList" />
                                </td>
                                <td>
                                    <input type="checkbox" name="request[@index].IsSearch" class="form-check-input" checked="@row.IsSearch" value="true" form="fAdminList" />
                                </td>
                                <td>@row.Posts</td>
                                <td>@row.CreatedAt</td>
                                <td rowspan="2">
                                    <div class="d-xl-flex gap-2 justify-content-center d-grid">
                                        <a class="btn btn-sm btn-outline-info" href="@row.EditURL">수정</a>
                                        <a class="btn btn-sm btn-outline-danger btn-row-delete" data-id="@row.ID">삭제</a>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <input type="checkbox" name="request[@index].IsActive" class="form-check-input" checked="@row.IsActive" value="true" form="fAdminList" />
                                </td>
                                <td>@row.Comments</td>
                                <td>@row.UpdatedAt</td>
                            </tr>
                        </tbody>
                    }
                }
        </table>
    </div>
</div>