@page "{id:int}"
@model Admin.Pages.Popup.EditModel
@{
    ViewData["Title"] = "팝업 수정";
}

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

    <partial name="_StatusMessage" />
    <partial name="_Editor" />

    <form id="fAdminWrite" method="post" accept-charset="utf-8" autocomplete="off">
        <input type="hidden" asp-for="Input.ID" />
        <input type="hidden" asp-for="QueryString" />

        <div class="row mb-2">
            <label asp-for="Input.PositionID" class="col-sm-2 col-form-label"><span class="text-danger">*</span> 위치</label>
            <div class="col-sm-10">
                <div class="row">
                    <div class="col col-md-auto">
                        <select asp-for="Input.PositionID" asp-items="Model.Positions" class="form-select" required>
                            <option value="">-- 선택 --</option>
                        </select>
                    </div>
                </div>
                <span asp-validation-for="Input.PositionID" class="text-danger"></span>
            </div>
        </div>
        <div class="row mb-2">
            <label asp-for="Input.Subject" class="col-sm-2 col-form-label"><span class="text-danger">*</span> 제목</label>
            <div class="col-sm-10">
                <input asp-for="Input.Subject" class="form-control" required />
                <span asp-validation-for="Input.Subject" class="text-danger"></span>
            </div>
        </div>
        <div class="row mb-2">
            <label asp-for="Input.Content" class="col-sm-2 col-form-label">내용</label>
            <div class="col-sm-10">
                <textarea asp-for="Input.Content" class="form-control ck-editor"></textarea>
                <span asp-validation-for="Input.Content" class="text-danger"></span>
            </div>
        </div>
        <div class="row mb-2">
            <label asp-for="Input.Link" class="col-sm-2 col-form-label">주소</label>
            <div class="col-sm-10">
                <input asp-for="Input.Link" class="form-control" />
                <span asp-validation-for="Input.Link" class="text-danger"></span>
                <span class="text-muted form-text">
                    팝업 클릭 시 이동할 주소를 설정합니다.
                </span>
            </div>
        </div>
        <div class="row mb-2">
            <label asp-for="Input.Order" class="col-sm-2 col-form-label"><span class="text-danger">*</span> 순서</label>
            <div class="col-sm-10">
                <div class="row">
                    <div class="col col-md-auto">
                        <input asp-for="Input.Order" class="form-control" type="number" min="-9999" max="9999" required />
                    </div>
                </div>
                <span asp-validation-for="Input.Order" class="text-danger"></span>
            </div>
        </div>
        <div class="row mb-2">
            <label class="col-sm-2 col-form-label">사용 기간</label>
            <div class="col-sm-10">
                <div class="row g-2">
                    <div class="col col-md-auto">
                        <input asp-for="Input.StartAt" class="form-control" type="datetime-local" />
                        <span asp-validation-for="Input.StartAt" class="text-danger"></span>
                    </div>
                    <div class="col-auto d-none d-md-block align-self-center">~</div>
                    <div class="col col-md-auto">
                        <input asp-for="Input.EndAt" class="form-control" type="datetime-local" />
                        <span asp-validation-for="Input.EndAt" class="text-danger"></span>
                    </div>
                </div>
                <span class="text-muted form-text">
                    사용 기간을 설정하지 않으면 무기한으로 노출됩니다.
                </span>
            </div>
        </div>
        <div class="row mb-2">
            <label asp-for="Input.IsActive" class="col-sm-2 col-form-label">사용 여부</label>
            <div class="col-sm-10 align-content-center">
                <div class="form-check-inline">
                    <input type="checkbox" asp-for="Input.IsActive" class="form-check-input" />
                    <label class="form-check-label" asp-for="Input.IsActive">사용합니다.</label>
                    <span asp-validation-for="Input.IsActive" class="text-danger"></span>
                </div>
            </div>
        </div>

        @if (Model.Input.UpdatedAt is not null)
        {
            <div class="row mb-2">
                <label class="col-sm-2 col-form-label">수정일시</label>
                <div class="col-sm-10">
                    <input asp-for="Input.UpdatedAt" class="form-control-plaintext" type="text" readonly />
                </div>
            </div>
        }
        @if (Model.Input.CreatedAt is not null)
        {
            <div class="row mb-2">
                <label class="col-sm-2 col-form-label">등록일시</label>
                <div class="col-sm-10">
                    <input asp-for="Input.CreatedAt" class="form-control-plaintext" type="text" readonly />
                </div>
            </div>
        }

        <hr />
        <div class="d-grid gap-2 text-center d-md-block">
            <button type="submit" class="btn btn-success">수정</button>
            <a href="/Popup?@Model.QueryString" class="btn btn-secondary">취소</a>
        </div>
        <br />
    </form>
</div>

@section Scripts {
    @{

    }
}