UI: Device models list, default hide decommissioned

This commit is contained in:
Gary Sharp
2017-03-29 12:55:07 +11:00
parent 82183f6508
commit fdf1bd4bc6
2 changed files with 118 additions and 64 deletions
@@ -3,28 +3,34 @@
Authorization.Require(Claims.Config.DeviceModel.Show);
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Device Models");
var hasDecommissionedModels = Model.DeviceModels.Any(db => db.DeviceCount > 0 && db.DeviceDecommissionedCount >= db.DeviceCount);
}
<table class="tableData">
@if (hasDecommissionedModels)
{
<a id="Config_DeviceModels_ShowDecommissioned" href="#" class="button small">Show Decommissioned (@(Model.DeviceModels.Count(db => db.DeviceCount > 0 && db.DeviceDecommissionedCount >= db.DeviceCount)))</a>
<script>
$(function () {
$('#Config_DeviceModels_ShowDecommissioned').click(function () {
$(this).remove();
$('#Config_DeviceModels_List').find('tr.hidden').show();
return false;
}).detach().appendTo('#layout_PageHeading');
})
</script>
}
<table id="Config_DeviceModels_List" class="tableData">
<tr>
<th>
Name/Description
</th>
<th>
Manufacturer
</th>
<th>
Model
</th>
<th>
Type
</th>
<th>
Device Count
</th>
<th>Name/Description</th>
<th>Manufacturer</th>
<th>Model</th>
<th>Type</th>
<th>Device Count</th>
</tr>
@foreach (var item in Model.DeviceModels)
{
<tr>
var isDecommissioned = item.DeviceCount > 0 && item.DeviceDecommissionedCount >= item.DeviceCount;
<tr class="@(isDecommissioned ? "hidden" : null)">
<td>
@Html.ActionLink(item.ToString(), MVC.Config.DeviceModel.Index(item.Id))
</td>
@@ -42,7 +48,8 @@
@if (item.DeviceDecommissionedCount > 0)
{
<span class="smallMessage" title="@(item.DeviceDecommissionedCount.ToString("n0")) Decommissioned">
(@(item.DeviceDecommissionedCount.ToString("n0")))</span>
(@(item.DeviceDecommissionedCount.ToString("n0")))
</span>
}
</td>
</tr>
@@ -2,7 +2,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.34014
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -27,7 +27,6 @@ namespace Disco.Web.Areas.Config.Views.DeviceModel
using System.Web.UI;
using System.Web.WebPages;
using Disco;
using Disco.BI.Extensions;
using Disco.Models.Repository;
using Disco.Services;
using Disco.Services.Authorization;
@@ -51,53 +50,101 @@ namespace Disco.Web.Areas.Config.Views.DeviceModel
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Device Models");
var hasDecommissionedModels = Model.DeviceModels.Any(db => db.DeviceCount > 0 && db.DeviceDecommissionedCount >= db.DeviceCount);
#line default
#line hidden
WriteLiteral("\r\n<table");
WriteLiteral("\r\n");
WriteLiteral(" class=\"tableData\"");
WriteLiteral(@">
<tr>
<th>
Name/Description
</th>
<th>
Manufacturer
</th>
<th>
Model
</th>
<th>
Type
</th>
<th>
Device Count
</th>
</tr>
#line 9 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
if (hasDecommissionedModels)
{
#line default
#line hidden
WriteLiteral(" <a");
WriteLiteral(" id=\"Config_DeviceModels_ShowDecommissioned\"");
WriteLiteral(" href=\"#\"");
WriteLiteral(" class=\"button small\"");
WriteLiteral(">Show Decommissioned (");
#line 11 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
Write(Model.DeviceModels.Count(db => db.DeviceCount > 0 && db.DeviceDecommissionedCount >= db.DeviceCount));
#line default
#line hidden
WriteLiteral(")</a>\r\n");
WriteLiteral(@" <script>
$(function () {
$('#Config_DeviceModels_ShowDecommissioned').click(function () {
$(this).remove();
$('#Config_DeviceModels_List').find('tr.hidden').show();
return false;
}).detach().appendTo('#layout_PageHeading');
})
</script>
");
#line 25 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
#line 21 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
}
#line default
#line hidden
WriteLiteral("<table");
WriteLiteral(" id=\"Config_DeviceModels_List\"");
WriteLiteral(" class=\"tableData\"");
WriteLiteral(">\r\n <tr>\r\n <th>Name/Description</th>\r\n <th>Manufacturer</th>\r\n " +
" <th>Model</th>\r\n <th>Type</th>\r\n <th>Device Count</th>\r\n " +
"</tr>\r\n");
#line 30 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
#line default
#line hidden
#line 25 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
#line 30 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
foreach (var item in Model.DeviceModels)
{
var isDecommissioned = item.DeviceCount > 0 && item.DeviceDecommissionedCount >= item.DeviceCount;
#line default
#line hidden
WriteLiteral(" <tr>\r\n <td>\r\n");
WriteLiteral(" <tr");
WriteAttribute("class", Tuple.Create(" class=\"", 1354), Tuple.Create("\"", 1399)
#line 33 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
, Tuple.Create(Tuple.Create("", 1362), Tuple.Create<System.Object, System.Int32>(isDecommissioned ? "hidden" : null
#line default
#line hidden
, 1362), false)
);
WriteLiteral(">\r\n <td>\r\n");
WriteLiteral(" ");
#line 29 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
#line 35 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
Write(Html.ActionLink(item.ToString(), MVC.Config.DeviceModel.Index(item.Id)));
@@ -108,7 +155,7 @@ WriteLiteral("\r\n </td>\r\n <td>\r\n");
WriteLiteral(" ");
#line 32 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
#line 38 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
Write(Html.DisplayFor(modelItem => item.Manufacturer));
@@ -119,7 +166,7 @@ WriteLiteral("\r\n </td>\r\n <td>\r\n");
WriteLiteral(" ");
#line 35 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
#line 41 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
Write(Html.DisplayFor(modelItem => item.Model));
@@ -130,7 +177,7 @@ WriteLiteral("\r\n </td>\r\n <td>\r\n");
WriteLiteral(" ");
#line 38 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
#line 44 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
Write(Html.DisplayFor(modelItem => item.ModelType));
@@ -141,7 +188,7 @@ WriteLiteral("\r\n </td>\r\n <td>\r\n");
WriteLiteral(" ");
#line 41 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
#line 47 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
Write(item.DeviceCount.ToString("n0"));
@@ -150,13 +197,13 @@ WriteLiteral(" ");
WriteLiteral("\r\n");
#line 42 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
#line 48 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
#line default
#line hidden
#line 42 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
#line 48 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
if (item.DeviceDecommissionedCount > 0)
{
@@ -167,30 +214,30 @@ WriteLiteral(" <span");
WriteLiteral(" class=\"smallMessage\"");
WriteAttribute("title", Tuple.Create(" title=\"", 1233), Tuple.Create("\"", 1304)
WriteAttribute("title", Tuple.Create(" title=\"", 2020), Tuple.Create("\"", 2091)
#line 44 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
, Tuple.Create(Tuple.Create("", 1241), Tuple.Create<System.Object, System.Int32>(item.DeviceDecommissionedCount.ToString("n0")
#line 50 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
, Tuple.Create(Tuple.Create("", 2028), Tuple.Create<System.Object, System.Int32>(item.DeviceDecommissionedCount.ToString("n0")
#line default
#line hidden
, 1241), false)
, Tuple.Create(Tuple.Create(" ", 1289), Tuple.Create("Decommissioned", 1290), true)
, 2028), false)
, Tuple.Create(Tuple.Create(" ", 2076), Tuple.Create("Decommissioned", 2077), true)
);
WriteLiteral(">\r\n (");
#line 45 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
#line 51 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
Write(item.DeviceDecommissionedCount.ToString("n0"));
#line default
#line hidden
WriteLiteral(")</span>\r\n");
WriteLiteral(")\r\n </span>\r\n");
#line 46 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
#line 53 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
}
@@ -199,7 +246,7 @@ WriteLiteral(")</span>\r\n");
WriteLiteral(" </td>\r\n </tr>\r\n");
#line 49 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
#line 56 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
}
@@ -214,7 +261,7 @@ WriteLiteral(">\r\n");
WriteLiteral(" ");
#line 52 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
#line 59 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
Write(Html.ActionLinkButton("Generic Components", MVC.Config.DeviceModel.GenericComponents()));