<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="GeneralTaskFilter.ascx.cs" Inherits="APC.Forms.BaseUserControls.GeneralTaskFilter" %>
<%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
    <ext:FormPanel 
        ID="FormPanel" 
        runat="server"
        AutoHeight="true"
        AutoWidth="true"
        BodyPadding="0"
        DefaultAnchor="100%" Header=false BodyBorder=0 Border=false Layout=VBoxLayout>
        <LayoutConfig>
            <ext:VBoxLayoutConfig Align="Stretch" />   
        </LayoutConfig>
        <Items>
          <ext:ComboBox ID="cmbStatus" runat="server" Name="Status" EmptyText="All Statuses" Flex="1"  AllowBlank="true" ForceSelection="false"  MsgTarget="Side" FieldLabel="Status">
           <Triggers>
                <ext:FieldTrigger Icon="Clear" Qtip="Click to Reset Field" HideTrigger="false" />
            </Triggers>
        <Listeners>
        <TriggerClick Handler="resetFieldTrigger(this);"/>
        <Select Handler="showFieldTrigger(this);" />
        </Listeners>
          <Items>
              <ext:ListItem Text="Outstanding" Value="1" />
              <ext:ListItem Text="Completed" Value="2" />
           </Items>          
           </ext:ComboBox>
            <ext:ComboBox ID="cmbUsers" runat="server" Name="User" FieldLabel="User" EmptyText="Any User" AllowBlank="true" ForceSelection="false" MsgTarget="Side" DisplayField="Description" ValueField="Value" TypeAhead="true" ValueNotFoundText="Loading..." QueryMode="Local" Editable="false">
            <Triggers>
                <ext:FieldTrigger Icon="Clear" Qtip="Click to Reset Field" HideTrigger="false"/>
            </Triggers>
              <ListConfig MinWidth="400" />
                    <Store>
                   <ext:Store ID="UserStore" runat="server">
                    <Model>
                        <ext:Model ID="UserModel" runat="server" IDProperty="Value">
                        <Fields>
                            <ext:ModelField Name="Value" Type="String" Mapping="Value" />
                            <ext:ModelField Name="Description" Type="String" Mapping="Description" />
                        </Fields>
                    </ext:Model>
                </Model>
                </ext:Store>
            </Store>
            <Listeners>
                <TriggerClick Handler="resetFieldTrigger(this);"/>
                <Select Handler="showFieldTrigger(this);" />
            </Listeners>
          </ext:ComboBox>

           <ext:DisplayField ID="DisplayField2" Text="Assigned Date:" runat="server"/>
           <ext:FieldContainer ID="FieldContainer1"  runat="server" MsgTarget="Side" CombineErrors="true" Layout="VBoxLayout">
                   <LayoutConfig>
            <ext:VBoxLayoutConfig Align="Stretch" />   
        </LayoutConfig>

                <Defaults>
                    <ext:Parameter Name="Flex" Value="1" Mode="Raw" />
                    <ext:Parameter Name="HideLabel" Value="true" Mode="Raw" />
                </Defaults>
                <Items>
                    <ext:DateField ID="dteAssignFrom" runat="server" FieldLabel="Start" Name="StartDate" AllowBlank="true" MarginSpec="0 0 5 0" EmptyText="Select a Date Range Start">
                        <Triggers>
                        <ext:FieldTrigger Icon="Clear" Qtip="Click to Reset Field" HideTrigger="true" />
                        </Triggers>
                        <Listeners>
                        <TriggerClick Handler="resetFieldTrigger(this);"/>
                        <Change Handler="showFieldTrigger(this);" />
                        </Listeners>
                    </ext:DateField>

                    <ext:DateField ID="dteAssignTo" runat="server" FieldLabel="End" Name="EndDate" EmptyText="Select a Date Range End" AllowBlank="true">
                                            <Triggers>
                        <ext:FieldTrigger Icon="Clear" Qtip="Click to Reset Field" HideTrigger="true" />
                        </Triggers>

                                <Listeners>
                <TriggerClick Handler="resetFieldTrigger(this);"/>
                <Change Handler="showFieldTrigger(this);" />
            </Listeners>
            </ext:DateField>

                </Items>
            </ext:FieldContainer>
            <ext:FieldSet 
                runat="server"
                Title="Flow Information"
                Collapsible="true"
                DefaultAnchor="100%" Layout="VBoxLayout" ID="ctl53">
                <LayoutConfig>
                    <ext:VBoxLayoutConfig Align="Stretch" />   
                </LayoutConfig>
                <Items>
                <ext:ComboBox ID="cmbProcess" runat="server" Name="Process" FieldLabel="Process" EmptyText="All Processes" AllowBlank="true" ForceSelection="false" MsgTarget="Side" DisplayField="Description" ValueField="Value" TypeAhead="true" ValueNotFoundText="Loading..." QueryMode="Local" Editable="false">
                <ListConfig MinWidth="400" />
                <Store>
                    <ext:Store ID="ProcessStore" runat="server">
                    <Model>
                        <ext:Model ID="ProcessModel" runat="server" IDProperty="Value">
                        <Fields>
                            <ext:ModelField Name="Value" Type="String" Mapping="Value" />
                            <ext:ModelField Name="Description" Type="String" Mapping="Description" />
                        </Fields>
                    </ext:Model>
                </Model>
           </ext:Store>
           </Store>
          <Listeners>
                <TriggerClick Handler="resetFieldTrigger(this);"/>
                <Select Handler="#{cmbStep}.clearValue(); #{cmbStep}.setDisabled(false);#{StepStore}.reload();#{cmbStep}.focus(false, 100);showFieldTrigger(this);" />
          </Listeners>
          <Triggers>
              <ext:FieldTrigger Icon="Clear" Qtip="Click to Reset Field" HideTrigger="true" />
          </Triggers>

          </ext:ComboBox>
          <ext:ComboBox ID="cmbStep" runat="server" Name="Step" FieldLabel="Step" EmptyText="Select a Process Step" AllowBlank="true" ForceSelection="false" MsgTarget="Side" DisplayField="Description" ValueField="Value" TypeAhead="true" ValueNotFoundText="Loading..." QueryMode="Local" Editable="false">
          <ListConfig MinWidth="400" />
           <Store>
                <ext:Store ID="StepStore" runat="server" OnReadData="StepRefresh">
                <Model>
                    <ext:Model ID="StepModel" runat="server" IDProperty="Value">
                        <Fields>
                            <ext:ModelField Name="Value" Type="String" Mapping="Value" />
                            <ext:ModelField Name="Description" Type="String" Mapping="Description" />
                        </Fields>
                    </ext:Model>
                </Model>
                </ext:Store>
          </Store>
          <Listeners>
           <TriggerClick Handler="resetFieldTrigger(this);"/>
           <Select Handler="showFieldTrigger(this);" />
          </Listeners>
          <Triggers>
              <ext:FieldTrigger Icon="Clear" Qtip="Click to Reset Field" HideTrigger="true" />
          </Triggers>
          </ext:ComboBox>
          <ext:TriggerField ID="txtFilterDesc" runat="server" EmptyText="Enter a Partial Description" AllowBlank=true FieldLabel="Partial Description" Name="Description">
                <Listeners>
                <TriggerClick Handler="resetFieldTrigger(this);"/>
                <Change Handler="showFieldTrigger(this);" />
                </Listeners>
                          <Triggers>
              <ext:FieldTrigger Icon="Clear" Qtip="Click to Reset Field" HideTrigger="true" />
          </Triggers>

            </ext:TriggerField>
               </Items>
            </ext:FieldSet>
        </Items>        
        <Buttons>
              <ext:Button runat="server" Text="Clear Filters" Icon="Cancel" ID="btnReset" Disabled="true">
              <DirectEvents>
              <Click OnEvent="btnClear_Click" />
              </DirectEvents>
             </ext:Button>
            <ext:Button runat="server" Text="Apply" Icon="Accept" ID="btnAccept">
            <DirectEvents>
                <Click Success="#{btnReset}.setDisabled(false);#{TaskPanel}.store.reload();" OnEvent="btnAccept_Click">
                    <EventMask ShowMask="true" Msg="Applying Filter..." MinDelay="500" />
                     <ExtraParams>
                        <ext:Parameter Name="values" Value="#{FormPanel}.getForm().getValues()" Mode="Raw" Encode="true"/>
                    </ExtraParams>
                </Click>
            </DirectEvents>

            </ext:Button>     
         </Buttons>       
    </ext:FormPanel>
