@model IEnumerable<Disco.Web.Areas.Config.Models.DeviceProfile._IndexModelItem>
@{
    Authorization.Require(Claims.Config.DeviceProfile.Show);
    var showTags = Model.Any(i => i.IsLinked);
}
<table class="tableData deviceProfileTable">
    <tr>
        <th class="name">
            Name
        </th>
        <th class="description">
            Description
        </th>
        <th class="type">
            Type
        </th>
        <th class="deviceCount">
            Device Count
        </th>
        @if (showTags)
        {
            <th>&nbsp;</th>
        }
    </tr>
    @foreach (var item in Model)
    {
        var isDecommissioned = item.DeviceCount > 0 && item.DeviceDecommissionedCount >= item.DeviceCount;
        <tr class="@(isDecommissioned ? "hidden" : null)">
            <td>
                @Html.ActionLink(item.Name, MVC.Config.DeviceProfile.Index(item.Id))
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Description)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.DistributionType)
            </td>
            <td>
                @if (item.DeviceCount > 0 && Authorization.Has(Claims.Device.Search))
                {
                    <span>@Html.ActionLink(string.Format("View {0}", item.DeviceCount), MVC.Search.Query(item.Id.ToString(), "DeviceProfile"))</span>
                }
                else
                {
                    <span>@item.DeviceCount.ToString("n0")</span>
                }
                @if (item.DeviceDecommissionedCount > 0)
                {
                    <span class="smallMessage" title="@(item.DeviceDecommissionedCount.ToString("n0")) Decommissioned">
                        (@(item.DeviceDecommissionedCount.ToString("n0")))
                    </span>
                }
            </td>
            @if (showTags)
            {
                <td>
                    @if (item.IsLinked)
                    {
                        <i class="fa fa-link fa-lg success" title="Is Linked"></i>
                    }
                    else
                    {
                        <text>&nbsp;</text>
                    }
                </td>
            }
        </tr>
        if (isDecommissioned)
        {
            <tr class="hidden decommissioned-padding"></tr>
        }
    }
</table>
