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

<asp:Content ID="Content1" ContentPlaceHolderID="ContentMain" runat="server">
    <dp:ValidatedTextBox ID="txtTitle" runat="server" LabelText="Title" Columns="100" />
    <div id="tabs" class="ui-tabs ui-widget ui-widget-content ui-corner-all">
        <dp:DpPanel ID="pnlEditTabs" runat="server" Visible="false" PanelTagKey="">
            <ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
                <li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active"><a href="#tabsDesc">Edit</a></li>
                <li class="ui-state-default ui-corner-top"><a href="#tabsProperties">Properties</a></li>
                <li class="ui-state-default ui-corner-top"><a href="#tabsUsage">Usage Properties</a></li>
                <li class="ui-state-default ui-corner-top"><a href="#tabsSteps" class="stepsTab">Steps</a></li>
                <li class="ui-state-default ui-corner-top"><a href="#tabsMetrics">Project Metadata</a></li>
            </ul>
        </dp:DpPanel>
        <dp:DpPanel ID="pnlCreateTabs" runat="server" Visible="false" PanelTagKey="">
            <ul>
                <li><a href="#tabsDesc">Description</a></li>
            </ul>
        </dp:DpPanel>
        <div id="tabsDesc" class="ui-tabs-panel ui-widget-content ui-corner-bottom">

            <div class="postBody">
            
            <div class='templateBody'>
            
                <h2>Description<span id='postEditDescToggle' title='Edit' class='edit ui-icon ui-icon-pencil'></span></h2>
                
                <div id='postEditorDescEdit' style="display: none;">
                <dp:DpHtmlEditorMce ID="htmlDesc" runat="server" CssClass="htmlEditor" EditorHeight="450px" EditorWidth="100%" ShowHtmlMode="true" EnableViewState="false">
                    <CustomUserCommands>
                        <dp:CustomUserCommand UserCommand="Processes" CommandDialog="~/EditorModals/InsertProcessLink.aspx?type=Tool"
                            CommandTitle="Insert Process Link" ButtonUrl="~/App_Themes/Default/images/InsertAnchor.gif"
                            DialogWidth="850" DialogHeight="650" />
                        <dp:CustomUserCommand UserCommand="Images" CommandDialog="~/EditorModals/InsertImageLink.aspx"
                            CommandTitle="Insert Image Link" ButtonUrl="~/App_Themes/Default/images/ImageManager.gif"
                            DialogWidth="850" DialogHeight="600" />
                        <dp:CustomUserCommand UserCommand="Files" CommandDialog="~/EditorModals/InsertFilesLink.aspx"
                            CommandTitle="Insert File Link" ButtonUrl="~/App_Themes/Default/images/TemplateManager.gif"
                            DialogWidth="850" DialogHeight="640" />
                    </CustomUserCommands>
                </dp:DpHtmlEditorMce>
                </div>
                
                <div class='postEditor'>
                    <div id='postEditorDescView'>
                    <asp:Literal runat="server" ID="litPostDescription" EnableViewState="false" />
                    
                    </div>
                    <br class='clear' />
                    
                    <h2>Sections</h2>
                        
                    <div class='templateSections' id="procEditTempSect">
                        <asp:Literal runat="server" ID="litPostBody" EnableViewState="false" />
                    </div>
                </div>


    <div id="dlgLinkProperties" title="Link properties" style="display:none;">
        <iframe id="ifLinkProperties" scrolling="no" frameborder="0" width="750px" height="500px"></iframe>      
    </div>

            </div>
            
            <div id='templateHtml' style='display:none;' >
                <asp:Literal runat="server" ID="litTemplateHtml" EnableViewState="false" />
            </div>

                <script id="sectionTemplate" type="text/x-jquery-tmpl">
                    <div>
                        <h2 data-direction="${direction}" data-multiplicity="${multiplicity}"  data-linktypeid="${linktypeid}" data-linktypename="${linktypename}"><a href="#">${sectionName}</a></h2>
                        <div class='section'>
                            <span class="editBar"><span class="edit blueIcon ui-icon ui-icon-pencil" title="Edit section"></span><span class="delete blueIcon ui-icon ui-icon-close" title="Delete section"></span></span>
                            <div class='content'>
                                <blockquote class='tutorialText'>${tutorialText}</blockquote>
                                {{html sectionContent}}
                            </div>
                        </div>                    
                    </div>
                </script>
            
            <style>
                .modalBackground
                {
                    background-color: #453423;
                    filter: alpha(opacity=40);
                    opacity: 0.5;
                }
                .ModalWindow
                {
                    border: solid1px#c0c0c0;
                    background: #f0f0f0;
                    padding: 0px10px10px10px;
                    position: absolute;
                    top: -1000px;
                }
            </style>
                    <a href="#" style="display: none; visibility: hidden;" id="dummyLink" runat="server">
                        dummy</a>
                    <ajax:ModalPopupExtender ID="btn_test_ModalPopupExtender" runat="server" DynamicServicePath=""
                        Enabled="True" PopupControlID="panelPopup" TargetControlID="dummyLink" BackgroundCssClass="modalBackground"
                        CancelControlID="btnCancel" PopupDragHandleControlID="panEdit">
                    </ajax:ModalPopupExtender>
                    <asp:Panel runat="server" ID="panelPopup" CssClass="ModalWindow sectionModalWindow">
                        <h3 id='sectionName'>Name</h3>
                        <dp:DpHtmlEditorMce ID="htmlSectionEdit" runat="server" CssClass="htmlEditor" EditorHeight="350px" EditorWidth="100%" ShowHtmlMode="true" EnableViewState="false">
                            <CustomUserCommands>
                                <dp:CustomUserCommand UserCommand="Processes" CommandDialog="~/EditorModals/InsertProcessLink.aspx?type=Tool"
                                    CommandTitle="Insert Process Link" ButtonUrl="~/App_Themes/Default/images/InsertAnchor.gif"
                                    DialogWidth="850" DialogHeight="650" />
                                <dp:CustomUserCommand UserCommand="Images" CommandDialog="~/EditorModals/InsertImageLink.aspx"
                                    CommandTitle="Insert Image Link" ButtonUrl="~/App_Themes/Default/images/ImageManager.gif"
                                    DialogWidth="850" DialogHeight="600" />
                                <dp:CustomUserCommand UserCommand="Files" CommandDialog="~/EditorModals/InsertFilesLink.aspx"
                                    CommandTitle="Insert File Link" ButtonUrl="~/App_Themes/Default/images/TemplateManager.gif"
                                    DialogWidth="850" DialogHeight="640" />
                            </CustomUserCommands>
                        </dp:DpHtmlEditorMce>
                        <input id="editDlgOK" type="button" onclick="UpdateLinkFromDlg();" value="Update"
                            class="ui-corner-all ui-state-default dpButton" />
                        <asp:Button ID="btnCancel" runat="server" Text="Cancel" />
                    </asp:Panel>


            
