@using ZelWiki.Models
@model ZelWiki.Models.ViewModels.Admin.PageModerateViewModel
@{
    Layout = "/Views/Shared/_Layout.cshtml";
    var sessionState = ViewData["SessionState"] as ZelWiki.SessionState ?? throw new Exception("Wiki State Context cannot be null.");
}

<h3>
    特殊标签页
</h3>

<p>
    浏览标有各种处理说明的页面，查看草稿、待删除、受保护等内容。<br /><br />
</p>

@if (!string.IsNullOrEmpty(Model.ErrorMessage))
{
    <div class="alert alert-danger">@Html.Raw(Model.ErrorMessage)</div>
}
@if (!string.IsNullOrEmpty(Model.SuccessMessage))
{
    <div class="alert alert-success">@Html.Raw(Model.SuccessMessage)</div>
}

@using (Html.BeginForm(null, null, FormMethod.Get, new { action = $"{GlobalConfiguration.BasePath}{Context.Request.Path}" }))
{
    <div class="container">
        <div class="row mb-3">
            <div class="col-md-6">
                @Html.DropDownListFor(m => m.Instruction,
                         new SelectList(Model.Instructions),
                         "选择",
                         new { @class = "form-control", id = "instructionDropdown" })
            </div>
            <div class="col-md-6">
                <button type="submit" class="btn btn-primary">搜索</button>
            </div>
        </div>
    </div>
    <br />

    @if (Model.Pages.Count > 0)
    {
        <table class="table fixedTable100 table-striped" border="0" width="100%" cellspacing="0" cellpadding="0">
            <thead>
                <tr>
                    <td><strong>名称</strong></td>
                    <td><strong>修订</strong></td>
                    <td><strong>修改人</strong></td>
                    <td><strong>上一次修改时间</strong></td>
                </tr>
            </thead>

            @foreach (var p in Model.Pages)
            {
                <tr>
                    <td><a href="@GlobalConfiguration.BasePath/@p.Navigation">@p.Name</a></td>
                    <td><a href="@GlobalConfiguration.BasePath/@p.Navigation/Revisions">@p.Revision</a></td>
                    <td>@p.ModifiedByUserName</td>
                    <td>@p.ModifiedDate</td>
                </tr>
            }
        </table>

        @Html.Raw(ZelWiki.Library.PageSelectorGenerator.Generate(Context.Request.QueryString, Model.PaginationPageCount))
    }
    else
    {
        <div class="d-flex small text-muted mb-0">
            <strong>
                暂无数据
            </strong>
        </div>
    }
}

<script>
    document.getElementById("instructionDropdown").addEventListener("change", function () {
        this.form.submit();
    });
</script>