@page
@model Admin.Pages.Banner.List.WriteModel
@{
    ViewData["Title"] = "배너 등록";
}

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

    <partial name="_StatusMessage" />

    <form id="fAdminWrite" method="post" accept-charset="utf-8" autocomplete="off" enctype="multipart/form-data">
        <div class="row mb-2">
            <label asp-for="Input.PositionID" class="col-sm-2 col-form-label"><span>*</span> 배너 위치</label>
            <div class="col-sm-10">
                <div class="row">
                    <div class="col col-md-auto">
                        <select asp-for="Input.PositionID" class="form-select" asp-items="Model.Positions" required></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>*</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.Link" class="col-sm-2 col-form-label"></label>
            <div class="col-sm-10">
                <input asp-for="Input.Link" class="form-control" type="url" />
                <span asp-validation-for="Input.Link" 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="mb-3">
                    <label asp-for="Input.DesktopImageFile" class="form-label">Desktop</label>
                    <div id="DesktopBannerPrev" hidden>
                        <img class="img-fluid img-thumbnail" alt="이미지(Desktop) 미리보기" /><br/>
                        <button type="button" class="btn btn-sm btn-danger mt-2 mb-2 btn-remove-preview">삭제</button>
                    </div>
                    <input asp-for="Input.DesktopImageFile" type="file" class="form-control" accept="image/*" />
                    <span asp-validation-for="Input.DesktopImageFile" class="text-danger"></span>
                </div>
                <div>
                    <label asp-for="Input.MobileImageFile" class="form-label">Mobile</label>
                    <div id="MobileBannerPrev" hidden>
                        <img class="img-fluid img-thumbnail" alt="이미지(Mobile) 미리보기" /><br/>
                        <button type="button" class="btn btn-sm btn-danger mt-2 mb-2 btn-remove-preview">삭제</button>
                    </div>
                    <input asp-for="Input.MobileImageFile" type="file" class="form-control" accept="image/*" />
                    <span asp-validation-for="Input.MobileImageFile" class="text-danger"></span>
                </div>
            </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" />
                        <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" />
                        <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>
        <hr />
        <div class="row">
            <div class="col text-center p-3">
                <button type="submit" class="btn btn-success">저장</button>
                <a href="/Banner/List?@Model.QueryString" class="btn btn-secondary">취소</a>
            </div>
        </div>
        <br/>
    </form>
</div>
@section Scripts {
    <script>
        setupImagePreview("Input_DesktopImageFile", "DesktopBannerPrev");
        setupImagePreview("Input_MobileImageFile", "MobileBannerPrev");
    </script>
}