<div id= "editorWrapper" >   


            <dp:DpHtmlEditorMce ID="hBody" runat="server" CssClass="htmlEditor" EditorHeight="700px"
                EditorWidth="100%" ShowHtmlMode="true" EnableViewState="false">       
                
                    <CustomUserCommands>
                            <dp:CustomUserCommand UserCommand="Processes" CommandDialog="~/EditorModals/InsertProcessLink.aspx?type=Tool"
                                CommandTitle="Insert Process Link" ButtonUrl="~/App_Themes/Default/images/InsertAnchor.gif"
                                DialogWidth="850" DialogHeight="650" />
                            <dp:CustomUserCommand UserCommand="Images" CommandDialog="~/EditorModals/InsertImageLink.aspx"
                                CommandTitle="Insert Image Link" ButtonUrl="~/App_Themes/Default/images/ImageManager.gif"
                                DialogWidth="850" DialogHeight="600" />
                            <dp:CustomUserCommand UserCommand="Files" CommandDialog="~/EditorModals/InsertFilesLink.aspx"
                                CommandTitle="Insert File Link" ButtonUrl="~/App_Themes/Default/images/TemplateManager.gif"
                                DialogWidth="850" DialogHeight="640" />
                    </CustomUserCommands>
                </dp:DpHtmlEditorMce>
</div>  

            </div>

        </div>
        <dp:DpPanel ID="pnlExistingDetail" runat="server" Visible="false" PanelTagKey="">
            <div id="tabsProperties" class="ui-tabs-hide">
                <h3>
                    Type</h3>
                <dp:EditProcessTypes ID="processTypes" runat="server" />
                <h3>
                    Process Alternatives</h3>
                <div style="margin: 3px 0px;">
                    <asp:Label runat="server" ID="lblAltGroup" Text="Alternative group:" AssociatedControlID="txtAltGroup" /><asp:TextBox
                        runat="server" ID="txtAltGroup" Style="margin-top: 3px;" />
                </div>
                <h3>
                    Tags</h3>
                <dp:ProcessTags ID="tags" runat="server" />
                <br class="clear" />
            </div>
            <div id="tabsUsage" class="ui-tabs-hide">                
                <asp:UpdatePanel ID="pnlUsgeProperties" runat="server">
                    <ContentTemplate>
                        <p class="hBlurb ui-state-highlight">
                            The data for these fields can be defined in the process library whenever a link to this type is created.</p>
                        <dp:MetadataEditorControl ID="mdeUsage" runat="server" ForeignType="10" ShowEditButtons="true"
                            CssClass="metadataEditor" LabelColumnSize="40" CreateButtonText="Edit metadata"
                            DefaultViewMode="Insert" ValidationGroup="usageGrp" HasEditModeDelete="true"
                            AllowMandatory="false" />
                    </ContentTemplate>
                </asp:UpdatePanel>
            </div>

            <div id="tabsSteps" class="ui-tabs-hide stepsTab">
                <table id="tblStepEditor" width="100%">
                    <tr>
                        <td id="tblCellSteps" >
