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
@@ -1,30 +1,36 @@
@model Disco.Web.Areas.Config.Models.DeviceModel.IndexModel @model Disco.Web.Areas.Config.Models.DeviceModel.IndexModel
@{ @{
Authorization.Require(Claims.Config.DeviceModel.Show); Authorization.Require(Claims.Config.DeviceModel.Show);
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Device Models"); 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> <tr>
<th> <th>Name/Description</th>
Name/Description <th>Manufacturer</th>
</th> <th>Model</th>
<th> <th>Type</th>
Manufacturer <th>Device Count</th>
</th>
<th>
Model
</th>
<th>
Type
</th>
<th>
Device Count
</th>
</tr> </tr>
@foreach (var item in Model.DeviceModels) @foreach (var item in Model.DeviceModels)
{ {
<tr> var isDecommissioned = item.DeviceCount > 0 && item.DeviceDecommissionedCount >= item.DeviceCount;
<tr class="@(isDecommissioned ? "hidden" : null)">
<td> <td>
@Html.ActionLink(item.ToString(), MVC.Config.DeviceModel.Index(item.Id)) @Html.ActionLink(item.ToString(), MVC.Config.DeviceModel.Index(item.Id))
</td> </td>
@@ -40,9 +46,10 @@
<td> <td>
@item.DeviceCount.ToString("n0") @item.DeviceCount.ToString("n0")
@if (item.DeviceDecommissionedCount > 0) @if (item.DeviceDecommissionedCount > 0)
{ {
<span class="smallMessage" title="@(item.DeviceDecommissionedCount.ToString("n0")) Decommissioned"> <span class="smallMessage" title="@(item.DeviceDecommissionedCount.ToString("n0")) Decommissioned">
(@(item.DeviceDecommissionedCount.ToString("n0")))</span> (@(item.DeviceDecommissionedCount.ToString("n0")))
</span>
} }
</td> </td>
</tr> </tr>
@@ -2,7 +2,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // 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 // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.
@@ -27,7 +27,6 @@ namespace Disco.Web.Areas.Config.Views.DeviceModel
using System.Web.UI; using System.Web.UI;
using System.Web.WebPages; using System.Web.WebPages;
using Disco; using Disco;
using Disco.BI.Extensions;
using Disco.Models.Repository; using Disco.Models.Repository;
using Disco.Services; using Disco.Services;
using Disco.Services.Authorization; using Disco.Services.Authorization;
@@ -48,56 +47,104 @@ namespace Disco.Web.Areas.Config.Views.DeviceModel
#line 2 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml" #line 2 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
Authorization.Require(Claims.Config.DeviceModel.Show); Authorization.Require(Claims.Config.DeviceModel.Show);
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Device Models"); 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 default
#line hidden #line hidden
WriteLiteral("\r\n<table"); WriteLiteral("\r\n");
WriteLiteral(" class=\"tableData\"");
#line 9 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
if (hasDecommissionedModels)
{
WriteLiteral(@">
<tr> #line default
<th> #line hidden
Name/Description WriteLiteral(" <a");
</th>
<th> WriteLiteral(" id=\"Config_DeviceModels_ShowDecommissioned\"");
Manufacturer
</th> WriteLiteral(" href=\"#\"");
<th>
Model WriteLiteral(" class=\"button small\"");
</th>
<th> WriteLiteral(">Show Decommissioned (");
Type
</th>
<th> #line 11 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
Device Count Write(Model.DeviceModels.Count(db => db.DeviceCount > 0 && db.DeviceDecommissionedCount >= db.DeviceCount));
</th>
</tr>
#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 default
#line hidden #line hidden
#line 25 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml" #line 30 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
foreach (var item in Model.DeviceModels) foreach (var item in Model.DeviceModels)
{ {
var isDecommissioned = item.DeviceCount > 0 && item.DeviceDecommissionedCount >= item.DeviceCount;
#line default #line default
#line hidden #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(" "); 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))); 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(" "); WriteLiteral(" ");
#line 32 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml" #line 38 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
Write(Html.DisplayFor(modelItem => item.Manufacturer)); Write(Html.DisplayFor(modelItem => item.Manufacturer));
@@ -119,7 +166,7 @@ WriteLiteral("\r\n </td>\r\n <td>\r\n");
WriteLiteral(" "); WriteLiteral(" ");
#line 35 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml" #line 41 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
Write(Html.DisplayFor(modelItem => item.Model)); Write(Html.DisplayFor(modelItem => item.Model));
@@ -130,7 +177,7 @@ WriteLiteral("\r\n </td>\r\n <td>\r\n");
WriteLiteral(" "); WriteLiteral(" ");
#line 38 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml" #line 44 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
Write(Html.DisplayFor(modelItem => item.ModelType)); Write(Html.DisplayFor(modelItem => item.ModelType));
@@ -141,7 +188,7 @@ WriteLiteral("\r\n </td>\r\n <td>\r\n");
WriteLiteral(" "); WriteLiteral(" ");
#line 41 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml" #line 47 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
Write(item.DeviceCount.ToString("n0")); Write(item.DeviceCount.ToString("n0"));
@@ -150,15 +197,15 @@ WriteLiteral(" ");
WriteLiteral("\r\n"); WriteLiteral("\r\n");
#line 42 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml" #line 48 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
#line default #line default
#line hidden #line hidden
#line 42 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml" #line 48 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
if (item.DeviceDecommissionedCount > 0) if (item.DeviceDecommissionedCount > 0)
{ {
#line default #line default
@@ -167,30 +214,30 @@ WriteLiteral(" <span");
WriteLiteral(" class=\"smallMessage\""); 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" #line 50 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
, Tuple.Create(Tuple.Create("", 1241), Tuple.Create<System.Object, System.Int32>(item.DeviceDecommissionedCount.ToString("n0") , Tuple.Create(Tuple.Create("", 2028), Tuple.Create<System.Object, System.Int32>(item.DeviceDecommissionedCount.ToString("n0")
#line default #line default
#line hidden #line hidden
, 1241), false) , 2028), false)
, Tuple.Create(Tuple.Create(" ", 1289), Tuple.Create("Decommissioned", 1290), true) , Tuple.Create(Tuple.Create(" ", 2076), Tuple.Create("Decommissioned", 2077), true)
); );
WriteLiteral(">\r\n ("); WriteLiteral(">\r\n (");
#line 45 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml" #line 51 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
Write(item.DeviceDecommissionedCount.ToString("n0")); Write(item.DeviceDecommissionedCount.ToString("n0"));
#line default #line default
#line hidden #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"); 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(" "); 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())); Write(Html.ActionLinkButton("Generic Components", MVC.Config.DeviceModel.GenericComponents()));