Files
Disco/Disco.Web/Areas/Config/Views/DeviceModel/_DeviceComponentsTable.generated.cs
T
2025-07-31 16:18:32 +10:00

605 lines
27 KiB
C#

#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/_DeviceComponentsTable.cshtml")]
public partial class _DeviceComponentsTable : Disco.Services.Web.WebViewPage<Disco.Web.Areas.Config.Models.DeviceModel.ComponentsModel>
{
public _DeviceComponentsTable()
{
}
public override void Execute()
{
#line 2 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
Authorization.Require(Claims.Config.DeviceModel.Show);
var canConfig = Authorization.Has(Claims.Config.DeviceModel.ConfigureComponents);
Html.BundleDeferred("~/ClientScripts/Modules/Disco-jQueryExtensions");
#line default
#line hidden
WriteLiteral("\r\n");
#line 9 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
if (canConfig)
{
#line default
#line hidden
WriteLiteral(" <table");
WriteLiteral(" id=\"deviceComponents\"");
WriteLiteral(" data-devicemodelid=\"");
#line 11 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
Write(Model.DeviceModelId.HasValue ? Model.DeviceModelId.Value.ToString() : string.Empty);
#line default
#line hidden
WriteLiteral("\"");
WriteLiteral(" data-addurl=\"");
#line 11 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
Write(Url.Action(MVC.API.DeviceModel.ComponentAdd(null, null, null)));
#line default
#line hidden
WriteLiteral("\"");
WriteLiteral(" data-updateurl=\"");
#line 11 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
Write(Url.Action(MVC.API.DeviceModel.ComponentUpdate()));
#line default
#line hidden
WriteLiteral("\"");
WriteLiteral(" data-removeurl=\"");
#line 11 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
Write(Url.Action(MVC.API.DeviceModel.ComponentRemove()));
#line default
#line hidden
WriteLiteral("\"");
WriteLiteral(" data-geturl=\"");
#line 11 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
Write(Url.Action(MVC.API.DeviceModel.Component()));
#line default
#line hidden
WriteLiteral("\"");
WriteLiteral(" data-updatejobsubtypesurl=\"");
#line 11 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
Write(Url.Action(MVC.API.DeviceModel.ComponentUpdateJobSubTypes()));
#line default
#line hidden
WriteLiteral("\"");
WriteLiteral(">\r\n <tr>\r\n <th>\r\n Description\r\n </th>" +
"\r\n <th>\r\n Cost\r\n </th>\r\n <th>\r\n " +
" Job Types\r\n </th>\r\n <th");
WriteLiteral(" class=\"actions\"");
WriteLiteral(">\r\n &nbsp;\r\n </th>\r\n </tr>\r\n");
#line 26 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
#line default
#line hidden
#line 26 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
foreach (var item in Model.DeviceComponents)
{
#line default
#line hidden
WriteLiteral(" <tr");
WriteLiteral(" data-devicecomponentid=\"");
#line 28 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
Write(item.Id);
#line default
#line hidden
WriteLiteral("\"");
WriteLiteral(">\r\n <td>\r\n <input");
WriteLiteral(" type=\"text\"");
WriteLiteral(" class=\"description\"");
WriteAttribute("value", Tuple.Create(" value=\"", 1318), Tuple.Create("\"", 1343)
#line 30 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
, Tuple.Create(Tuple.Create("", 1326), Tuple.Create<System.Object, System.Int32>(item.Description
#line default
#line hidden
, 1326), false)
);
WriteLiteral(" />\r\n </td>\r\n <td>\r\n <input");
WriteLiteral(" type=\"text\"");
WriteLiteral(" class=\"cost\"");
WriteAttribute("value", Tuple.Create(" value=\"", 1445), Tuple.Create("\"", 1477)
#line 33 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
, Tuple.Create(Tuple.Create("", 1453), Tuple.Create<System.Object, System.Int32>(item.Cost.ToString("C")
#line default
#line hidden
, 1453), false)
);
WriteLiteral(" />\r\n </td>\r\n <td>\r\n <span");
WriteLiteral(" class=\"fa-stack edit\"");
WriteLiteral(">\r\n <i");
WriteLiteral(" class=\"fa fa-list-alt fa-stack-2x\"");
WriteLiteral("></i>\r\n <i");
WriteAttribute("class", Tuple.Create(" class=\"", 1672), Tuple.Create("\"", 1763)
, Tuple.Create(Tuple.Create("", 1680), Tuple.Create("fa", 1680), true)
, Tuple.Create(Tuple.Create(" ", 1682), Tuple.Create("fa-asterisk", 1683), true)
, Tuple.Create(Tuple.Create(" ", 1694), Tuple.Create("fa-stack-1x", 1695), true)
#line 38 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
, Tuple.Create(Tuple.Create("", 1706), Tuple.Create<System.Object, System.Int32>(item.JobSubTypes.Count == 0 ? " hidden" : string.Empty
#line default
#line hidden
, 1706), false)
);
WriteLiteral("></i>\r\n </span>\r\n </td>\r\n <td>\r\n" +
" <i");
WriteLiteral(" class=\"fa fa-times-circle remove\"");
WriteLiteral("></i>\r\n </td>\r\n </tr>\r\n");
#line 45 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
}
#line default
#line hidden
WriteLiteral(" <tr>\r\n <td");
WriteLiteral(" colspan=\"4\"");
WriteLiteral(">\r\n <a");
WriteLiteral(" href=\"#\"");
WriteLiteral(" id=\"addDeviceComponent\"");
WriteLiteral(">Add Component</a>\r\n </td>\r\n </tr>\r\n </table>\r\n");
WriteLiteral(" <script");
WriteLiteral(" type=\"text/javascript\"");
WriteLiteral(">\r\n $(function () {\r\n const $deviceComponents = $(\'#deviceCompo" +
"nents\');\r\n\r\n $(\'#addDeviceComponent\').click(function () {\r\n " +
" const dc = $(\'<tr><td><input type=\"text\" class=\"description\" /></td><td><i" +
"nput type=\"text\" class=\"cost\" /></td><td><span class=\"fa-stack edit\"><i class=\"f" +
"a fa-list-alt fa-stack-2x\"></i><i class=\"fa fa-asterisk fa-stack-1x hidden\"></i>" +
"</span></td><td><i class=\"fa fa-times-circle remove\"></i></td></tr>\');\r\n " +
" dc.insertBefore($deviceComponents.find(\'tr\').last());\r\n d" +
"c.find(\'input.description\').focus();\r\n return false;\r\n " +
" });\r\n\r\n $deviceComponents.on(\'change\', \'input\', function () { update" +
"Component(this); });\r\n $deviceComponents.on(\'focus\', \'input\', functio" +
"n () { $(this).select(); });\r\n\r\n $deviceComponents.on(\'click\', \'.remo" +
"ve\', removeComponent);\r\n $deviceComponents.on(\'click\', \'.edit\', funct" +
"ion () { editComponentJobTypes(this); });\r\n\r\n async function removeCo" +
"mponentConfirmed(id, row) {\r\n const body = new FormData();\r\n " +
" body.append(\'__RequestVerificationToken\', document.body.dataset.antif" +
"orgery);\r\n body.append(\'id\', id);\r\n\r\n try {\r\n " +
" const response = await fetch($deviceComponents.attr(\'data-removeu" +
"rl\'), {\r\n method: \'POST\',\r\n body: " +
"body\r\n });\r\n\r\n if (response.ok) {\r\n " +
" row.remove();\r\n } else {\r\n " +
" alert(\'Unable to remove component: \' + response.statusText);\r\n " +
" }\r\n } catch (e) {\r\n alert(\'Unable to r" +
"emove component: \' + e);\r\n }\r\n }\r\n function" +
" removeComponent() {\r\n const componentRow = $(this).closest(\'tr\')" +
";\r\n const id = componentRow.attr(\'data-devicecomponentid\');\r\n " +
" if (id) {\r\n const dialog = $(\"#dialogConfirmRemov" +
"e\");\r\n const buttons = dialog.dialog(\"option\", \"buttons\");\r\n " +
" buttons[\'Remove\'] = function () { removeComponentConfirmed(id" +
", componentRow); $(this).dialog(\"close\"); };\r\n dialog.dialog(" +
"\"option\", \"buttons\", buttons);\r\n dialog.dialog(\'open\');\r\n " +
" } else {\r\n // New - Remove\r\n c" +
"omponentRow.remove();\r\n }\r\n }\r\n async funct" +
"ion updateComponent(input) {\r\n const componentRow = $(input).clos" +
"est(\'tr\');\r\n componentRow.find(\'input\').attr(\'disabled\', true).ad" +
"dClass(\'updating\');\r\n\r\n const id = componentRow.attr(\'data-device" +
"componentid\');\r\n if (id) {\r\n // Update\r\n " +
" const body = new FormData();\r\n body.append(\'__R" +
"equestVerificationToken\', document.body.dataset.antiforgery);\r\n " +
" body.append(\'id\', id);\r\n body.append(\'description\', compon" +
"entRow.find(\'input.description\').val());\r\n body.append(\'cost\'" +
", componentRow.find(\'input.cost\').val());\r\n\r\n try {\r\n " +
" const response = await fetch($deviceComponents.attr(\'data-update" +
"url\'), {\r\n method: \'POST\',\r\n " +
" body: body\r\n });\r\n\r\n if (respon" +
"se.ok) {\r\n const result = await response.json();\r\n " +
" componentRow.find(\'input\').attr(\'disabled\', false).remo" +
"veClass(\'updating\');\r\n componentRow.find(\'input.descr" +
"iption\').val(result.Description);\r\n componentRow.find" +
"(\'input.cost\').val(result.Cost);\r\n } else {\r\n " +
" alert(\'Unable to update component: \' + response.statusText);\r\n " +
" }\r\n } catch (e) {\r\n " +
" alert(\'Unable to update component: \' + e);\r\n }\r\n " +
" } else {\r\n // Add\r\n const modelId =" +
" componentRow.closest(\'table\').attr(\'data-devicemodelid\');\r\n " +
"const body = new FormData();\r\n body.append(\'__RequestVerifica" +
"tionToken\', document.body.dataset.antiforgery);\r\n body.append" +
"(\'id\', modelId);\r\n body.append(\'description\', componentRow.fi" +
"nd(\'input.description\').val());\r\n body.append(\'cost\', compone" +
"ntRow.find(\'input.cost\').val());\r\n\r\n try {\r\n " +
" const response = await fetch($deviceComponents.attr(\'data-addurl\'), {\r\n " +
" method: \'POST\',\r\n body: bod" +
"y\r\n });\r\n\r\n if (response.ok) {\r\n " +
" const result = await response.json();\r\n " +
" componentRow.find(\'input\').attr(\'disabled\', false).removeClass(\'upd" +
"ating\');\r\n componentRow.attr(\'data-devicecomponentid\'" +
", result.Id);\r\n componentRow.find(\'input.description\'" +
").val(result.Description);\r\n componentRow.find(\'input" +
".cost\').val(result.Cost);\r\n } else {\r\n " +
" alert(\'Unable to add component: \' + response.statusText);\r\n " +
" }\r\n } catch (e) {\r\n alert(" +
"\'Unable to add component: \' + e);\r\n }\r\n }\r\n " +
" }\r\n async function editComponentJobTypes(input) {\r\n " +
" const edit$this = $(input);\r\n const componentRow = edit$th" +
"is.closest(\'tr\');\r\n const id = componentRow.attr(\'data-devicecomp" +
"onentid\');\r\n\r\n if (id) {\r\n try {\r\n " +
" const body = new FormData();\r\n body.append(\'_" +
"_RequestVerificationToken\', document.body.dataset.antiforgery);\r\n " +
" body.append(\'id\', id);\r\n const getResponse = awa" +
"it fetch($deviceComponents.attr(\'data-geturl\'), {\r\n m" +
"ethod: \'POST\',\r\n body: body\r\n " +
"})\r\n\r\n componentRow.find(\'input\').attr(\'disabled\', false)" +
".removeClass(\'updating\');\r\n if (getResponse.ok) {\r\n " +
" const component = await getResponse.json();\r\n " +
" $dialogUpdateJobTypes = $(\'#dialogUpdateJobTypes\');\r\n " +
" $dialogUpdateJobTypes.find(\'input:checked\').each(function () { $" +
"(this).prop(\'checked\', false) });\r\n for (var i = 0; i" +
" < component.JobSubTypes.length; i++) {\r\n var sjt" +
" = component.JobSubTypes[i];\r\n $dialogUpdateJobTy" +
"pes.find(\'#SubTypes_\' + sjt).prop(\'checked\', true);\r\n " +
" }\r\n $(\'#CheckboxBulkSelect_dialogUpdateJobTypes\').ch" +
"eckboxBulkSelect(\'update\');\r\n const buttons = $dialog" +
"UpdateJobTypes.dialog(\"option\", \"buttons\");\r\n buttons" +
"[\'Save\'] = function () {\r\n async function saveAsy" +
"nc() {\r\n const body = new FormData();\r\n " +
" let jobSubTypeCount = 0;\r\n " +
" body.append(\'__RequestVerificationToken\', document.body.dataset.anti" +
"forgery);\r\n body.append(\'id\', id);\r\n " +
" $dialogUpdateJobTypes.find(\'input:checked\').each(func" +
"tion () { body.append(\'jobSubTypes\', $(this).val()); jobSubTypeCount++; });\r\n\r\n " +
" try {\r\n " +
" const updateResponse = await fetch($deviceComponents.attr(\'data-updatejobsubty" +
"pesurl\'), {\r\n method: \'POST\',\r\n " +
" body: body\r\n " +
" })\r\n\r\n if (updateResponse.ok) {" +
"\r\n if (jobSubTypeCount > 0) {\r\n " +
" edit$this.find(\'.fa-asterisk\').removeC" +
"lass(\'hidden\');\r\n } else {\r\n " +
" edit$this.find(\'.fa-asterisk\').addClass(\'" +
"hidden\');\r\n }\r\n " +
" $dialogUpdateJobTypes.dialog(\"close\");\r\n " +
" } else {\r\n aler" +
"t(\'Unable to update component sub types: \' + updateResponse.statusText);\r\n " +
" }\r\n } catch" +
" (e) {\r\n alert(\'Unable to update componen" +
"t sub types: \' + e);\r\n }\r\n " +
" }\r\n saveAsync();\r\n " +
" };\r\n $dialogUpdateJobTypes.dialog(\"option\"," +
" \"buttons\", buttons);\r\n $dialogUpdateJobTypes.dialog(" +
"\'open\');\r\n } else {\r\n alert(\'U" +
"nable to load component: \' + getResponse.statusText);\r\n }" +
"\r\n } catch (e) {\r\n alert(\'Unable to lo" +
"ad component: \' + e);\r\n }\r\n }\r\n }\r\n" +
"\r\n $(\"#dialogConfirmRemove\").dialog({\r\n resizable: fal" +
"se,\r\n height: 140,\r\n modal: true,\r\n " +
" autoOpen: false,\r\n buttons: {\r\n \"Remove\": fun" +
"ction () {\r\n $(this).dialog(\"close\");\r\n " +
" },\r\n Cancel: function () {\r\n $(this)" +
".dialog(\"close\");\r\n }\r\n }\r\n });\r\n\r\n" +
" $(\'#dialogUpdateJobTypes\').dialog({\r\n resizable: fals" +
"e,\r\n modal: true,\r\n autoOpen: false,\r\n " +
" width: 550,\r\n buttons: {\r\n \"Save\": functio" +
"n () {\r\n $(this).dialog(\"close\");\r\n }," +
"\r\n Cancel: function () {\r\n $(this).dia" +
"log(\"close\");\r\n }\r\n }\r\n });\r\n\r\n " +
" $(\'#CheckboxBulkSelect_dialogUpdateJobTypes\').checkboxBulkSelect({ paren" +
"tSelector: \'div\' });\r\n });\r\n </script>\r\n");
WriteLiteral(" <div");
WriteLiteral(" id=\"dialogUpdateJobTypes\"");
WriteLiteral(" title=\"Update Job Types\"");
WriteLiteral(">\r\n <div>\r\n <h2>Hardware Non-Warranty Job Types</h2>\r\n");
WriteLiteral(" ");
#line 265 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
Write(CommonHelpers.CheckBoxList("SubTypes", Model.JobSubTypes.ToSelectListItems(), 2));
#line default
#line hidden
WriteLiteral("\r\n <br />\r\n <span");
WriteLiteral(" id=\"CheckboxBulkSelect_dialogUpdateJobTypes\"");
WriteLiteral(" class=\"checkboxBulkSelectContainer\"");
WriteLiteral("></span>\r\n </div>\r\n </div>\r\n");
WriteLiteral(" <div");
WriteLiteral(" id=\"dialogConfirmRemove\"");
WriteLiteral(" title=\"Delete this Component?\"");
WriteLiteral(">\r\n <p>\r\n <i");
WriteLiteral(" class=\"fa fa-exclamation-triangle fa-lg warning\"");
WriteLiteral("></i>\r\n This item will be permanently deleted and cannot be recovered." +
" Are you sure?\r\n </p>\r\n </div>\r\n");
#line 276 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
}
else
{
#line default
#line hidden
WriteLiteral(" <table");
WriteLiteral(" id=\"deviceComponents\"");
WriteLiteral(" data-devicemodelid=\"");
#line 279 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
Write(Model.DeviceModelId.HasValue ? Model.DeviceModelId.Value.ToString() : string.Empty);
#line default
#line hidden
WriteLiteral("\"");
WriteLiteral(">\r\n <tr>\r\n <th>\r\n Description\r\n </th>" +
"\r\n <th>\r\n Cost\r\n </th>\r\n <th>\r\n " +
" Job Types\r\n </th>\r\n </tr>\r\n");
#line 291 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
#line default
#line hidden
#line 291 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
foreach (var item in Model.DeviceComponents)
{
#line default
#line hidden
WriteLiteral(" <tr");
WriteLiteral(" data-devicecomponentid=\"");
#line 293 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
Write(item.Id);
#line default
#line hidden
WriteLiteral("\"");
WriteLiteral(">\r\n <td>\r\n");
WriteLiteral(" ");
#line 295 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
Write(item.Description);
#line default
#line hidden
WriteLiteral("\r\n </td>\r\n <td>\r\n");
WriteLiteral(" ");
#line 298 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
Write(item.Cost.ToString("C"));
#line default
#line hidden
WriteLiteral("\r\n </td>\r\n <td>\r\n");
#line 301 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
#line default
#line hidden
#line 301 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
if (item.JobSubTypes.Count > 0)
{
#line default
#line hidden
WriteLiteral(" <ul>\r\n");
#line 304 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
#line default
#line hidden
#line 304 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
foreach (var jst in item.JobSubTypes)
{
#line default
#line hidden
WriteLiteral(" <li>");
#line 306 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
Write(jst.Description);
#line default
#line hidden
WriteLiteral("</li>\r\n");
#line 307 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
}
#line default
#line hidden
WriteLiteral(" </ul>\r\n");
#line 309 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
}
else
{
#line default
#line hidden
WriteLiteral(" <span");
WriteLiteral(" class=\"smallMessage\"");
WriteLiteral(">&lt;None Specified&gt;</span>\r\n");
#line 313 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
}
#line default
#line hidden
WriteLiteral(" </td>\r\n </tr>\r\n");
#line 316 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
}
#line default
#line hidden
WriteLiteral(" </table>\r\n");
#line 318 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
}
#line default
#line hidden
}
}
}
#pragma warning restore 1591