feature: custom device models
This commit is contained in:
@@ -17,6 +17,8 @@ namespace Disco.Web.Areas.API.Controllers
|
||||
{
|
||||
|
||||
const string pDescription = "description";
|
||||
const string pManufacturer = "manufacturer";
|
||||
const string pModel = "model";
|
||||
const string pDefaultPurchaseDate = "defaultpurchasedate";
|
||||
const string pDefaultWarrantyProvider = "defaultwarrantyprovider";
|
||||
const string pDefaultRepairProvider = "defaultrepairprovider";
|
||||
@@ -40,6 +42,12 @@ namespace Disco.Web.Areas.API.Controllers
|
||||
case pDescription:
|
||||
UpdateDescription(deviceModel, value);
|
||||
break;
|
||||
case pManufacturer:
|
||||
UpdateManufacturer(deviceModel, value);
|
||||
break;
|
||||
case pModel:
|
||||
UpdateModel(deviceModel, value);
|
||||
break;
|
||||
case pDefaultPurchaseDate:
|
||||
UpdateDefaultPurchaseDate(deviceModel, value);
|
||||
break;
|
||||
@@ -72,13 +80,25 @@ namespace Disco.Web.Areas.API.Controllers
|
||||
}
|
||||
|
||||
#region Update Shortcut Methods
|
||||
|
||||
|
||||
[DiscoAuthorize(Claims.Config.DeviceModel.Configure)]
|
||||
public virtual ActionResult UpdateDescription(int id, string Description = null, bool redirect = false)
|
||||
{
|
||||
return Update(id, pDescription, Description, redirect);
|
||||
}
|
||||
|
||||
[DiscoAuthorize(Claims.Config.DeviceModel.Configure)]
|
||||
public virtual ActionResult UpdateManufacturer(int id, string manufacturer = null, bool redirect = false)
|
||||
{
|
||||
return Update(id, pManufacturer, manufacturer, redirect);
|
||||
}
|
||||
|
||||
[DiscoAuthorize(Claims.Config.DeviceModel.Configure)]
|
||||
public virtual ActionResult UpdateModel(int id, string model = null, bool redirect = false)
|
||||
{
|
||||
return Update(id, pModel, model, redirect);
|
||||
}
|
||||
|
||||
[DiscoAuthorize(Claims.Config.DeviceModel.Configure)]
|
||||
public virtual ActionResult UpdateDefaultPurchaseDate(int id, string DefaultPurchaseDate = null, bool redirect = false)
|
||||
{
|
||||
@@ -100,7 +120,7 @@ namespace Disco.Web.Areas.API.Controllers
|
||||
#endregion
|
||||
|
||||
#region Update Properties
|
||||
private void UpdateDescription(Disco.Models.Repository.DeviceModel deviceModel, string Description)
|
||||
private void UpdateDescription(DeviceModel deviceModel, string Description)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Description))
|
||||
deviceModel.Description = null;
|
||||
@@ -108,7 +128,29 @@ namespace Disco.Web.Areas.API.Controllers
|
||||
deviceModel.Description = Description;
|
||||
Database.SaveChanges();
|
||||
}
|
||||
private void UpdateDefaultPurchaseDate(Disco.Models.Repository.DeviceModel deviceModel, string DefaultPurchaseDate)
|
||||
private void UpdateManufacturer(DeviceModel deviceModel, string manufacturer)
|
||||
{
|
||||
if (!deviceModel.IsCustomModel())
|
||||
throw new InvalidCastException("Cannot update Manufacturer for a non-custom device model.");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(manufacturer))
|
||||
deviceModel.Manufacturer = null;
|
||||
else
|
||||
deviceModel.Manufacturer = manufacturer;
|
||||
Database.SaveChanges();
|
||||
}
|
||||
private void UpdateModel(DeviceModel deviceModel, string model)
|
||||
{
|
||||
if (!deviceModel.IsCustomModel())
|
||||
throw new InvalidCastException("Cannot update Model for a non-custom device model.");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(model))
|
||||
deviceModel.Model = null;
|
||||
else
|
||||
deviceModel.Model = model;
|
||||
Database.SaveChanges();
|
||||
}
|
||||
private void UpdateDefaultPurchaseDate(DeviceModel deviceModel, string DefaultPurchaseDate)
|
||||
{
|
||||
if (string.IsNullOrEmpty(DefaultPurchaseDate))
|
||||
{
|
||||
@@ -128,7 +170,7 @@ namespace Disco.Web.Areas.API.Controllers
|
||||
}
|
||||
Database.SaveChanges();
|
||||
}
|
||||
private void UpdateDefaultWarrantyProvider(Disco.Models.Repository.DeviceModel deviceModel, string DefaultWarrantyProvider)
|
||||
private void UpdateDefaultWarrantyProvider(DeviceModel deviceModel, string DefaultWarrantyProvider)
|
||||
{
|
||||
if (string.IsNullOrEmpty(DefaultWarrantyProvider))
|
||||
{
|
||||
@@ -142,7 +184,7 @@ namespace Disco.Web.Areas.API.Controllers
|
||||
}
|
||||
Database.SaveChanges();
|
||||
}
|
||||
private void UpdateDefaultRepairProvider(Disco.Models.Repository.DeviceModel deviceModel, string DefaultRepairProvider)
|
||||
private void UpdateDefaultRepairProvider(DeviceModel deviceModel, string DefaultRepairProvider)
|
||||
{
|
||||
if (string.IsNullOrEmpty(DefaultRepairProvider))
|
||||
{
|
||||
@@ -192,7 +234,7 @@ namespace Disco.Web.Areas.API.Controllers
|
||||
}
|
||||
return File(Links.ClientSource.Style.Images.DeviceTypes.Unknown_png, "image/png");
|
||||
}
|
||||
|
||||
|
||||
[DiscoAuthorize(Claims.Config.DeviceModel.Configure), HttpPost]
|
||||
public virtual ActionResult Image(int id, bool redirect, HttpPostedFileBase Image)
|
||||
{
|
||||
@@ -232,7 +274,7 @@ namespace Disco.Web.Areas.API.Controllers
|
||||
#region Actions
|
||||
|
||||
[DiscoAuthorize(Claims.Config.DeviceModel.Delete)]
|
||||
public virtual ActionResult Delete(int id, Nullable<bool> redirect = false)
|
||||
public virtual ActionResult Delete(int id, bool? redirect = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -292,7 +334,7 @@ namespace Disco.Web.Areas.API.Controllers
|
||||
Cost = Cost.Substring(Cost.IndexOf("$") + 1);
|
||||
decimal.TryParse(Cost, out cost);
|
||||
|
||||
var dc = new Disco.Models.Repository.DeviceComponent()
|
||||
var dc = new DeviceComponent()
|
||||
{
|
||||
Description = Description,
|
||||
Cost = cost
|
||||
|
||||
@@ -19,6 +19,11 @@ namespace Disco.Web.Areas.Config
|
||||
"Config/DeviceModel/GenericComponents",
|
||||
new { controller = "DeviceModel", action = "GenericComponents" }
|
||||
);
|
||||
context.MapRoute(
|
||||
"Config_DeviceModel_Create",
|
||||
"Config/DeviceModel/Create",
|
||||
new { controller = "DeviceModel", action = "Create" }
|
||||
);
|
||||
context.MapRoute(
|
||||
"Config_DeviceModel",
|
||||
"Config/DeviceModel/{id}",
|
||||
@@ -27,7 +32,7 @@ namespace Disco.Web.Areas.Config
|
||||
context.MapRoute(
|
||||
"Config_DeviceBatch_Create",
|
||||
"Config/DeviceBatch/Create",
|
||||
new { controller = "DeviceBatch", action = "Create", id = UrlParameter.Optional }
|
||||
new { controller = "DeviceBatch", action = "Create" }
|
||||
);
|
||||
context.MapRoute(
|
||||
"Config_DeviceBatch_Timeline",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Disco.Models.UI.Config.DeviceModel;
|
||||
using Disco.Models.Repository;
|
||||
using Disco.Models.UI.Config.DeviceModel;
|
||||
using Disco.Services;
|
||||
using Disco.Services.Authorization;
|
||||
using Disco.Services.Plugins;
|
||||
@@ -36,7 +37,7 @@ namespace Disco.Web.Areas.Config.Controllers
|
||||
{
|
||||
DeviceModelId = m.DeviceModel.Id,
|
||||
DeviceComponents = Database.DeviceComponents.Include("JobSubTypes").Where(dc => dc.DeviceModelId == m.DeviceModel.Id).ToList(),
|
||||
JobSubTypes = Database.JobSubTypes.Where(jst => jst.JobTypeId == Disco.Models.Repository.JobType.JobTypeIds.HNWar).ToList()
|
||||
JobSubTypes = Database.JobSubTypes.Where(jst => jst.JobTypeId == JobType.JobTypeIds.HNWar).ToList()
|
||||
};
|
||||
|
||||
m.CanDelete = m.DeviceModel.CanDelete(Database);
|
||||
@@ -46,7 +47,7 @@ namespace Disco.Web.Areas.Config.Controllers
|
||||
m.BulkGenerateDocumentTemplates = Database.DocumentTemplates.Where(t => !t.IsHidden).ToList();
|
||||
|
||||
// UI Extensions
|
||||
UIExtensions.ExecuteExtensions<ConfigDeviceModelShowModel>(this.ControllerContext, m);
|
||||
UIExtensions.ExecuteExtensions<ConfigDeviceModelShowModel>(ControllerContext, m);
|
||||
|
||||
return View(MVC.Config.DeviceModel.Views.Show, m);
|
||||
}
|
||||
@@ -55,23 +56,60 @@ namespace Disco.Web.Areas.Config.Controllers
|
||||
var m = Models.DeviceModel.IndexModel.Build(Database);
|
||||
|
||||
// UI Extensions
|
||||
UIExtensions.ExecuteExtensions<ConfigDeviceModelIndexModel>(this.ControllerContext, m);
|
||||
UIExtensions.ExecuteExtensions<ConfigDeviceModelIndexModel>(ControllerContext, m);
|
||||
|
||||
return View(m);
|
||||
}
|
||||
}
|
||||
|
||||
[DiscoAuthorizeAll(Claims.Config.DeviceModel.CreateCustom, Claims.Config.DeviceModel.Configure)]
|
||||
[HttpGet]
|
||||
public virtual ActionResult Create()
|
||||
{
|
||||
var m = new Models.DeviceModel.CreateModel();
|
||||
|
||||
// UI Extensions
|
||||
UIExtensions.ExecuteExtensions<ConfigDeviceModelCreateModel>(ControllerContext, m);
|
||||
|
||||
return View(m);
|
||||
}
|
||||
|
||||
[DiscoAuthorizeAll(Claims.Config.DeviceModel.CreateCustom, Claims.Config.DeviceModel.Configure)]
|
||||
[HttpPost, ValidateAntiForgeryToken]
|
||||
public virtual ActionResult Create(Models.DeviceModel.CreateModel model)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
var deviceModel = new DeviceModel()
|
||||
{
|
||||
Description = model.Description.NullOrTrimmed(),
|
||||
Manufacturer = model.Manufacturer.NullOrTrimmed(),
|
||||
Model = model.ManufacturerModel.NullOrTrimmed(),
|
||||
ModelType = DeviceModel.CustomModelType,
|
||||
};
|
||||
|
||||
Database.DeviceModels.Add(deviceModel);
|
||||
Database.SaveChanges();
|
||||
return RedirectToAction(MVC.Config.DeviceModel.Index(deviceModel.Id));
|
||||
}
|
||||
|
||||
// UI Extensions
|
||||
UIExtensions.ExecuteExtensions<ConfigDeviceModelCreateModel>(ControllerContext, model);
|
||||
|
||||
return View(model);
|
||||
}
|
||||
|
||||
[DiscoAuthorize(Claims.Config.DeviceModel.Show)]
|
||||
public virtual ActionResult GenericComponents()
|
||||
{
|
||||
var m = new Models.DeviceModel.ComponentsModel()
|
||||
{
|
||||
DeviceComponents = Database.DeviceComponents.Include("JobSubTypes").Where(dc => !dc.DeviceModelId.HasValue).ToList(),
|
||||
JobSubTypes = Database.JobSubTypes.Where(jst => jst.JobTypeId == Disco.Models.Repository.JobType.JobTypeIds.HNWar).ToList()
|
||||
JobSubTypes = Database.JobSubTypes.Where(jst => jst.JobTypeId == JobType.JobTypeIds.HNWar).ToList()
|
||||
};
|
||||
|
||||
// UI Extensions
|
||||
UIExtensions.ExecuteExtensions<ConfigDeviceModelComponentsModel>(this.ControllerContext, m);
|
||||
UIExtensions.ExecuteExtensions<ConfigDeviceModelComponentsModel>(ControllerContext, m);
|
||||
|
||||
return View(m);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
using Disco.Models.UI.Config.DeviceModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Disco.Web.Areas.Config.Models.DeviceModel
|
||||
{
|
||||
public class CreateModel : ConfigDeviceModelCreateModel
|
||||
{
|
||||
[Required, StringLength(500)]
|
||||
public string Description { get; set; }
|
||||
[StringLength(200)]
|
||||
public string Manufacturer { get; set; }
|
||||
[StringLength(200)]
|
||||
public string ManufacturerModel { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
@model Disco.Web.Areas.Config.Models.DeviceModel.CreateModel
|
||||
@{
|
||||
Authorization.RequireAll(Claims.Config.DeviceModel.CreateCustom, Claims.Config.DeviceModel.Configure);
|
||||
|
||||
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Device Models", MVC.Config.DeviceModel.Index(null), "Create Custom");
|
||||
}
|
||||
@using (Html.BeginForm())
|
||||
{
|
||||
@Html.AntiForgeryToken()
|
||||
<div class="form" style="width: 450px">
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
Name / Description:
|
||||
</th>
|
||||
<td>
|
||||
@Html.TextBoxFor(model => model.Description)<br />@Html.ValidationMessageFor(model => model.Description)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Manufacturer:
|
||||
</th>
|
||||
<td>@Html.TextBoxFor(model => model.Manufacturer)<br />@Html.ValidationMessageFor(model => model.Manufacturer)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Model:
|
||||
</th>
|
||||
<td>@Html.TextBoxFor(model => model.ManufacturerModel)<br />@Html.ValidationMessageFor(model => model.ManufacturerModel)
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p class="actions">
|
||||
<input type="submit" class="button" value="Create Custom" />
|
||||
</p>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
$('#Description').focus().select();
|
||||
});
|
||||
</script>
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
#pragma warning disable 1591
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Disco.Web.Areas.Config.Views.DeviceModel
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Helpers;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Mvc.Ajax;
|
||||
using System.Web.Mvc.Html;
|
||||
using System.Web.Routing;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.WebPages;
|
||||
using Disco;
|
||||
using Disco.Models.Repository;
|
||||
using Disco.Services;
|
||||
using Disco.Services.Authorization;
|
||||
using Disco.Services.Web;
|
||||
using Disco.Web;
|
||||
using Disco.Web.Extensions;
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")]
|
||||
[System.Web.WebPages.PageVirtualPathAttribute("~/Areas/Config/Views/DeviceModel/Create.cshtml")]
|
||||
public partial class Create : Disco.Services.Web.WebViewPage<Disco.Web.Areas.Config.Models.DeviceModel.CreateModel>
|
||||
{
|
||||
public Create()
|
||||
{
|
||||
}
|
||||
public override void Execute()
|
||||
{
|
||||
|
||||
#line 2 "..\..\Areas\Config\Views\DeviceModel\Create.cshtml"
|
||||
|
||||
Authorization.RequireAll(Claims.Config.DeviceModel.CreateCustom, Claims.Config.DeviceModel.Configure);
|
||||
|
||||
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Device Models", MVC.Config.DeviceModel.Index(null), "Create Custom");
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n");
|
||||
|
||||
|
||||
#line 7 "..\..\Areas\Config\Views\DeviceModel\Create.cshtml"
|
||||
using (Html.BeginForm())
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 9 "..\..\Areas\Config\Views\DeviceModel\Create.cshtml"
|
||||
Write(Html.AntiForgeryToken());
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 9 "..\..\Areas\Config\Views\DeviceModel\Create.cshtml"
|
||||
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <div");
|
||||
|
||||
WriteLiteral(" class=\"form\"");
|
||||
|
||||
WriteLiteral(" style=\"width: 450px\"");
|
||||
|
||||
WriteLiteral(">\r\n <table>\r\n <tr>\r\n <th>\r\n N" +
|
||||
"ame / Description:\r\n </th>\r\n <td>\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 17 "..\..\Areas\Config\Views\DeviceModel\Create.cshtml"
|
||||
Write(Html.TextBoxFor(model => model.Description));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("<br />");
|
||||
|
||||
|
||||
#line 17 "..\..\Areas\Config\Views\DeviceModel\Create.cshtml"
|
||||
Write(Html.ValidationMessageFor(model => model.Description));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n </td>\r\n </tr>\r\n <tr>\r\n <th" +
|
||||
">\r\n Manufacturer:\r\n </th>\r\n <td" +
|
||||
">");
|
||||
|
||||
|
||||
#line 24 "..\..\Areas\Config\Views\DeviceModel\Create.cshtml"
|
||||
Write(Html.TextBoxFor(model => model.Manufacturer));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("<br />");
|
||||
|
||||
|
||||
#line 24 "..\..\Areas\Config\Views\DeviceModel\Create.cshtml"
|
||||
Write(Html.ValidationMessageFor(model => model.Manufacturer));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n </td>\r\n </tr>\r\n <tr>\r\n <th" +
|
||||
">\r\n Model:\r\n </th>\r\n <td>");
|
||||
|
||||
|
||||
#line 31 "..\..\Areas\Config\Views\DeviceModel\Create.cshtml"
|
||||
Write(Html.TextBoxFor(model => model.ManufacturerModel));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("<br />");
|
||||
|
||||
|
||||
#line 31 "..\..\Areas\Config\Views\DeviceModel\Create.cshtml"
|
||||
Write(Html.ValidationMessageFor(model => model.ManufacturerModel));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n </td>\r\n </tr>\r\n </table>\r\n <p");
|
||||
|
||||
WriteLiteral(" class=\"actions\"");
|
||||
|
||||
WriteLiteral(">\r\n <input");
|
||||
|
||||
WriteLiteral(" type=\"submit\"");
|
||||
|
||||
WriteLiteral(" class=\"button\"");
|
||||
|
||||
WriteLiteral(" value=\"Create Custom\"");
|
||||
|
||||
WriteLiteral(" />\r\n </p>\r\n </div>\r\n");
|
||||
|
||||
WriteLiteral(" <script");
|
||||
|
||||
WriteLiteral(" type=\"text/javascript\"");
|
||||
|
||||
WriteLiteral(">\r\n $(function () {\r\n $(\'#Description\').focus().select();\r\n " +
|
||||
" });\r\n </script>\r\n");
|
||||
|
||||
|
||||
#line 44 "..\..\Areas\Config\Views\DeviceModel\Create.cshtml"
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
@@ -64,4 +64,8 @@
|
||||
</table>
|
||||
<div class="actionBar">
|
||||
@Html.ActionLinkButton("Generic Components", MVC.Config.DeviceModel.GenericComponents())
|
||||
@if (Authorization.HasAll(Claims.Config.DeviceModel.CreateCustom, Claims.Config.DeviceModel.Configure))
|
||||
{
|
||||
@Html.ActionLinkButton("Create Custom Device Model", MVC.Config.DeviceModel.Create())
|
||||
}
|
||||
</div>
|
||||
@@ -304,7 +304,38 @@ Write(Html.ActionLinkButton("Generic Components", MVC.Config.DeviceModel.Generic
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n</div>");
|
||||
WriteLiteral("\r\n");
|
||||
|
||||
|
||||
#line 67 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 67 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
|
||||
if (Authorization.HasAll(Claims.Config.DeviceModel.CreateCustom, Claims.Config.DeviceModel.Configure))
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 69 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
|
||||
Write(Html.ActionLinkButton("Create Custom Device Model", MVC.Config.DeviceModel.Create()));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 69 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
|
||||
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</div>");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
var canConfig = Authorization.Has(Claims.Config.DeviceModel.Configure);
|
||||
var canViewPlugins = Authorization.Has(Claims.Config.Plugin.Install);
|
||||
var isCustom = Model.DeviceModel.IsCustomModel();
|
||||
|
||||
if (canConfig)
|
||||
{
|
||||
@@ -47,44 +48,82 @@
|
||||
{
|
||||
@Html.DisplayFor(model => model.DeviceModel.Description)
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Manufacturer:
|
||||
</th>
|
||||
<td>
|
||||
@Html.DisplayFor(model => model.DeviceModel.Manufacturer)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Model:
|
||||
</th>
|
||||
<td>
|
||||
@Html.DisplayFor(model => model.DeviceModel.Model)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Statistics</th>
|
||||
<td>
|
||||
<div><strong>@Model.DeviceCount.ToString("n0")</strong> @(Model.DeviceCount == 1 ? "devices is" : "devices are") of this model type.</div>
|
||||
@if (Model.DeviceDecommissionedCount > 0)
|
||||
{
|
||||
<div class="smallMessage">@Model.DeviceDecommissionedCount.ToString("n0") @(Model.DeviceDecommissionedCount == 1 ? "device is" : "devices are") decommissioned.</div>
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Default Purchase Date:
|
||||
</th>
|
||||
<td>
|
||||
@if (canConfig)
|
||||
{
|
||||
@Html.EditorFor(model => model.DeviceModel.DefaultPurchaseDate)
|
||||
@AjaxHelpers.AjaxLoader()
|
||||
<script>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Manufacturer:
|
||||
</th>
|
||||
<td>
|
||||
@if (isCustom && canConfig)
|
||||
{
|
||||
@Html.EditorFor(model => model.DeviceModel.Manufacturer)
|
||||
@AjaxHelpers.AjaxSave()
|
||||
@AjaxHelpers.AjaxLoader()
|
||||
<script>
|
||||
$(function () {
|
||||
document.DiscoFunctions.PropertyChangeHelper(
|
||||
$('#DeviceModel_Manufacturer'),
|
||||
'Manufacturer',
|
||||
'@Url.Action(MVC.API.DeviceModel.UpdateManufacturer(Model.DeviceModel.Id))',
|
||||
'manufacturer'
|
||||
);
|
||||
});
|
||||
</script>
|
||||
}
|
||||
else
|
||||
{
|
||||
@Html.DisplayFor(model => model.DeviceModel.Manufacturer)
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Model:
|
||||
</th>
|
||||
<td>
|
||||
@if (isCustom && canConfig)
|
||||
{
|
||||
@Html.EditorFor(model => model.DeviceModel.Model)
|
||||
@AjaxHelpers.AjaxSave()
|
||||
@AjaxHelpers.AjaxLoader()
|
||||
<script>
|
||||
$(function () {
|
||||
document.DiscoFunctions.PropertyChangeHelper(
|
||||
$('#DeviceModel_Model'),
|
||||
'Model',
|
||||
'@Url.Action(MVC.API.DeviceModel.UpdateModel(Model.DeviceModel.Id))',
|
||||
'model'
|
||||
);
|
||||
});
|
||||
</script>
|
||||
}
|
||||
else
|
||||
{
|
||||
@Html.DisplayFor(model => model.DeviceModel.Model)
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Statistics</th>
|
||||
<td>
|
||||
<div><strong>@Model.DeviceCount.ToString("n0")</strong> @(Model.DeviceCount == 1 ? "devices is" : "devices are") of this model type.</div>
|
||||
@if (Model.DeviceDecommissionedCount > 0)
|
||||
{
|
||||
<div class="smallMessage">@Model.DeviceDecommissionedCount.ToString("n0") @(Model.DeviceDecommissionedCount == 1 ? "device is" : "devices are") decommissioned.</div>
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Default Purchase Date:
|
||||
</th>
|
||||
<td>
|
||||
@if (canConfig)
|
||||
{
|
||||
@Html.EditorFor(model => model.DeviceModel.DefaultPurchaseDate)
|
||||
@AjaxHelpers.AjaxLoader()
|
||||
<script>
|
||||
$(function () {
|
||||
var dateField = $('#DeviceModel_DefaultPurchaseDate');
|
||||
document.DiscoFunctions.DateChangeHelper(
|
||||
@@ -96,26 +135,26 @@
|
||||
true
|
||||
);
|
||||
});
|
||||
</script>
|
||||
}
|
||||
else
|
||||
{
|
||||
@CommonHelpers.FriendlyDate(Model.DeviceModel.DefaultPurchaseDate, "Unknown")
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Default Warranty Provider:
|
||||
</th>
|
||||
<td>
|
||||
@if (canConfig)
|
||||
{
|
||||
if (Model.WarrantyProviders.Count > 0)
|
||||
{
|
||||
@Html.DropDownListFor(model => model.DeviceModel.DefaultWarrantyProvider, Model.WarrantyProviders.ToSelectListItems(Model.DeviceModel.DefaultWarrantyProvider, true, "None"))
|
||||
@AjaxHelpers.AjaxLoader()
|
||||
<script>
|
||||
</script>
|
||||
}
|
||||
else
|
||||
{
|
||||
@CommonHelpers.FriendlyDate(Model.DeviceModel.DefaultPurchaseDate, "Unknown")
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Default Warranty Provider:
|
||||
</th>
|
||||
<td>
|
||||
@if (canConfig)
|
||||
{
|
||||
if (Model.WarrantyProviders.Count > 0)
|
||||
{
|
||||
@Html.DropDownListFor(model => model.DeviceModel.DefaultWarrantyProvider, Model.WarrantyProviders.ToSelectListItems(Model.DeviceModel.DefaultWarrantyProvider, true, "None"))
|
||||
@AjaxHelpers.AjaxLoader()
|
||||
<script>
|
||||
$(function () {
|
||||
document.DiscoFunctions.PropertyChangeHelper(
|
||||
$('#DeviceModel_DefaultWarrantyProvider'),
|
||||
@@ -124,54 +163,54 @@
|
||||
'DefaultWarrantyProvider'
|
||||
);
|
||||
});
|
||||
</script>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="smallMessage">No warranty provider plugins installed</span>
|
||||
}
|
||||
if (canViewPlugins)
|
||||
{
|
||||
<div class="info-box">
|
||||
<p class="fa-p">
|
||||
<i class="fa fa-info-circle"></i>View the <a href="@(Url.Action(MVC.Config.Plugins.Install()))">Plugin Catalogue</a> to discover and install warranty provider plugins.
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Model.DeviceModel.DefaultWarrantyProvider == null)
|
||||
{
|
||||
<span class="smallMessage"><None Specified></span>
|
||||
}
|
||||
else
|
||||
{
|
||||
var provider = Model.WarrantyProviders.FirstOrDefault(wp => wp.Id == Model.DeviceModel.DefaultWarrantyProvider);
|
||||
if (provider == null)
|
||||
{
|
||||
<span class="smallMessage"><None Specified></span>
|
||||
</script>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="smallMessage">No warranty provider plugins installed</span>
|
||||
}
|
||||
if (canViewPlugins)
|
||||
{
|
||||
<div class="info-box">
|
||||
<p class="fa-p">
|
||||
<i class="fa fa-info-circle"></i>View the <a href="@(Url.Action(MVC.Config.Plugins.Install()))">Plugin Catalogue</a> to discover and install warranty provider plugins.
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@provider.Name
|
||||
if (Model.DeviceModel.DefaultWarrantyProvider == null)
|
||||
{
|
||||
<span class="smallMessage"><None Specified></span>
|
||||
}
|
||||
else
|
||||
{
|
||||
var provider = Model.WarrantyProviders.FirstOrDefault(wp => wp.Id == Model.DeviceModel.DefaultWarrantyProvider);
|
||||
if (provider == null)
|
||||
{
|
||||
<span class="smallMessage"><None Specified></span>
|
||||
}
|
||||
else
|
||||
{
|
||||
@provider.Name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Default Repair Provider:
|
||||
</th>
|
||||
<td>
|
||||
@if (canConfig)
|
||||
{
|
||||
if (Model.RepairProviders.Count > 0)
|
||||
{
|
||||
@Html.DropDownListFor(model => model.DeviceModel.DefaultRepairProvider, Model.RepairProviders.ToSelectListItems(Model.DeviceModel.DefaultRepairProvider, true, "None"))
|
||||
@AjaxHelpers.AjaxLoader()
|
||||
<script>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Default Repair Provider:
|
||||
</th>
|
||||
<td>
|
||||
@if (canConfig)
|
||||
{
|
||||
if (Model.RepairProviders.Count > 0)
|
||||
{
|
||||
@Html.DropDownListFor(model => model.DeviceModel.DefaultRepairProvider, Model.RepairProviders.ToSelectListItems(Model.DeviceModel.DefaultRepairProvider, true, "None"))
|
||||
@AjaxHelpers.AjaxLoader()
|
||||
<script>
|
||||
$(function () {
|
||||
document.DiscoFunctions.PropertyChangeHelper(
|
||||
$('#DeviceModel_DefaultRepairProvider'),
|
||||
@@ -180,68 +219,68 @@
|
||||
'DefaultRepairProvider'
|
||||
);
|
||||
});
|
||||
</script>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div>No repair provider plugins installed</div>
|
||||
}
|
||||
if (canViewPlugins)
|
||||
{
|
||||
<div class="info-box">
|
||||
<p class="fa-p">
|
||||
<i class="fa fa-info-circle"></i>View the <a href="@(Url.Action(MVC.Config.Plugins.Install()))">Plugin Catalogue</a> to discover and install repair provider plugins.
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Model.DeviceModel.DefaultRepairProvider == null)
|
||||
{
|
||||
<span class="smallMessage"><None Specified></span>
|
||||
}
|
||||
else
|
||||
{
|
||||
var provider = Model.RepairProviders.FirstOrDefault(wp => wp.Id == Model.DeviceModel.DefaultRepairProvider);
|
||||
if (provider == null)
|
||||
{
|
||||
<span class="smallMessage"><None Specified></span>
|
||||
</script>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div>No repair provider plugins installed</div>
|
||||
}
|
||||
if (canViewPlugins)
|
||||
{
|
||||
<div class="info-box">
|
||||
<p class="fa-p">
|
||||
<i class="fa fa-info-circle"></i>View the <a href="@(Url.Action(MVC.Config.Plugins.Install()))">Plugin Catalogue</a> to discover and install repair provider plugins.
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@provider.Name
|
||||
if (Model.DeviceModel.DefaultRepairProvider == null)
|
||||
{
|
||||
<span class="smallMessage"><None Specified></span>
|
||||
}
|
||||
else
|
||||
{
|
||||
var provider = Model.RepairProviders.FirstOrDefault(wp => wp.Id == Model.DeviceModel.DefaultRepairProvider);
|
||||
if (provider == null)
|
||||
{
|
||||
<span class="smallMessage"><None Specified></span>
|
||||
}
|
||||
else
|
||||
{
|
||||
@provider.Name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Type:
|
||||
</th>
|
||||
<td>
|
||||
@Html.DisplayFor(model => model.DeviceModel.ModelType)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Image:
|
||||
</th>
|
||||
<td>
|
||||
<img alt="Model Image" src="@Url.Action(MVC.API.DeviceModel.Image(Model.DeviceModel.Id, Model.DeviceModel.ImageHash()))" />
|
||||
@if (canConfig)
|
||||
{
|
||||
<hr />
|
||||
using (Html.BeginForm(MVC.API.DeviceModel.Image(Model.DeviceModel.Id, true, null), FormMethod.Post, new { enctype = "multipart/form-data" }))
|
||||
{
|
||||
<input type="file" name="Image" id="Image" style="width: 220px;" />
|
||||
<input class="button small" type="submit" value="Upload Image" />
|
||||
}
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Type:
|
||||
</th>
|
||||
<td>
|
||||
@Html.DisplayFor(model => model.DeviceModel.ModelType)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Image:
|
||||
</th>
|
||||
<td>
|
||||
<img alt="Model Image" src="@Url.Action(MVC.API.DeviceModel.Image(Model.DeviceModel.Id, Model.DeviceModel.ImageHash()))" />
|
||||
@if (canConfig)
|
||||
{
|
||||
<hr />
|
||||
using (Html.BeginForm(MVC.API.DeviceModel.Image(Model.DeviceModel.Id, true, null), FormMethod.Post, new { enctype = "multipart/form-data" }))
|
||||
{
|
||||
<input type="file" name="Image" id="Image" style="width: 220px;" />
|
||||
<input class="button small" type="submit" value="Upload Image" />
|
||||
}
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<h2>Components</h2>
|
||||
@Html.Partial(MVC.Config.DeviceModel.Views._DeviceComponentsTable, Model.DeviceComponentsModel)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user