@model bitforum.Models.Views.PermissionsFormViewModel

@{
    ViewData["Title"] = $"{Model.RoleName}의 권한";
}

<div class="container">
    <partial name="_StatusMessage" />

    <form name="f_admin_write" id="fAdminWrite" method="post" accept-charset="utf-8" autocomplete="off" asp-action="ManagePermissions">
        <div class="card">
            <div class="card-header">
                <div class="row">
                    <div class="col">
                        <h2>@ViewData["Title"]</h2>
                        권한을 추가하거나 회수할 수 있습니다. <ins>Create: 읽기, View: 열람, Edit: 수정, Delete: 삭제</ins>
                    </div>
                    <div class="col-auto align-self-end">
                        <button type="submit" class="btn btn-success">저장</button>
                        <a asp-action="Index" class="btn btn-secondary">취소</a>
                    </div>
                </div>
            </div>

            <div class="card-body">
                <input type="hidden" asp-for="RoleID" />

                <div class="row">
                @for (int i = 0; i < Model.RoleClaims.Count; i++)
                {
                    var row = Model.RoleClaims[i].DisplayValue.Split('.');
                    var menuName = row[1];
                    var menuID = row[2];
                    var permission = row[3];

                    <div class="col-6 col-md-3 g-2">
                        <div class="card">
                            <div class="card-body">
                                <div class="form-check m-1">
                                    <input type="hidden" asp-for="@Model.RoleClaims[i].DisplayValue" />
                                    <input asp-for="@Model.RoleClaims[i].IsSelected" class="form-check-input" />
                                    <label class="form-check-label" asp-for="@Model.RoleClaims[i].IsSelected">
                                            @menuName - <span class="badge text-bg-light border">@permission</span>
                                    </label>
                                </div>
                            </div>
                        </div>
                    </div>
                }
                </div>

                <div asp-validation-summary="All" class="text-danger"></div>
            </div>

            <div class="card-footer text-center p-4">
                <button type="submit" class="btn btn-success">저장</button>
                <a asp-action="Index" class="btn btn-secondary">취소</a>
            </div>
        </div>

        <br/>
        <br/>
    </form>
</div>