<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="List.aspx.cs" Inherits="eDocument.Server.Administrator.User.List" MasterPageFile="~/Site.Master" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="Server">
    
    <h1 class="skjema-admin__page-title">
        Brukere
    </h1>

    <div class="mb-2">
        <a href="Invite.aspx">
            Inviter ny bruker
        </a>
    </div>
    <br/>

    <div>
        <asp:Label 
            runat="server" 
            ID="lblMessage" 
            ForeColor="Red">
        </asp:Label>

        <asp:GridView 
            runat="server" 
            ID="grid"
            DataKeyNames="Id"
            ItemType="eDocument.Server.Administrator.User.AdminUserWithCustomerRoles"
            AutoGenerateEditButton="False"
            SelectMethod="GetData"
            OnRowCommand="grid_OnRowCommand"
            CssClass="skjema-admin__table"
            Border="0"
            AutoGenerateColumns="false">

            <Columns>
                <asp:DynamicField DataField="Id" Visible="False" />
                <asp:DynamicField DataField="Username" HeaderText="E-post (brukernavn)" />
                <asp:DynamicField DataField="DisplayName" HeaderText="Navn"/>
                <asp:DynamicField DataField="Email" Visible="False"/>
                <%--<asp:DynamicField DataField="Roles" />--%>
                <asp:TemplateField HeaderText="Roller og tilganger">
                    <ItemTemplate>
                        <%# ConvertToDisplayFriendlyRoles(Eval("Roles"))%>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:LinkButton runat="server" CommandName="Action" ID="btnRevokeAccess" Text="Fjern tilgang" OnCommand="btnRevokeAccess_OnClick" CommandArgument='<%#Bind("Id") %>'>Fjern tilgang</asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemTemplate>
                        <a href='Edit.aspx?id=<%#Eval("Id")%>'>Endre</a>
                        <%--<asp:linkbutton id="btnEdit" runat="server" commandname="Edit" text="Edit" />--%>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
    </div>

    <asp:Panel ID="pnlWarn" Visible="False" runat="server" CssClass="skjema-admin__modal" data-jscomponent="modal">
        <div class="skjema-admin__modal__window">

            <button class="skjema-admin__modal__close" type="button" data-jscomponent="modalClose"></button>

            <asp:Label CssClass="skjema-admin__page__label" Text="Ønsker du å fjerne brukeren fra organisasjonen?" runat="server" />

            <br/>

            <span>
                <asp:Button CssClass="skjema-admin__button skjema-admin__button--primary" runat="server" ID="btnConfirmRemoveUser" OnClick="btnConfirmRemoveUser_OnClick" Text="Ja, fjern brukeren" />
            </span>

            &nbsp;&nbsp;

            <span>
                <asp:Button CssClass="skjema-admin__button skjema-admin__button--secondary" runat="server" ID="btnAbortRemoveUser" OnClick="btnCancelRmoveUser_OnClick" Text="Nei" />
            </span>
        </div>
    </asp:Panel>
</asp:Content>
