@using X.PagedList;
@using X.PagedList.Mvc.Core;
@using X.PagedList.Web.Common;

@model IPagedList<Project>


@{
    ViewData["Title"] = "Porjekt-Übersicht";
}

<h1> Projekt-Übersicht</h1>

<form asp-action="CreateEdit">
    <button type="submit" class="btn btn-primary"><i class="bi bi-plus-square"></i> neues Projekt erstellen</button>
</form>

<hr />
<form asp-action="Index" method="get">
    <p>
        Suchen nach: <input type="text" name="SearchString" value="" />
        <input type="submit" value="suchen" />
    </p>
</form>

<table class="table table-striped table-hover"
       data-filter-control="true"
       data-show-search-clear-button="true">
    <thead>
        <tr>
            <th hidden>Id</th>
            <th>Nr.</th>
            <th>Anlage</th>
            <th style="width:20%">Name</th>
            <th>Bezeichnung</th>
            <th>Status</th>
            <th>Aktionen</th>
        </tr>
    </thead>

    <tbody>
        @{
            foreach (var project in Model)
            {
                <tr>
                    <td hidden>
                        @project.Id
                    </td>
                    <td>
                        @project.No
                    </td>
                    <td>
                        @project.Plant.Name  @project.Plant.SubPlantShortName
                    </td>
                    <td>
                        @project.Name
                    </td>
                    <td>
                        @project.Description
                    </td>
                    <td class="text-@(project.Status == ProjectStatus.started ? "success" : "danger")">
                        @Html.DisplayFor(x => @project.Status)
                    </td>
                    <td>
                        <div class="btn-group" style="flex-direction:row">
                            <button class="btn btn-success" onclick="location.href='@Url.Action("CreateEdit", new {@project.Id})'"><i class="bi bi-pencil-square"></i></button>
                            <button class="btn btn-danger" onclick="location.href='@Url.Action("DeleteProject", new {@project.Id})'"><i class="bi bi-trash"></i></button>
                        </div>
                    </td>
                </tr>
            }
        }
    </tbody>

</table>


<nav>
    @Html.PagedListPager(Model, page => Url.Action("index", new { page = page }), new PagedListRenderOptions()
    {
    ActiveLiElementClass = "active",
    PageClasses = new[]{ "page-link"},
    LiElementClasses=new[] { "page-item" },
    UlElementClasses = new[] { "pagination","justify-content-center", "mt-3" },
    LinkToNextPageFormat = ">",
    LinkToPreviousPageFormat = "<",
    DisplayLinkToPreviousPage = PagedListDisplayMode.Always,
    DisplayLinkToNextPage = PagedListDisplayMode.Always
    })
</nav>

