@using OurUmbraco.Our.Controllers
@model OurUmbraco.Our.Models.EditFileModel
<div class="package-create">

    @Html.Partial("~/Views/Partials/Project/PackageEditNavigation.cshtml", "files")

    <div class="form simpleForm" id="registrationForm">
        <fieldset>
            <legend>Current project files</legend>
            <p>
                <table class="dataTable">
                    <thead>
                        <tr>
                            <th>File</th>
                            <th>Type</th>
                            <th>Compatible Version</th>
                            <th>.NET Version</th>
                            <th>Uploaded</th>
                            <th class="center">Default Release</th>
                            <th class="center">Archive</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var wikiFile in Model.AvailableFiles)
                        {
                            var versionsList = new List<string>();
                            foreach (var version in wikiFile.Versions)
                            {
                                versionsList.Add(version.Version);
                            }
                            var versions = string.Join(",", versionsList);

                            <tr>
                                <td>@wikiFile.Name</td>
                                <td>@wikiFile.FileType</td>
                                <td>@versions</td>
                                <td>@wikiFile.DotNetVersion</td>
                                <td>@wikiFile.CreateDate</td>
                                <td class="center">
                                    @if (wikiFile.Current == false)
                                    {
                                        using (Html.BeginUmbracoForm<ProjectController>("MarkFileAsCurrent"))
                                        {
                                            <input type="hidden" name="id" value="@Request.QueryString["id"]" />
                                            <input type="hidden" name="releaseFileId" value="@wikiFile.Id" />
                                            <input type="submit" value="Make current" class="actionButton" />
                                        }
                                    }
                                    else
                                    {
                                        <text>Current</text>
                                    }
                                </td>
                                <td class="center">
                                    @using (Html.BeginUmbracoForm<ProjectController>("ArchiveFile"))
                                    {
                                        var buttonText = wikiFile.Archived ? "Unarchive" : "Archive";

                                        <input type="hidden" name="id" value="@Request.QueryString["id"]" />
                                        <input type="hidden" name="releaseFileId" value="@wikiFile.Id" />
                                        <input type="submit" value="@buttonText" class="actionButton" />
                                    }
                                </td>
                            </tr>
                        }
                </table>
            </p>
        </fieldset>
        <fieldset>
            <legend>Upload file</legend>
            <div id="">
                @using (Html.BeginUmbracoForm<ProjectController>("AddFile"))
                {
                    <span style="color: red;">
                        @Html.ValidationSummary()
                    </span>

                    <div id="">
                        <p>
                            <label class="inputLabel">Pick file (10 MB max):</label>
                        </p>
                        <div>
                            <div>
                                <input type="file" class="title" name="UploadFile.File">
                            </div>
                        </div>
                        <p></p>
                        <p>
                            <label class="inputLabel">Choose filetype</label>

                            @Html.DropDownListFor(model => model.UploadFile.FileType, new List<SelectListItem>
                            {
                                new SelectListItem { Text = "Package", Value = "package" },
                                new SelectListItem { Text = "Hot Fix", Value = "hotfix"},
                                new SelectListItem { Text = "Documentation", Value = "docs"},
                                new SelectListItem { Text = "Source Code", Value = "source"}
                            })
                        </p>
                        <div class="pickversionWrapper">
                            <p id="pickVersion">
                                <label class="inputLabel">Choose umbraco version</label>
                            </p>
                            <div class="pickVersion" style="float: left; margin-bottom: 10px;">
                                @foreach (var item in Model.UploadFile.AvailableVersions)
                                {
                                    var versionsSelected = Model.UploadFile.SelectedVersions;
                                    <input type="checkbox" name="UploadFile.SelectedVersions" value="@item.Value" id="@item.Value" @if (versionsSelected != null && versionsSelected.Contains(item.Value)) { <text> checked="checked" </text> } /> <label for="@item.Value" style="display: inline; padding: 0;">@item.Text</label><br />
                                }

                            </div>
                            <p style="clear: both; margin-bottom: 10px;">If your package manifest references a specific version of Umbraco, then that will be used instead.</p>
                        </div>
                        <p id="pickNetVersion">
                            <label class="inputLabel">Choose supported .NET runtime</label>

                            <select name="UploadFile.DotNetVersion" class="title">
                                <option value=""></option>
                                <option value="2.0">2.0</option>
                                <option value="3.5">3.5</option>
                                <option value="4.0">4.0</option>
                                <option value="4.5">4.5</option>
                                <option value="4.5.1">4.5.1</option>
                                <option value="4.5.2">4.5.2</option>
                                <option value="4.6.0">4.6.0</option>
                                <option value="4.6.1">4.6.1</option>
                            </select><br>
                        </p>

                        <p>
                            <input type="hidden" name="UploadFile.ProjectId" value="@Request.QueryString["id"]" />
                            <input type="submit" value="Save file" class="submitButton button blue tiny">
                        </p>

                    </div>
                }
                <div class="buttons">
                    <a href="/member/profile/projects/edit/?editorStep=screenshots&id=@Request.QueryString["id"]" class="submitButton button green tiny" style="color: white;">Next</a>
                </div>
            </div>

        </fieldset>
    </div>
</div>