#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.34014
//
//     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.BI.Extensions;
    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(">\r\n        <tr>\r\n            <th>Description\r\n            </th>\r\n            <th>" +
"Cost\r\n            </th>\r\n            <th>Job Types\r\n            </th>\r\n         " +
"   <th");

WriteLiteral(" class=\"actions\"");

WriteLiteral(">&nbsp;\r\n            </th>\r\n        </tr>\r\n");

            
            #line 22 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
        
            
            #line default
            #line hidden
            
            #line 22 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
         foreach (var item in Model.DeviceComponents)
        {

            
            #line default
            #line hidden
WriteLiteral("            <tr");

WriteLiteral(" data-devicecomponentid=\"");

            
            #line 24 "..\..\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=\"", 883), Tuple.Create("\"", 908)
            
            #line 26 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
, Tuple.Create(Tuple.Create("", 891), Tuple.Create<System.Object, System.Int32>(item.Description
            
            #line default
            #line hidden
, 891), false)
);

WriteLiteral(" />\r\n                </td>\r\n                <td>\r\n                    <input");

WriteLiteral(" type=\"text\"");

WriteLiteral(" class=\"cost\"");

WriteAttribute("value", Tuple.Create(" value=\"", 1010), Tuple.Create("\"", 1042)
            
            #line 29 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
, Tuple.Create(Tuple.Create("", 1018), Tuple.Create<System.Object, System.Int32>(item.Cost.ToString("C")
            
            #line default
            #line hidden
, 1018), 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=\"", 1237), Tuple.Create("\"", 1328)
, Tuple.Create(Tuple.Create("", 1245), Tuple.Create("fa", 1245), true)
, Tuple.Create(Tuple.Create(" ", 1247), Tuple.Create("fa-asterisk", 1248), true)
, Tuple.Create(Tuple.Create(" ", 1259), Tuple.Create("fa-stack-1x", 1260), true)
            
            #line 34 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
, Tuple.Create(Tuple.Create("", 1271), Tuple.Create<System.Object, System.Int32>(item.JobSubTypes.Count == 0 ? " hidden" : string.Empty
            
            #line default
            #line hidden
, 1271), 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 41 "..\..\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(@">
        $(function () {
            var $deviceComponents = $('#deviceComponents');

            $('#addDeviceComponent').click(function () {
                var dc = $('<tr><td><input type=""text"" class=""description"" /></td><td><input type=""text"" class=""cost"" /></td><td><span class=""fa-stack edit""><i class=""fa 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>');
                dc.find('input').focus(function () { $(this).select() })
                dc.insertBefore($deviceComponents.find('tr').last());
                dc.find('input.description').focus();
                return false;
            });

            $deviceComponents.on('change', 'input', updateComponent);
            $deviceComponents.on('focus', 'input', function () { $(this).select(); });

            $deviceComponents.on('click', '.remove', removeComponent);
            $deviceComponents.on('click', '.edit', editComponentJobTypes);

            function removeComponentConfirmed(id, row) {
                var data = { id: id };
                $.ajax({
                    url: '");

            
            #line 69 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
                     Write(Url.Action(MVC.API.DeviceModel.ComponentRemove()));

            
            #line default
            #line hidden
WriteLiteral("\',\r\n                    dataType: \'json\',\r\n                    data: data,\r\n     " +
"               success: function (d) {\r\n                        if (d == \'OK\') {" +
"\r\n                            row.remove();\r\n                        } else {\r\n " +
"                           alert(\'Unable to remove component: \' + d);\r\n         " +
"               }\r\n                    },\r\n                    error: function (j" +
"qXHR, textStatus, errorThrown) {\r\n                        alert(\'Unable to remov" +
"e component: \' + textStatus);\r\n                    }\r\n                });\r\n     " +
"   }\r\n            function removeComponent() {\r\n                var componentRow" +
" = $(this).closest(\'tr\');\r\n                var id = componentRow.attr(\'data-devi" +
"cecomponentid\');\r\n                if (id) {\r\n                    var dialog = $(" +
"\"#dialogConfirmRemove\");\r\n                    var buttons = dialog.dialog(\"optio" +
"n\", \"buttons\");\r\n                    buttons[\'Remove\'] = function () { removeCom" +
"ponentConfirmed(id, componentRow); $(this).dialog(\"close\"); };\r\n                " +
"    var buttons = dialog.dialog(\"option\", \"buttons\", buttons);\r\n                " +
"    dialog.dialog(\'open\');\r\n                } else {\r\n                    // New" +
" - Remove\r\n                    componentRow.remove();\r\n                }\r\n      " +
"      }\r\n            function updateComponent() {\r\n                var component" +
"Row = $(this).closest(\'tr\');\r\n                componentRow.find(\'input\').attr(\'d" +
"isabled\', true).addClass(\'updating\');\r\n\r\n                var id = componentRow.a" +
"ttr(\'data-devicecomponentid\');\r\n                if (id) {\r\n                    /" +
"/ Update\r\n                    var data = {\r\n                        id: id,\r\n   " +
"                     Description: componentRow.find(\'input.description\').val(),\r" +
"\n                        Cost: componentRow.find(\'input.cost\').val()\r\n          " +
"          };\r\n                    $.ajax({\r\n                        url: \'");

            
            #line 111 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
                         Write(Url.Action(MVC.API.DeviceModel.ComponentUpdate()));

            
            #line default
            #line hidden
WriteLiteral(@"',
                        dataType: 'json',
                        type: 'POST',
                        data: data,
                        success: function (d) {
                            componentRow.find('input').attr('disabled', false).removeClass('updating');
                            if (d.Result == 'OK') {
                                componentRow.find('input.description').val(d.Component.Description);
                                componentRow.find('input.cost').val(d.Component.Cost);
                            } else {
                                alert('Unable to update component: ' + d.Result);
                            }
                        },
                        error: function (jqXHR, textStatus, errorThrown) {
                            alert('Unable to update component: ' + textStatus);
                        }
                    });
                } else {
                    // Add
                    id = componentRow.closest('table').attr('data-devicemodelid');
                    var data = {
                        id: id,
                        Description: componentRow.find('input.description').val(),
                        Cost: componentRow.find('input.cost').val()
                    };
                    $.ajax({
                        url: '");

            
            #line 137 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
                         Write(Url.Action(MVC.API.DeviceModel.ComponentAdd(null, null, null)));

            
            #line default
            #line hidden
WriteLiteral(@"',
                        dataType: 'json',
                        type: 'POST',
                        data: data,
                        success: function (d) {
                            componentRow.find('input').attr('disabled', false).removeClass('updating');
                            if (d.Result == 'OK') {
                                componentRow.attr('data-devicecomponentid', d.Component.Id);
                                componentRow.find('input.description').val(d.Component.Description);
                                componentRow.find('input.cost').val(d.Component.Cost);
                            } else {
                                alert('Unable to add component: ' + d.Result);
                            }
                        },
                        error: function (jqXHR, textStatus, errorThrown) {
                            alert('Unable to add component: ' + textStatus);
                        }
                    });
                }
            }
            function editComponentJobTypes() {
                var edit$this = $(this);
                var componentRow = edit$this.closest('tr');

                var id = componentRow.attr('data-devicecomponentid');

                if (id) {
                    var data = {
                        id: id
                    };
                    $.ajax({
                        url: '");

            
            #line 168 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
                         Write(Url.Action(MVC.API.DeviceModel.Component()));

            
            #line default
            #line hidden
WriteLiteral("\',\r\n                        dataType: \'json\',\r\n                        data: data" +
",\r\n                        success: function (d) {\r\n                            " +
"componentRow.find(\'input\').attr(\'disabled\', false).removeClass(\'updating\');\r\n   " +
"                         if (d.Result == \'OK\') {\r\n                              " +
"  $dialogUpdateJobTypes = $(\'#dialogUpdateJobTypes\');\r\n                         " +
"       $dialogUpdateJobTypes.find(\'input:checked\').each(function () { $(this).pr" +
"op(\'checked\', false) });\r\n                                for (var i = 0; i < d." +
"Component.JobSubTypes.length; i++) {\r\n                                    var sj" +
"t = d.Component.JobSubTypes[i];\r\n                                    $dialogUpda" +
"teJobTypes.find(\'#SubTypes_\' + sjt).prop(\'checked\', true);\r\n                    " +
"            }\r\n                                $(\'#CheckboxBulkSelect_dialogUpda" +
"teJobTypes\').checkboxBulkSelect(\'update\');\r\n                                var " +
"buttons = $dialogUpdateJobTypes.dialog(\"option\", \"buttons\");\r\n                  " +
"              buttons[\'Save\'] = function () {\r\n                                 " +
"   $dialogUpdateJobTypes.dialog(\"disable\");\r\n                                   " +
" var selectedSJTs = [];\r\n                                    $dialogUpdateJobTyp" +
"es.find(\'input:checked\').each(function () { selectedSJTs.push($(this).val()) });" +
"\r\n\r\n                                    var data = {\r\n                          " +
"              id: id,\r\n                                        JobSubTypes: sele" +
"ctedSJTs\r\n                                    };\r\n                              " +
"      $.ajax({\r\n                                        url: \'");

            
            #line 192 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
                                         Write(Url.Action(MVC.API.DeviceModel.ComponentUpdateJobSubTypes()));

            
            #line default
            #line hidden
WriteLiteral("\',\r\n                                        dataType: \'json\',\r\n                  " +
"                      type: \'POST\',\r\n                                        tra" +
"ditional: true,\r\n                                        data: data,\r\n          " +
"                              success: function (d) {\r\n                         " +
"                   if (d.Result == \'OK\') {\r\n                                    " +
"            if (d.Component.JobSubTypes.length > 0) {\r\n                         " +
"                           edit$this.find(\'.fa-asterisk\').removeClass(\'hidden\');" +
"\r\n                                                } else {\r\n                    " +
"                                edit$this.find(\'.fa-asterisk\').addClass(\'hidden\'" +
");\r\n                                                }\r\n                         " +
"                       $dialogUpdateJobTypes.dialog(\"enable\");\r\n                " +
"                                $dialogUpdateJobTypes.dialog(\"close\");\r\n        " +
"                                    } else {\r\n                                  " +
"              alert(\'Unable to update component sub types: \' + d.Result);\r\n     " +
"                                       }\r\n                                      " +
"  },\r\n                                        error: function (jqXHR, textStatus" +
", errorThrown) {\r\n                                            alert(\'Unable to u" +
"pdate component sub types: \' + textStatus);\r\n                                   " +
"     }\r\n                                    });\r\n                               " +
" };\r\n                                var buttons = $dialogUpdateJobTypes.dialog(" +
"\"option\", \"buttons\", buttons);\r\n                                $dialogUpdateJob" +
"Types.dialog(\'open\');\r\n                            } else {\r\n                   " +
"             alert(\'Unable to load component: \' + d.Result);\r\n                  " +
"          }\r\n                        },\r\n                        error: function" +
" (jqXHR, textStatus, errorThrown) {\r\n                            alert(\'Unable t" +
"o load component: \' + textStatus);\r\n                        }\r\n                 " +
"   });\r\n                }\r\n\r\n            }\r\n\r\n            $(\"#dialogConfirmRemov" +
"e\").dialog({\r\n                resizable: false,\r\n                height: 140,\r\n " +
"               modal: true,\r\n                autoOpen: false,\r\n                b" +
"uttons: {\r\n                    \"Remove\": function () {\r\n                        " +
"$(this).dialog(\"close\");\r\n                    },\r\n                    Cancel: fu" +
"nction () {\r\n                        $(this).dialog(\"close\");\r\n                 " +
"   }\r\n                }\r\n            });\r\n\r\n            $(\'#dialogUpdateJobTypes" +
"\').dialog({\r\n                resizable: false,\r\n                modal: true,\r\n  " +
"              autoOpen: false,\r\n                width: 550,\r\n                but" +
"tons: {\r\n                    \"Save\": function () {\r\n                        $(th" +
"is).dialog(\"close\");\r\n                    },\r\n                    Cancel: functi" +
"on () {\r\n                        $(this).dialog(\"close\");\r\n                    }" +
"\r\n                }\r\n            });\r\n\r\n            $(\'#CheckboxBulkSelect_dialo" +
"gUpdateJobTypes\').checkboxBulkSelect({ parentSelector: \'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>Description\r\n            </th>\r\n            <th>" +
"Cost\r\n            </th>\r\n            <th>Job Types\r\n            </th>\r\n        <" +
"/tr>\r\n");

            
            #line 288 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
        
            
            #line default
            #line hidden
            
            #line 288 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
         foreach (var item in Model.DeviceComponents)
        {

            
            #line default
            #line hidden
WriteLiteral("            <tr");

WriteLiteral(" data-devicecomponentid=\"");

            
            #line 290 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
                                   Write(item.Id);

            
            #line default
            #line hidden
WriteLiteral("\"");

WriteLiteral(">\r\n                <td>\r\n");

WriteLiteral("                    ");

            
            #line 292 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
               Write(item.Description);

            
            #line default
            #line hidden
WriteLiteral("\r\n                </td>\r\n                <td>\r\n");

WriteLiteral("                    ");

            
            #line 295 "..\..\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 298 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
                    
            
            #line default
            #line hidden
            
            #line 298 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
                     if (item.JobSubTypes.Count > 0)
                    {

            
            #line default
            #line hidden
WriteLiteral("                        <ul>\r\n");

            
            #line 301 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
                            
            
            #line default
            #line hidden
            
            #line 301 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
                             foreach (var jst in item.JobSubTypes)
                            {

            
            #line default
            #line hidden
WriteLiteral("                                <li>");

            
            #line 303 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
                               Write(jst.Description);

            
            #line default
            #line hidden
WriteLiteral("</li>\r\n");

            
            #line 304 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
                            }

            
            #line default
            #line hidden
WriteLiteral("                        </ul>\r\n");

            
            #line 306 "..\..\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 310 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
                    }

            
            #line default
            #line hidden
WriteLiteral("                </td>\r\n            </tr>\r\n");

            
            #line 313 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
        }

            
            #line default
            #line hidden
WriteLiteral("    </table>\r\n");

            
            #line 315 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
}
            
            #line default
            #line hidden
        }
    }
}
#pragma warning restore 1591
