@using MrCMS.ACL
@model MrCMS.Web.Areas.Admin.Models.ACLModel
@{
    ViewBag.Title = "ACL";
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
    var settings = ViewData["settings"] as ACLSettings;
}
@using (Html.BeginForm())
{
    <fieldset>
        <legend>ACL
            <span class="btn-group display-inline pull-right">
                @if (settings.ACLEnabled)
                {
                    @Html.ActionLink("Disable ACL", "Disable", "ACL", null, new { id = "disable-acl", @class = "btn btn-default" })
                }
                else
                {
                    @Html.ActionLink("Enable ACL", "Enable", "ACL", null, new { id = "enable-acl", @class = "btn btn-default" })
                }
                <input class="btn btn-primary" type="submit" value="Update" />
            </span>
        </legend>
    </fieldset>
    <div class="row">
        <div class="col-lg-12">
            @if (settings.ACLEnabled)
            {
                <h3>@Resource("Admin ACL Features", "Features")</h3>
                Html.RenderPartial("Group", new ViewDataDictionary(Model.Features) { { "roles", Model.Roles } });
                <hr />
                <h2>@Resource("Admin ACL Webpages", "Webpages")</h2>
                Html.RenderPartial("Group", new ViewDataDictionary(Model.Webpages) { { "roles", Model.Roles } });
                <hr />
                <h2>@Resource("Admin ACL Widgets", "Widgets")</h2>
                Html.RenderPartial("Group", new ViewDataDictionary(Model.Widgets) { { "roles", Model.Roles } });
            }
            else
            {
                <p>@Resource("Admin ACL Disabled", "ACL is disabled").</p>
            }
        </div>
    </div>
}
@section JavaScriptBlock
{
    <script>
        $(function () {
            $('#disable-acl').click(function () {
                post_to_url($(this).attr('href'), {});
                return false;
            });
            $('#enable-acl').click(function () {
                post_to_url($(this).attr('href'), {});
                return false;
            });
        })
    </script>
}
