From d8538d27928dbd56014c23547039f87704d33cf4 Mon Sep 17 00:00:00 2001 From: Gary Sharp Date: Mon, 2 Sep 2013 18:58:49 +1000 Subject: [PATCH] Fix: Remove Unnecessary AJAX at Log Warranty Page is always refreshed to provide information to Warranty Plugin - generate address UI at server. --- Disco.Web/Views/Job/LogWarranty.cshtml | 55 ++---- Disco.Web/Views/Job/LogWarranty.generated.cs | 194 ++++++++++++------- 2 files changed, 139 insertions(+), 110 deletions(-) diff --git a/Disco.Web/Views/Job/LogWarranty.cshtml b/Disco.Web/Views/Job/LogWarranty.cshtml index 2d1d257b..311fec08 100644 --- a/Disco.Web/Views/Job/LogWarranty.cshtml +++ b/Disco.Web/Views/Job/LogWarranty.cshtml @@ -11,32 +11,28 @@
- - - - - -
- Internal Job Id: + Internal Job Id: @Model.JobId
- Device Serial Number: + Device Serial Number: @Model.Job.Device.SerialNumber
- Device Model: + Device Model: @Model.Job.Device.DeviceModel.Manufacturer @Model.Job.Device.DeviceModel.Model
- Technician: + Technician: @Model.TechUser.DisplayName @@ -47,23 +43,32 @@
- Repair Address: + Repair Address: - @Html.DropDownListFor(model => model.OrganisationAddressId, Model.OrganisationAddresses.ToSelectListItems(Model.OrganisationAddressId, true))
+ @Html.DropDownListFor(model => model.OrganisationAddressId, Model.OrganisationAddresses.ToSelectListItems(Model.OrganisationAddressId, (Model.OrganisationAddress == null)))
@Html.ValidationMessageFor(m => m.OrganisationAddressId)
+ @{ + var oa = Model.OrganisationAddress; + if (oa != null) + { + @oa.Address +
+ @oa.Suburb, @oa.Postcode +
+ @oa.State, @oa.Country + } + }
- Warranty Provider: + Warranty Provider: @Html.DropDownListFor(model => model.WarrantyProviderId, Model.WarrantyProviders.ToSelectListItems(Model.WarrantyProviderId, true))
@@ -73,8 +78,7 @@
-

- Fault Description

+

Fault Description

