<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="AddAttachment.ascx.cs" Inherits="APC.Forms.BaseUserControls.AddAttachment" %>
<%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
<ext:Window ID="Window1" Height="150" Width="400" Title="Add Attachment" Closable="true" CloseAction=Hide Layout="FitLayout" Plain=true runat="server" Hidden=true>
 <Listeners>
 <Close Handler="#{grdAttach}.store.reload();"></Close>
 </Listeners>
 <Loader Mode="Frame" AutoLoad="false" DisableCaching=true/>
<Items>
 <ext:FormPanel 
            ID="BasicForm" 
            runat="server"
            Width="500"
            Frame="true"
            Title="Upload an Attachment"
            AutoHeight="true"
            PaddingSummary="0px 0px 0px 0px"
            LabelWidth="50" Header=false>                
            <Defaults>
                <ext:Parameter Name="anchor" Value="95%" Mode="Value" />
                <ext:Parameter Name="allowBlank" Value="false" Mode="Raw" />
                <ext:Parameter Name="msgTarget" Value="side" Mode="Value" />
            </Defaults>
            <Items>
                <ext:TextField ID="txtDescription" runat="server" FieldLabel="Description" EmptyText="Please provide a Description" AllowBlank="false"/>
                <ext:FileUploadField 
                    ID="FileUploadField1" 
                    runat="server" 
                    EmptyText="Select an attachment"
                    FieldLabel="Path"
                    ButtonText=""
                    Icon="ImageAdd">
                </ext:FileUploadField>
            </Items>
            <Listeners>
                <ValidityChange Handler="#{SaveButton}.setDisabled(!valid);" />
            </Listeners>
            <Buttons>
                <ext:Button ID="SaveButton" runat="server" Text="Save" Disabled="true">
                    <DirectEvents>
                        <Click OnEvent="UploadClick"
                            Before="if (!#{BasicForm}.getForm().isValid()) { return false; } 
                            Ext.Msg.wait('Uploading your Attachment...', 'Uploading');"                                
                            Failure="Ext.Msg.show({ title   : 'Error',   msg : 'Error during uploading',  minWidth: 200, modal   : true, icon    : Ext.Msg.ERROR, buttons : Ext.Msg.OK  });"
                            Success="Ext.Msg.hide();#{Window1}.close();">
                        </Click>
                    </DirectEvents>
                </ext:Button>
            </Buttons>
        </ext:FormPanel>
        </Items>
</ext:Window>
