<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Project.Master" Inherits="System.Web.Mvc.ViewPage<AdministratorConsole.Models.ProjectController.EditExternalModelsViewModel>" %>

<asp:Content ID="MainContent" ContentPlaceHolderID="MainContent" runat="server">
    <div id="content-wrap">
        <% Html.RenderPartial("Navigation/_SideNavigation", Model.MenuNavigationModel); %>
	    <div id="content">
	        <h1>Manage Files</h1>
            <div id="tab-container">
                <ul class="tabs">
			        <li><a href="<%= Url.Action("EditFiles/" + Model.CurrentProject.ExternalId, "Project") %>">Local</a></li>
			        <li><a href="<%= Url.Action("EditExternalModels/" + Model.CurrentProject.ExternalId, "Project") %>" class="active">External</a></li>
		        </ul>
            </div>
            <br />
            <div><%= TextHelper.GetText("External Models are references to Revit models outside of the project folder, which should be included for task processing.") %></div>
            <br />
            <table class="standard-list full" cellspacing="0" cellpadding="0">
                <tr>
                    <th align="left">Path</th>
                    <th colspan="2" style="text-align:right;"><a href="javascript:loadAddExternalModel()">Add</a></th>
                </tr>
                <% if (Model.ExternalRevitModels.Count > 0)
                    { %>
                    <% bool evenEntry = false; %>
                    <% foreach (ExternalRevitModel externalRevitModel in Model.ExternalRevitModels)
                        { %>
                        <tr <% if (evenEntry) { %>class="even"<% evenEntry = false; %><% } else { %>class="odd"<% evenEntry = true; %><% } %>>
                            <td><%= externalRevitModel.Path %></td>
                            <td style="width:30px;text-align:right"><a href="javascript:loadDeleteExternalModel('<%= externalRevitModel.ExternalId %>')">Delete</a></td>
                        </tr>
                    <% } %>
                <% }
                    else
                    { %>
                    <tr>
                        <td colspan="3">No external models</td>
                    </tr>
                <% }%>
            </table>
        </div>
    </div>
    <script type="text/javascript">
        function loadAddExternalModel() {
            $.ajax({
                url: '<%= Url.Action("AddExternalModel", "Project")%>',
                data: { id: '<%= Model.CurrentProject.ExternalId %>' },
                type: "GET",
                cache: false,
                success: function (response) {
                    $("#modal-overlay").html(response);
                },
                complete: function () {
                    showModelDialog();
                }
            });
        }
        function loadEditExternalModel(modelId) {
            $.ajax({
                url: '<%= Url.Action("EditExternalModel", "Project")%>',
                data: { projectId: '<%= Model.CurrentProject.ExternalId %>', id: modelId },
                type: "GET",
                cache: false,
                success: function (response) {
                    $("#modal-overlay").html(response);
                },
                complete: function () {
                    showModelDialog();
                }
            });
        }
        function loadDeleteExternalModel(modelId) {
            $.ajax({
                url: '<%= Url.Action("DeleteExternalModelConfirm", "Project")%>',
                data: { projectId: '<%= Model.CurrentProject.ExternalId %>', modelId: modelId },
                type: "GET",
                cache: false,
                success: function (response) {
                    $("#modal-overlay").html(response);
                },
                complete: function () {
                    showModelDialog();
                }
            });
        }
    </script>
</asp:Content>