@@ -103,24 +107,6 @@ var $ProviderId = $('#WarrantyProviderId'); - var updateOrganisationAddressDetails = function () { - $organisationAddressDetails.slideUp(); - var orgAddressId = $OrganisationAddressId.val(); - if (orgAddressId) { - $organisationAddressDetailsLoading.slideDown(); - $.getJSON('@(Url.Action(MVC.API.Job.OrganisationAddress()))', { id: orgAddressId }, function (data) { - $organisationAddressDetails.empty().append( - $('').text(data.Address), - '
', - $('').text(data.Suburb + ', ' + data.Postcode), - '
', - $('').text(data.State + ', ' + data.Country) - ); - $organisationAddressDetailsLoading.slideUp(); - $organisationAddressDetails.slideDown(); - }); - } - } var updateProviderDetails = function () { var providerId = $ProviderId.val(); var orgAddressId = $OrganisationAddressId.val(); @@ -129,8 +115,7 @@ window.location.href = '@(Url.Action(MVC.Job.LogWarranty(Model.JobId, null, null)))?WarrantyProviderId=' + providerId + '&OrganisationAddressId=' + orgAddressId; } } - $OrganisationAddressId.change(updateOrganisationAddressDetails).change(updateProviderDetails); + $OrganisationAddressId.change(updateProviderDetails); $ProviderId.change(updateProviderDetails); - updateOrganisationAddressDetails(); }); diff --git a/Disco.Web/Views/Job/LogWarranty.generated.cs b/Disco.Web/Views/Job/LogWarranty.generated.cs index 577d050e..6946c3a1 100644 --- a/Disco.Web/Views/Job/LogWarranty.generated.cs +++ b/Disco.Web/Views/Job/LogWarranty.generated.cs @@ -2,7 +2,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.18033 +// Runtime Version:4.0.30319.18051 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -118,39 +118,37 @@ WriteLiteral(" class=\"form\""); WriteLiteral(" style=\"width: 650px\""); -WriteLiteral(">\r\n \r\n \r\n \r\n
\r\n I" + -"nternal Job Id:\r\n \r\n"); +WriteLiteral(">\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Device Serial Number:\r\n \r\n " + -" \r\n \r\n \r\n \r\n Device Model:\r\n \r\n \r\n"); +">Device Model:\r\n \r\n \r\n \r\n \r\n \r\n Technician:\r\n \r\n \r\n WriteLiteral(" style=\"width: 150px\""); -WriteLiteral(">\r\n Repair Address:\r\n \r\n \r\n"); +WriteLiteral(">Repair Address:\r\n \r\n \r\n \r\n " + -" \r\n \r\n \r\n \r\n " + +" \r\n \r\n " + +"
Internal Job Id:\r\n " + +" \r\n"); WriteLiteral(" "); - #line 18 "..\..\Views\Job\LogWarranty.cshtml" + #line 17 "..\..\Views\Job\LogWarranty.cshtml" Write(Model.JobId); #line default #line hidden WriteLiteral("\r\n
\r\n"); +">Device Serial Number:\r\n \r\n \r\n"); WriteLiteral(" "); - #line 26 "..\..\Views\Job\LogWarranty.cshtml" + #line 24 "..\..\Views\Job\LogWarranty.cshtml" Write(Model.Job.Device.SerialNumber); #line default #line hidden WriteLiteral("\r\n
\r\n"); WriteLiteral(" "); - #line 34 "..\..\Views\Job\LogWarranty.cshtml" + #line 31 "..\..\Views\Job\LogWarranty.cshtml" Write(Model.Job.Device.DeviceModel.Manufacturer); @@ -159,20 +157,19 @@ WriteLiteral(" "); WriteLiteral(" "); - #line 34 "..\..\Views\Job\LogWarranty.cshtml" + #line 31 "..\..\Views\Job\LogWarranty.cshtml" Write(Model.Job.Device.DeviceModel.Model); #line default #line hidden WriteLiteral("\r\n
\r" + -"\n"); +">Technician:\r\n \r\n \r\n"); WriteLiteral(" "); - #line 42 "..\..\Views\Job\LogWarranty.cshtml" + #line 38 "..\..\Views\Job\LogWarranty.cshtml" Write(Model.TechUser.DisplayName); @@ -185,7 +182,7 @@ WriteLiteral(" class=\"smallMessage\""); WriteLiteral(">\r\n Email Address: "); - #line 44 "..\..\Views\Job\LogWarranty.cshtml" + #line 40 "..\..\Views\Job\LogWarranty.cshtml" Write(Model.TechUser.EmailAddress); @@ -194,7 +191,7 @@ WriteLiteral(">\r\n Email Address: "); WriteLiteral("
\r\n Phone Number: "); - #line 45 "..\..\Views\Job\LogWarranty.cshtml" + #line 41 "..\..\Views\Job\LogWarranty.cshtml" Write(Model.TechUser.PhoneNumber); @@ -205,14 +202,13 @@ WriteLiteral("\r\n \r\n
\r\n"); WriteLiteral(" "); - #line 54 "..\..\Views\Job\LogWarranty.cshtml" - Write(Html.DropDownListFor(model => model.OrganisationAddressId, Model.OrganisationAddresses.ToSelectListItems(Model.OrganisationAddressId, true))); + #line 49 "..\..\Views\Job\LogWarranty.cshtml" + Write(Html.DropDownListFor(model => model.OrganisationAddressId, Model.OrganisationAddresses.ToSelectListItems(Model.OrganisationAddressId, (Model.OrganisationAddress == null)))); #line default @@ -222,7 +218,7 @@ WriteLiteral("
\r\n"); WriteLiteral(" "); - #line 55 "..\..\Views\Job\LogWarranty.cshtml" + #line 50 "..\..\Views\Job\LogWarranty.cshtml" Write(Html.ValidationMessageFor(m => m.OrganisationAddressId)); @@ -236,14 +232,14 @@ WriteLiteral(" style=\"display: none\""); WriteLiteral(">\r\n (Links.ClientSource.Style.Images.Status.loading_gif + #line 52 "..\..\Views\Job\LogWarranty.cshtml" +, Tuple.Create(Tuple.Create("", 2081), Tuple.Create(Links.ClientSource.Style.Images.Status.loading_gif #line default #line hidden -, 2160), false) +, 2081), false) ); WriteLiteral(" alt=\"Loading\""); @@ -256,14 +252,94 @@ WriteLiteral(">Loading Details...\r\n \r\n WriteLiteral(" id=\"organisationAddressDetails\""); -WriteLiteral(">\r\n \r\n
\r\n Warranty Provider:\r\n " + -" \r\n"); +WriteLiteral(">\r\n"); + + + #line 56 "..\..\Views\Job\LogWarranty.cshtml" + + + #line default + #line hidden + + #line 56 "..\..\Views\Job\LogWarranty.cshtml" + + var oa = Model.OrganisationAddress; + if (oa != null) + { + + + #line default + #line hidden +WriteLiteral(" "); + + + #line 60 "..\..\Views\Job\LogWarranty.cshtml" + Write(oa.Address); + + + #line default + #line hidden +WriteLiteral("\r\n"); + +WriteLiteral("
\r\n"); + +WriteLiteral(" "); + + + #line 62 "..\..\Views\Job\LogWarranty.cshtml" + Write(oa.Suburb); + + + #line default + #line hidden +WriteLiteral(", "); + + + #line 62 "..\..\Views\Job\LogWarranty.cshtml" + Write(oa.Postcode); + + + #line default + #line hidden +WriteLiteral("\r\n"); + +WriteLiteral("
\r\n"); + +WriteLiteral(" "); + + + #line 64 "..\..\Views\Job\LogWarranty.cshtml" + Write(oa.State); + + + #line default + #line hidden +WriteLiteral(", "); + + + #line 64 "..\..\Views\Job\LogWarranty.cshtml" + Write(oa.Country); + + + #line default + #line hidden +WriteLiteral("\r\n"); + + + #line 65 "..\..\Views\Job\LogWarranty.cshtml" + } + + + #line default + #line hidden +WriteLiteral("\r\n \r\n
Warranty Provider:\r\n \r\n"); WriteLiteral(" "); - #line 69 "..\..\Views\Job\LogWarranty.cshtml" + #line 74 "..\..\Views\Job\LogWarranty.cshtml" Write(Html.DropDownListFor(model => model.WarrantyProviderId, Model.WarrantyProviders.ToSelectListItems(Model.WarrantyProviderId, true))); @@ -274,7 +350,7 @@ WriteLiteral("
\r\n"); WriteLiteral(" "); - #line 70 "..\..\Views\Job\LogWarranty.cshtml" + #line 75 "..\..\Views\Job\LogWarranty.cshtml" Write(Html.ValidationMessageFor(m => m.WarrantyProviderId)); @@ -290,13 +366,13 @@ WriteLiteral(" class=\"form\""); WriteLiteral(" style=\"width: 650px; margin-top: 15px;\""); -WriteLiteral(">\r\n

\r\n Fault Description

\r\n \r\n " + -" \r\n
\r\n"); +WriteLiteral(">\r\n

Fault Description

\r\n \r\n \r\n " + +" \r\n \r\n
\r\n"); WriteLiteral(" "); - #line 81 "..\..\Views\Job\LogWarranty.cshtml" + #line 85 "..\..\Views\Job\LogWarranty.cshtml" Write(Html.EditorFor(model => model.FaultDescription)); @@ -307,7 +383,7 @@ WriteLiteral("
\r\n"); WriteLiteral(" "); - #line 82 "..\..\Views\Job\LogWarranty.cshtml" + #line 86 "..\..\Views\Job\LogWarranty.cshtml" Write(Html.ValidationMessageFor(m => m.FaultDescription)); @@ -316,7 +392,7 @@ WriteLiteral(" "); WriteLiteral("\r\n
\r\n \r\n"); - #line 87 "..\..\Views\Job\LogWarranty.cshtml" + #line 91 "..\..\Views\Job\LogWarranty.cshtml" if (Model.WarrantyProvider != null && Model.WarrantyProviderSubmitJobViewType != null) { @@ -332,7 +408,7 @@ WriteLiteral(">\r\n"); WriteLiteral(" "); - #line 90 "..\..\Views\Job\LogWarranty.cshtml" + #line 94 "..\..\Views\Job\LogWarranty.cshtml" Write(Html.PartialCompiled(Model.WarrantyProviderSubmitJobViewType, Model.WarrantyProviderSubmitJobModel)); @@ -341,7 +417,7 @@ WriteLiteral(" "); WriteLiteral("\r\n \r\n"); - #line 92 "..\..\Views\Job\LogWarranty.cshtml" + #line 96 "..\..\Views\Job\LogWarranty.cshtml" } @@ -362,7 +438,7 @@ WriteLiteral(" value=\"Preview Warranty Claim\""); WriteLiteral(" />\r\n \r\n"); - #line 96 "..\..\Views\Job\LogWarranty.cshtml" + #line 100 "..\..\Views\Job\LogWarranty.cshtml" } @@ -381,33 +457,6 @@ WriteLiteral(@"> var $ProviderId = $('#WarrantyProviderId'); - var updateOrganisationAddressDetails = function () { - $organisationAddressDetails.slideUp(); - var orgAddressId = $OrganisationAddressId.val(); - if (orgAddressId) { - $organisationAddressDetailsLoading.slideDown(); - $.getJSON('"); - - - #line 111 "..\..\Views\Job\LogWarranty.cshtml" - Write(Url.Action(MVC.API.Job.OrganisationAddress())); - - - #line default - #line hidden -WriteLiteral(@"', { id: orgAddressId }, function (data) { - $organisationAddressDetails.empty().append( - $('').text(data.Address), - '
', - $('').text(data.Suburb + ', ' + data.Postcode), - '
', - $('').text(data.State + ', ' + data.Country) - ); - $organisationAddressDetailsLoading.slideUp(); - $organisationAddressDetails.slideDown(); - }); - } - } var updateProviderDetails = function () { var providerId = $ProviderId.val(); var orgAddressId = $OrganisationAddressId.val(); @@ -416,21 +465,16 @@ WriteLiteral(@"', { id: orgAddressId }, function (data) { window.location.href = '"); - #line 129 "..\..\Views\Job\LogWarranty.cshtml" + #line 115 "..\..\Views\Job\LogWarranty.cshtml" Write(Url.Action(MVC.Job.LogWarranty(Model.JobId, null, null))); #line default #line hidden -WriteLiteral(@"?WarrantyProviderId=' + providerId + '&OrganisationAddressId=' + orgAddressId; - } - } - $OrganisationAddressId.change(updateOrganisationAddressDetails).change(updateProviderDetails); - $ProviderId.change(updateProviderDetails); - updateOrganisationAddressDetails(); - }); - -"); +WriteLiteral("?WarrantyProviderId=\' + providerId + \'&OrganisationAddressId=\' + orgAddressId;\r\n " + +" }\r\n }\r\n $OrganisationAddressId.change(updateProviderDet" + +"ails);\r\n $ProviderId.change(updateProviderDetails);\r\n });\r\n\r\n" + +""); } }