<textarea id="code" style="width: 100%; display:none;" rows="11" >
st=>start:
e=>end:
op1=>activity:Do something
split=>xor:option
op2=>activity:Do something
else that is
fun to do
x=>split:
ops1=>activity:Split option 1
ops2=>activity:Split option 2
ops3=>activity:Split option 3
y=>join:
st(right)->op1(right)->split
split(yes, right)->op2
split(no)->e
op2(right)->x
x(first, right)->ops1->y
x(second, right)->ops2->y
x(third, right)->ops3->y
y(first, bottom)->e
        </textarea>
               <button id="run" type="button" style="display:none;">Run</button>

                    <div class="bpmnLoading">Loading...</div>

                            <div id="steps" style="position:fixed;overflow:auto;">
                            </div>
                        </td>
                        <td id="tblCellProcesses" width="250px">
                            <div id="cellProcContainer">
                                <button id="btnLayoutDiagram" type="button" class="ui-corner-all ui-state-default dpButton">Layout diagram</button>
                            <h2>Add gateway</h2>
                                <img src="../../App_Themes/Default/images/bpmnInclusive.png" id="addInclusiveGateway" alt="Add Inclusive Gateway" class="inclusiveGateway" />
                                <img src="../../App_Themes/Default/images/bpmnParallel.png" id="addParallelGateway" alt="Add Parallel Gateway" class="parallelGateway" />
                            <h2>
                                Add placeholder step</h2>
                            <div id='processPlaceholder'>
                                <div id='placeholderDrag'>
                                    <dp:JqTextBox ID="txtPlaceholder" runat="server" Columns="40" />
                                    <span id='placeholderDragging' style="display: none;"></span><span class='ui-icon ui-icon-arrow-4-diag'
                                        id='addPlaceholder'></span>
                                </div>
                            </div>
                            <h2>
                                Add process step</h2>
                            <dp:JqTextBox ID="txtFilter" runat="server" Columns="40" />
                            <input type="button" id='btnFilter' value="Find" onclick="filterChanged();" class="ui-corner-all ui-state-default dpButton" />
                            <span style="white-space:nowrap;"><span id="chkStepUseFtSearch" class="stcheck">Full text</span>
                            <span id="chkStepUseProcOnly" class="stcheck"><asp:Literal ID="litPtTypeName" runat="server" /></span>
                            </span>
                            <div id="procDragList">
                                <dp:TagProcessList ID="procDragTagList" runat="server" ShowViewLink="true" ShowDragIcon="true"/>
                            </div>
                            </div>
                        </td>
                    </tr>
                </table>
                <div id="stepDialog" title="Edit step">
                    <dp:JqTextBox ID="stepName" runat="server" AddLineBreak="true" LabelText="Step name"
                        Columns="60" />
                    <dp:JqTextBox ID="stepDesc" runat="server" AddLineBreak="true" LabelText="Tailoring instruction"
                        TextBoxMode="MultiLine" Columns="80" />
                    <div id="stepDialogComponent">
                        <br />
                        <dp:JqCheckbox ID="isIterativeStep" runat="server" LabelText="Iterative step" />
                        <br />
                        <button id="btnPromoteToProcess" class="ui-corner-all ui-state-default dpButton">Promote text step to process</button>
                    </div>
                </div>
            </div>
            <div id="tabsMetrics" class="ui-tabs-hide">
                <asp:Panel runat="server" ID="pnlCommonPrompt">
                    <p class="hBlurb ui-state-highlight">
                        The data for these common fields will be collected for each project instance based on this type.</p>
                </asp:Panel>
                <dp:Metadata ID="commonMetrics" runat="server" ForeignType="18" MetadataForeignType="18"
                    ShowEditButtons="false" ViewMode="Edit" Enabled="false" MetadataName="data" OnNoData="commonMetrics_OnNoData" />
                <asp:UpdatePanel ID="up" runat="server">
                    <ContentTemplate>
                        <p class="hBlurb ui-state-highlight">
                            The data for these fields will be collected for each project instance based on this type.</p>
                        <dp:MetadataEditorControl ID="mdeMetrics" runat="server" ForeignType="7" ShowEditButtons="true"
                            CssClass="metadataEditor" LabelColumnSize="40" CreateButtonText="Edit metadata"
                            DefaultViewMode="Insert" ValidationGroup="metricGrp" HasEditModeDelete="true"
                            AllowMandatory="false" />
                    </ContentTemplate>
                </asp:UpdatePanel>
            </div>
        </dp:DpPanel>
    </div>
    <br />
</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 href="../<%=PrettyTitle %>">
            Cancel</a></li>
    </ul>
    <ul class='ui-widget-content' id="ulSave">
        <li class="btn btnSave"><span class="ui-icon ui-icon-disk"></span>
            <asp:LinkButton ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" OnClientClick="javascript:saveContent(); saveSteps();" /></li>
    </ul>
    
    <ul class='ui-widget-content' runat="server" id="ulEditDirect">
        <li class="btn btnEdit"><span class="ui-icon ui-icon-pencil"></span>
            <a href='./EditDirect'>Edit directly</a></li>
    </ul>
</asp:Content>
