<%@ Import Namespace="DevProcess.Common.Utils" %>

<%@ Page Language="C#" MasterPageFile="~/2ColMaster.Master" AutoEventWireup="true"
    CodeBehind="ProcessTypes.aspx.cs" Inherits="ProcessDefinition.ProcessTypes" Title="Process types" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentMain" runat="server">
    <asp:Panel ID="pnlProcTypes" runat="server">
        <asp:ObjectDataSource ID="odsItems" runat="server" OldValuesParameterFormatString="original_{0}"
            SelectMethod="GetProcessTypes" TypeName="DevProcess.ProcessDefinitionService.ProcessDefinitionManager">
            <SelectParameters>
                <asp:Parameter Name="repositoryName" Type="String" />
            </SelectParameters>
        </asp:ObjectDataSource>
        <asp:ListView ID="lstItems" runat="server" ItemPlaceholderID="itemList" EnableViewState="False"
            DataSourceID="odsItems">
            <LayoutTemplate>
                <h2>
                    Process library types</h2>
                <ul>
                    <asp:PlaceHolder ID="itemList" runat="server" />
                </ul>
            </LayoutTemplate>
            <ItemTemplate>
                <li class='pSum'>
                    <%# GetTypeIconHtml(Eval("ProcessTypeId"))%>
                
                    <asp:LinkButton ID="lbProcessType" runat="server" Text='<%#StringHelper.Format("{0:multilinenourl}",Eval("ProcessTypeName")) %>'
                        CommandArgument='<%#Eval("ProcessTypeId") %>' OnCommand="lbProcessType_Click" />
                    <asp:LinkButton ID="lbMetrics" runat="server" Text=' [common metadata]' CommandArgument='<%#Eval("ProcessTypeId") %>'
                        OnCommand="lbMetrics_Click" />
                        
                    <span class="processTypeDelete ui-icon ui-icon-trash" ptid='<%# Eval("ProcessTypeId") %>'
                        title='<%# "Delete process type: " + StringHelper.Format("{0:multilinenourl}",Eval("ProcessTypeName")) %>'>
                    </span> 
                </li>
            </ItemTemplate>
            <EmptyDataTemplate>
            </EmptyDataTemplate>
        </asp:ListView>
        <asp:Button ID="btnNewType" runat="server" Text="New type" CausesValidation="false" OnClick="btnNewType_Click" />
    </asp:Panel>

    <asp:Panel ID="pnlMetrics" runat="server" Visible="false">
        <h2>
            <asp:Literal ID="litCommonMetrics" runat="server" /></h2>
        <p class="hBlurb ui-state-highlight">
            These fields will be collected for all process library definitions based on this type.</p>
            
        <dp:MetadataEditorControl ID="mdeMetrics" runat="server" ForeignType="11" ShowEditButtons="true"
            AllowMandatory="false" CssClass="metadataEditor" LabelColumnSize="40" CreateButtonText="Edit metadata"
            DefaultViewMode="Insert" ValidationGroup="metricGrp" HasEditModeDelete="true" />
        <br />
        
        <asp:Button ID="btnFinishMetrics" runat="server" Text="Save Common Metadata" OnClick="btnSaveCommonMetadata_Click"  />
        <asp:Button ID="btnCancelMetadata" runat="server" Text="Cancel" CausesValidation="false" OnClick="btnCancel_Click" />
    </asp:Panel>
                    
    <div id="dialogProcessInUse" title="Process type in use.">
        <p>
            <span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span>
            This process library type is in use and cannot be deleted.</p>
    </div>
    <div id="dialogDeleteConfirmation" title="Delete process type.">
        <p>
            <span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span>
            Are you sure you want to delete this process library type?</p>
    </div>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentOptions" runat="server">
    <ul class='ui-widget-content'>
        <li class="btn"><span class="ui-icon ui-icon-arrowreturnthick-1-w"></span><a runat="server"
            id="hlBack" href='<%=pd.R.GetReposRoot() %>'>Back to library</a></li>
    </ul>
    <ul class='ui-widget-content'>
        <li class="btn"><span class="ui-icon ui-icon-shuffle"></span><a
             href='<%=pd.R.GetReposRoot() %>/Library/ProcessMetaModel'>Process metamodel</a></li>
    </ul>
</asp:Content>
