<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="RolesManagement.ascx.cs" Inherits="Zap.BI.Portal.Controls.Settings.RolesManagement" %>
<%@ Register TagPrefix="zap" TagName="ZapCheckBox" Src="~/Controls/UserControls/ZapCheckBox.ascx" %>

<input type="hidden" id="RoleMappingsField" runat="server" class="roleMappings" />
<table style="width: 100%;">
    <tr>
        <td valign="top" style="width: 60%;">
            <fieldset class="ui-fieldset">
                <legend>
                    <asp:Label runat="server" Text="<%$ Resources: Controls.Settings.SettingsText, Label_ExistingRoles %>" />
                </legend>
                <dxwgv:ASPxGridView Style="height: 100%;" runat="server" ID="RolesGridView" EnableCallBacks="false" Width="100%" KeyFieldName="LocalizedName"
                    OnCustomDataCallback="RolesGridView_CustomDataCallback"
                    OnCustomButtonCallback="RolesGridView_DeleteRole"
                    OnCustomButtonInitialize="RolesGridView_InitializeButton"
                    CssClass="large-rows has-filter has-resizable-columns"
                    Styles-Header-CssClass="grid-header-cell"
                    Styles-FilterCell-CssClass="grid-filter"
                    Styles-Row-CssClass="grid-row"
                    Styles-EmptyDataRow-CssClass="grid-empty"
                    Styles-Disabled-CssClass="is-disabled"
                    Styles-SelectedRow-CssClass="is-selected"
                    Styles-FocusedRow-CssClass="has-focus"
                    Styles-PagerBottomPanel-CssClass="grid-pager">
                    <Settings ShowFilterRow="True" ShowFilterRowMenu="False" ShowVerticalScrollBar="true" VerticalScrollableHeight="150" />
                    <SettingsBehavior AllowFocusedRow="true" ColumnResizeMode="Control" />
                    <SettingsCustomizationWindow Enabled="False" PopupHorizontalAlign="LeftSides" PopupVerticalAlign="TopSides" PopupHorizontalOffset="30" PopupVerticalOffset="30" />
                    <SettingsPager PageSize="2000" />
                    <Columns>
                        <dxwgv:GridViewDataColumn FieldName="LocalizedName" Caption="<%$ Resources: Controls.Settings.SettingsText, Label_RoleName %>" VisibleIndex="0" Width="100%" SortOrder="Ascending">
                            <Settings AutoFilterCondition="Contains" />
                        </dxwgv:GridViewDataColumn>
                        <dxwgv:GridViewCommandColumn VisibleIndex="1" Width="90">
                            <CustomButtons>
                                <dxwgv:GridViewCommandColumnCustomButton Text="<%$ Resources: Controls.Settings.SettingsText, Label_Delete %>" />
                            </CustomButtons>
                        </dxwgv:GridViewCommandColumn>
                    </Columns>
                    <Styles CssPostfix="DE">
                        <AlternatingRow Enabled="True" />
                    </Styles>
                </dxwgv:ASPxGridView>
                <br />
            </fieldset>
            <fieldset class="ui-fieldset">
                <legend>
                    <asp:Label runat="server" Text="<%$ Resources: Controls.Settings.SettingsText, Label_AddRole %>" />
                </legend>
                <table>
                    <tr>
                        <td>
                            <asp:Label ID="NewRole" runat="server" Text="<%$ Resources: Controls.Settings.SettingsText, Label_RoleName %>" CssClass="ui-form-label" /></td>
                        <td>
                            <asp:TextBox ID="NewRoleName" runat="server" Width="250" CssClass="ui-input-box" /></td>
                        <td>
                            <asp:Button ID="AddNewRole" runat="server" CssClass="button standardbutton" OnClick="AddNewRole_Click" Text="<%$ Resources: Controls.Settings.SettingsText, Label_Add %>" /></td>
                    </tr>
                    <tr>
                        <td></td>
                        <td colspan="2">
                            <asp:Label ID="AddRoleMessage" CssClass="SuccessLabel ui-text" runat="server" />
                        </td>
                    </tr>
                </table>
            </fieldset>
        </td>
        <td style="width: 40%;">
            <div style="overflow: auto;">
                <%--Area in which changes to inputs should register unsaved changes client side--%>
                <div class="unsavedChangesInputs">
                    <fieldset class="ui-fieldset">
                        <legend>
                            <asp:Label runat="server" Text="<%$ Resources: Controls.Settings.SettingsText, Label_Permissions %>" />
                        </legend>
                        <asp:Repeater ID="PermissionTypes" runat="server" OnItemDataBound="PermissionTypes_ItemDataBound">
                            <ItemTemplate>
                                <asp:Label ID="PermissionName" Text='<%#Eval("LocalizedPermissionsName")%>' runat="server" CssClass="ui-form-label" ToolTip='<%#Eval("LocalizedPermissionsDescription")%>' />
                                <asp:Repeater ID="PermissionActions" runat="server" OnItemDataBound="PermissionActions_ItemDataBound">
                                    <HeaderTemplate>
                                        <table>
                                    </HeaderTemplate>
                                    <ItemTemplate>
                                        <tr>
                                            <td title='<%# Eval("LocalizedPermissionActionDescription") %>'>
                                                <zap:ZapCheckBox runat="server" Value='<%# Eval("PermissionActionId")%>' CssClass="PermissionAction PermissionActionCheckBox RoleOptionControl ui-input" Text='<%# Eval("LocalizedPermissionAction") %>' />
                                                <div class="DependentPermissionActions">
                                                    <asp:Repeater ID="DependentPermissionActions" runat="server">
                                                        <HeaderTemplate>
                                                            <table>
                                                        </HeaderTemplate>
                                                        <ItemTemplate>
                                                            <tr>
                                                                <td title='<%# Eval("LocalizedPermissionActionDescription") %>'>
                                                                    <zap:ZapCheckBox runat="server" Value='<%# Eval("PermissionActionId")%>' CssClass="PermissionAction PermissionActionCheckBox RoleOptionControl ui-input" Text='<%# Eval("LocalizedPermissionAction") %>' />
                                                                </td>
                                                            </tr>
                                                        </ItemTemplate>
                                                        <FooterTemplate>
                                                            </table>
                                                        </FooterTemplate>
                                                    </asp:Repeater>
                                                </div>
                                            </td>
                                        </tr>
                                    </ItemTemplate>
                                    <FooterTemplate>
                                        </table>
                                    </FooterTemplate>
                                </asp:Repeater>
                                <br />
                            </ItemTemplate>
                        </asp:Repeater>
                    </fieldset>
                    <fieldset class="ui-fieldset">
                        <legend>
                            <asp:Label runat="server" Text="<%$ Resources: Controls.Settings.SettingsText, Label_FolderPermissions %>" />
                        </legend>
                        <asp:Repeater ID="FolderPermissionActions" runat="server">
                            <HeaderTemplate>
                                <table class="FolderPermissionActionsTable">
                                    <tr>
                                        <th></th>
                                        <th>
                                            <asp:Label runat="server" Text="<%$ Resources: Controls.Settings.SettingsText, Label_Public %>" />
                                        </th>
                                        <th>
                                            <asp:Label runat="server" Text="<%$ Resources: Controls.Settings.SettingsText, Label_Personal %>" />
                                        </th>
                                    </tr>
                            </HeaderTemplate>
                            <ItemTemplate>
                                <tr>
                                    <td class="ui-input" title='<%# Eval("LocalizedPermissionActionDescription") %>'>
                                        <asp:Label runat="server" Text='<%# Eval("LocalizedPermissionAction") %>' />
                                    </td>
                                    <td title="<%= Zap.BI.Portal.Controls.Settings.SettingsText.Tooltip_ApplyPermissionToPublicFolder %>" class="FolderPermissionActionCheckboxContainer">
                                        <zap:ZapCheckBox runat="server" Value='<%# Eval("PermissionActionId")%>'
                                            CssClass="FolderPermissionActionCheckBox PermissionActionCheckBox RoleOptionControl applyInPublic" />
                                    </td>
                                    <td title="<%= Zap.BI.Portal.Controls.Settings.SettingsText.Tooltip_ApplyPermissionToPersonalFolders %>" class="FolderPermissionActionCheckboxContainer">
                                        <zap:ZapCheckBox runat="server" Value='<%# Eval("PermissionActionId")%>'
                                            CssClass="FolderPermissionActionCheckBox PermissionActionCheckBox RoleOptionControl applyInPersonal"
                                            Visible='<%# !(bool)Eval("ApplyInPublicOnly") %>' />
                                    </td>
                                </tr>
                            </ItemTemplate>
                            <FooterTemplate>
                                </table>
                            </FooterTemplate>
                        </asp:Repeater>
                    </fieldset>
                </div>
            </div>
        </td>
    </tr>
</table>
<asp:PlaceHolder ID="PopupPlaceholder" runat="server" />
