@model ChapterEditViewModel
@{
    ViewData["Title"] = Model.ChapterID == 0 ? "New Chapter" : "Edit Chapter";
}

<div class="page-heading compact">
    <div>
        <p class="eyebrow">@Model.Book?.BookTitle</p>
        <h1>@ViewData["Title"] <help-icon key="chapters.edit" /></h1>
    </div>
    <a class="btn btn-outline-secondary" asp-controller="Books" asp-action="Details" asp-route-id="@Model.BookID">Back to book</a>
</div>

<form asp-action="Save" method="post" class="edit-panel">
    <input asp-for="ChapterID" type="hidden" />
    <input asp-for="BookID" type="hidden" />
    <div asp-validation-summary="ModelOnly" class="text-danger"></div>
    <div class="row g-3">
        <div class="col-md-3">
            <label asp-for="ChapterNumber" class="form-label">Chapter number <help-icon key="chapters.fields.chapterNumber" mode="inline" /></label>
            <input asp-for="ChapterNumber" class="form-control" />
        </div>
        <div class="col-md-3">
            <label asp-for="ChapterTitle" class="form-label"></label>
            <input asp-for="ChapterTitle" class="form-control" />
            <span asp-validation-for="ChapterTitle" class="text-danger"></span>
        </div>
        <div class="col-md-3">
            <label asp-for="RevisionStatusID" class="form-label">Revision status <help-icon key="chapters.fields.revisionStatus" mode="inline" /></label>
            <select asp-for="RevisionStatusID" asp-items="Model.RevisionStatuses" class="form-select"></select>
        </div>
        <div class="col-md-3">
            <label asp-for="ChapterPurposeID" class="form-label"></label>
            <select asp-for="ChapterPurposeID" asp-items="Model.ChapterPurposes" class="form-select"></select>
        </div>
        <div class="col-12">
            <label asp-for="Summary" class="form-label"></label>
            <textarea asp-for="Summary" class="form-control" rows="4"></textarea>
        </div>
    </div>
    <button class="btn btn-primary mt-3" type="submit">Save chapter</button>
</form>

@section Scripts {
    <partial name="_ValidationScriptsPartial" />
}
