Update: Support Ajax and Form Post for All HNWAR

This commit is contained in:
Gary Sharp
2013-04-02 14:03:23 +11:00
parent 8657d4ec32
commit e7ff62afc7
19 changed files with 879 additions and 879 deletions
@@ -40,7 +40,15 @@ namespace Disco.Web.Views.Job.JobParts
}
public override void Execute()
{
WriteLiteral("<table");
#line 2 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
Html.BundleDeferred("~/ClientScripts/Modules/Disco-PropertyChangeHelpers");
#line default
#line hidden
WriteLiteral("\r\n<table");
WriteLiteral(" id=\"jobNonWarrantyFinance\"");
@@ -53,7 +61,7 @@ WriteLiteral(">Accounting Charge Required\r\n </th>\r\n <td>\r\n")
WriteLiteral(" ");
#line 7 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
#line 10 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
Write(CommonHelpers.FriendlyDate(Model.Job.JobMetaNonWarranty.AccountingChargeRequiredDate, "Not Required", "Job_JobMetaNonWarranty_AccountingChargeRequiredDate"));
@@ -66,7 +74,7 @@ WriteLiteral(" id=\"Job_JobMetaNonWarranty_AccountingChargeRequiredUser\"");
WriteLiteral(">");
#line 8 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
#line 11 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
Write(string.IsNullOrEmpty(Model.Job.JobMetaNonWarranty.AccountingChargeRequiredUserId) ? string.Empty : string.Format("by {0}", Model.Job.JobMetaNonWarranty.AccountingChargeRequiredUser.ToString()));
@@ -77,7 +85,7 @@ WriteLiteral("</span>\r\n");
WriteLiteral(" ");
#line 9 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
#line 12 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
Write(AjaxHelpers.AjaxLoader());
@@ -92,7 +100,7 @@ WriteLiteral(">Accounting Charge Added\r\n </th>\r\n <td>\r\n");
WriteLiteral(" ");
#line 16 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
#line 19 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
Write(CommonHelpers.FriendlyDate(Model.Job.JobMetaNonWarranty.AccountingChargeAddedDate, "Not Added", "Job_JobMetaNonWarranty_AccountingChargeAddedDate"));
@@ -105,7 +113,7 @@ WriteLiteral(" id=\"Job_JobMetaNonWarranty_AccountingChargeAddedUser\"");
WriteLiteral(">");
#line 17 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
#line 20 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
Write(string.IsNullOrEmpty(Model.Job.JobMetaNonWarranty.AccountingChargeAddedUserId) ? string.Empty : string.Format("by {0}", Model.Job.JobMetaNonWarranty.AccountingChargeAddedUser.ToString()));
@@ -116,7 +124,7 @@ WriteLiteral("</span>\r\n");
WriteLiteral(" ");
#line 18 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
#line 21 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
Write(AjaxHelpers.AjaxLoader());
@@ -131,7 +139,7 @@ WriteLiteral(">Accounting Charge Paid\r\n </th>\r\n <td>\r\n");
WriteLiteral(" ");
#line 25 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
#line 28 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
Write(CommonHelpers.FriendlyDate(Model.Job.JobMetaNonWarranty.AccountingChargePaidDate, "Not Paid", "Job_JobMetaNonWarranty_AccountingChargePaidDate"));
@@ -144,7 +152,7 @@ WriteLiteral(" id=\"Job_JobMetaNonWarranty_AccountingChargePaidUser\"");
WriteLiteral(">");
#line 26 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
#line 29 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
Write(string.IsNullOrEmpty(Model.Job.JobMetaNonWarranty.AccountingChargePaidUserId) ? string.Empty : string.Format("by {0}", Model.Job.JobMetaNonWarranty.AccountingChargePaidUser.ToString()));
@@ -155,7 +163,7 @@ WriteLiteral("</span>\r\n");
WriteLiteral(" ");
#line 27 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
#line 30 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
Write(AjaxHelpers.AjaxLoader());
@@ -170,7 +178,7 @@ WriteLiteral(">Purchase Order Raised\r\n </th>\r\n <td>\r\n");
WriteLiteral(" ");
#line 34 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
#line 37 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
Write(CommonHelpers.FriendlyDate(Model.Job.JobMetaNonWarranty.PurchaseOrderRaisedDate, "Not Raised", "Job_JobMetaNonWarranty_PurchaseOrderRaisedDate"));
@@ -183,7 +191,7 @@ WriteLiteral(" id=\"Job_JobMetaNonWarranty_PurchaseOrderRaisedUser\"");
WriteLiteral(">");
#line 35 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
#line 38 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
Write(string.IsNullOrEmpty(Model.Job.JobMetaNonWarranty.PurchaseOrderRaisedUserId) ? string.Empty : string.Format("by {0}", Model.Job.JobMetaNonWarranty.PurchaseOrderRaisedUser.ToString()));
@@ -194,7 +202,7 @@ WriteLiteral("</span>\r\n");
WriteLiteral(" ");
#line 36 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
#line 39 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
Write(AjaxHelpers.AjaxLoader());
@@ -206,7 +214,7 @@ WriteLiteral("\r\n </td>\r\n </tr>\r\n <tr>\r\n <th>Purchase
WriteLiteral(" ");
#line 43 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
#line 46 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
Write(Html.TextBoxFor(m => m.Job.JobMetaNonWarranty.PurchaseOrderReference));
@@ -217,7 +225,7 @@ WriteLiteral("\r\n");
WriteLiteral(" ");
#line 44 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
#line 47 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
Write(AjaxHelpers.AjaxSave());
@@ -228,7 +236,7 @@ WriteLiteral("\r\n");
WriteLiteral(" ");
#line 45 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
#line 48 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
Write(AjaxHelpers.AjaxLoader());
@@ -261,7 +269,7 @@ WriteLiteral(@">
url: '");
#line 66 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
#line 69 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
Write(Url.Action(MVC.API.Job.UpdateNonWarrantyPurchaseOrderReference(Model.Job.Id, null)));
@@ -298,7 +306,7 @@ WriteLiteral(">Purchase Order Sent\r\n </th>\r\n <td>\r\n");
WriteLiteral(" ");
#line 91 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
#line 94 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
Write(CommonHelpers.FriendlyDate(Model.Job.JobMetaNonWarranty.PurchaseOrderSentDate, "Not Sent", "Job_JobMetaNonWarranty_PurchaseOrderSentDate"));
@@ -311,7 +319,7 @@ WriteLiteral(" id=\"Job_JobMetaNonWarranty_PurchaseOrderSentUser\"");
WriteLiteral(">");
#line 92 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
#line 95 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
Write(string.IsNullOrEmpty(Model.Job.JobMetaNonWarranty.PurchaseOrderSentUserId) ? string.Empty : string.Format("by {0}", Model.Job.JobMetaNonWarranty.PurchaseOrderSentUser.ToString()));
@@ -322,7 +330,7 @@ WriteLiteral("</span>\r\n");
WriteLiteral(" ");
#line 93 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
#line 96 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
Write(AjaxHelpers.AjaxLoader());
@@ -337,7 +345,7 @@ WriteLiteral(">Invoice Received\r\n </th>\r\n <td>\r\n");
WriteLiteral(" ");
#line 100 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
#line 103 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
Write(CommonHelpers.FriendlyDate(Model.Job.JobMetaNonWarranty.InvoiceReceivedDate, "Not Received", "Job_JobMetaNonWarranty_InvoiceReceivedDate"));
@@ -350,7 +358,7 @@ WriteLiteral(" id=\"Job_JobMetaNonWarranty_InvoiceReceivedUser\"");
WriteLiteral(">");
#line 101 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
#line 104 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
Write(string.IsNullOrEmpty(Model.Job.JobMetaNonWarranty.InvoiceReceivedUserId) ? string.Empty : string.Format("by {0}", Model.Job.JobMetaNonWarranty.InvoiceReceivedUser.ToString()));
@@ -361,125 +369,52 @@ WriteLiteral("</span>\r\n");
WriteLiteral(" ");
#line 102 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
#line 105 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
Write(AjaxHelpers.AjaxLoader());
#line default
#line hidden
WriteLiteral("\r\n </td>\r\n </tr>\r\n</table>\r\n<script>\r\n (function(){\r\n var bas" +
"eUpdateUrl = \'");
WriteLiteral("\r\n </td>\r\n </tr>\r\n</table>\r\n<script>\r\n $(function(){\r\n var up" +
"dateUrl = \'");
#line 108 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
Write(Url.Action(MVC.API.Job.Update(Model.Job.Id, null)));
#line 111 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
Write(Url.Action(MVC.API.Job.Update(Model.Job.Id, null)));
#line default
#line hidden
WriteLiteral("\';\r\n\r\n var dialog, dialogForm, dialogHeader, dialogDateBox, dialogDateProp" +
"ertyNameBox;\r\n var friendlyName, dateField, userField, updatePropertyName" +
", notSetDisplay, minDate, useAjax;\r\n\r\n function dateDialogGet(){\r\n " +
" if (!dialog){\r\n dialog = $(\'<div>\').attr({\'class\': \'dialog\'}" +
")\r\n dialogForm = $(\'<form>\').attr({\'action\': baseUpdateUrl, \'meth" +
"od\': \'post\'}).appendTo(dialog);\r\n var dialogBody = $(\'<p>\').appen" +
"dTo(dialogForm);\r\n dialogHeader = $(\'<h3>\').attr(\'autofocus\', \'au" +
"tofocus\').appendTo(dialogBody);\r\n dialogDatePropertyNameBox = $(\'" +
"<input>\').attr({\'type\': \'hidden\', \'name\': \'key\'}).appendTo(dialogBody);\r\n " +
" dialogDateBox = $(\'<input>\').attr({\'type\': \'datetime\', \'name\': \'value\'}" +
").css({\'display\': \'block\', \'margin-top\': 15, \'margin-left\': \'auto\', \'margin-righ" +
"t\': \'auto\' }).appendTo(dialogBody);\r\n $(\'<input>\').attr({\'type\': " +
"\'hidden\', \'name\': \'redirect\'}).val(\'true\').appendTo(dialogBody);\r\n\r\n " +
" dialog.dialog({\r\n resizable: false,\r\n " +
"modal: true,\r\n autoOpen: false,\r\n buttons:" +
" {\r\n \"Update\": dateDialogUpdate,\r\n " +
" Cancel: function () {\r\n $(this).dialog(\"close\");\r\n " +
" }\r\n },\r\n open: funct" +
"ion(){\r\n dialog.dialog(\'widget\').find(\'.ui-dialog-buttonp" +
"ane :tabbable:first\').focus();\r\n }\r\n });\r\n " +
" dialogDateBox.datetimepicker({\r\n defaultDate: new" +
" Date(),\r\n ampm: true,\r\n changeYear: true," +
"\r\n changeMonth: true,\r\n dateFormat: \'yy/mm" +
"/dd\',\r\n });\r\n }\r\n return dialog;\r\n }" +
"\r\n\r\n function dateDialogUpdate(){\r\n var dateValue = dialogDate" +
"Box.val();\r\n\r\n if (useAjax){\r\n // Use Ajax\r\n " +
" var $dateField, $userField;\r\n $dateField = $(\'#\' + dateFiel" +
"d);\r\n if (userField)\r\n $userField = $(\'#\' + us" +
"erField);\r\n\r\n dialog.dialog(\"close\");\r\n\r\n var $aja" +
"xLoading = ($userField ? $userField.next(\'.ajaxLoading\') : $dateField.next(\'.aja" +
"xLoading\')).show();\r\n\r\n var data = {\r\n key: up" +
"datePropertyName,\r\n value: dateValue\r\n };\r\n " +
" $.getJSON(baseUpdateUrl, data, function (response, result) {\r\n " +
" if (result != \'success\' || response.Result != \'OK\') {\r\n " +
" alert(\'Unable to change \' + friendlyName + \' Date:\\n\' + response);" +
"\r\n $ajaxLoading.hide();\r\n } else {\r\n " +
" if (response.DateTimeFull){\r\n $" +
"dateField.attr(\'data-datetimeformatted\', response.DateTimeJavascript)\r\n " +
" .attr(\'data-discodatetime\', response.DateTimeSortable)\r\n " +
" .attr(\'title\', response.DateTimeFull)\r\n " +
" .text(response.DateTimeFriendly);\r\n " +
" }else{\r\n $dateField.attr(\'data-datetimeformatted\', \'" +
"\')\r\n .attr(\'data-discodatetime\', \'-1\')\r\n " +
" .attr(\'title\', notSetDisplay)\r\n " +
" .text(notSetDisplay);\r\n }\r\n " +
"if ($userField)\r\n $userField.text(\'by \' + response.Us" +
"erDescription);\r\n $ajaxLoading.hide().next(\'.ajaxOk\').sho" +
"w().delay(\'fast\').fadeOut(\'slow\');\r\n }\r\n })\r\n " +
" }else{\r\n // Post Form & Redirect\r\n dial" +
"og.dialog(\"disable\");\r\n dialog.dialog(\"option\", \"buttons\", null);" +
"\r\n\r\n dialogDatePropertyNameBox.val(updatePropertyName);\r\n\r\n " +
" dialogForm.submit();\r\n }\r\n }\r\n\r\n function dat" +
"eDialogOpen(FriendlyName, DateField, UserField, UpdatePropertyName, NotSetDispla" +
"y, MinDate, UseAjax){\r\n friendlyName = FriendlyName;\r\n dat" +
"eField = DateField;\r\n userField = UserField;\r\n updatePrope" +
"rtyName = UpdatePropertyName;\r\n notSetDisplay = NotSetDisplay;\r\n " +
" minDate = MinDate;\r\n useAjax = UseAjax;\r\n\r\n var d =" +
" dateDialogGet();\r\n\r\n d.dialog(\'option\', \'title\', friendlyName);\r\n " +
" dialogHeader.text(friendlyName + \' Date\');\r\n\r\n var dfVal = $" +
"(\'#\' + DateField).attr(\'data-datetimeformatted\');\r\n\r\n if (dfVal)\r\n " +
" dialogDateBox.datetimepicker(\'setDate\', new Date(dfVal));\r\n " +
" else\r\n dialogDateBox.datetimepicker(\'setDate\', new Date());\r\n" +
"\r\n if (MinDate)\r\n dialogDateBox.datetimepicker(\'option" +
"\', \'minDate\', MinDate);\r\n else\r\n dialogDateBox.datetim" +
"epicker(\'option\', \'minDate\', null);\r\n\r\n d.dialog(\'open\');\r\n }\r" +
"\n\r\n function dateDialogCreateUpdater(FriendlyName, DateField, UserField, " +
"UpdatePropertyName, NotSetDisplay, MinDate, UseAjax){\r\n $(\'<a>\').attr" +
"({href: \'#\', \'class\': \'button small\', style: \'margin-right: 5px;\'}).text(\'Update" +
"\').click(function(event){\r\n event.preventDefault();\r\n " +
" dateDialogOpen(FriendlyName, DateField, UserField, UpdatePropertyName, NotSe" +
"tDisplay, MinDate, UseAjax);\r\n }).insertBefore(\'#\' + DateField);\r\n " +
" }\r\n\r\n if (!document.DiscoFunctions)\r\n document.DiscoFunct" +
"ions = {};\r\n if (!document.DiscoFunctions.DateDialogCreateUpdater)\r\n " +
" document.DiscoFunctions.DateDialogCreateUpdater = dateDialogCreateUpdater" +
";\r\n })();\r\n $(function(){\r\n var jobOpenDate = \'");
WriteLiteral("\';\r\n var jobOpenDate = \'");
#line 240 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
#line 112 "..\..\Views\Job\JobParts\NonWarrantyFinance.cshtml"
Write(Model.Job.OpenedDate.ToJavascriptDateTime());
#line default
#line hidden
WriteLiteral("\';\r\n\r\n document.DiscoFunctions.DateDialogCreateUpdater(\'Accounting Charge " +
"Required\', \'Job_JobMetaNonWarranty_AccountingChargeRequiredDate\', \'Job_JobMetaNo" +
"nWarranty_AccountingChargeRequiredUser\', \'NonWarrantyAccountingChargeRequired\', " +
"\'Not Required\', jobOpenDate, false);\r\n document.DiscoFunctions.DateDialog" +
"CreateUpdater(\'Accounting Charge Added\', \'Job_JobMetaNonWarranty_AccountingCharg" +
"eAddedDate\', \'Job_JobMetaNonWarranty_AccountingChargeAddedUser\', \'NonWarrantyAcc" +
"ountingChargeAdded\', \'Not Added\', jobOpenDate, false);\r\n document.DiscoFu" +
"nctions.DateDialogCreateUpdater(\'Accounting Charge Paid\', \'Job_JobMetaNonWarrant" +
"y_AccountingChargePaidDate\', \'Job_JobMetaNonWarranty_AccountingChargePaidUser\', " +
"\'NonWarrantyAccountingChargePaid\', \'Not Paid\', jobOpenDate, false);\r\n doc" +
"ument.DiscoFunctions.DateDialogCreateUpdater(\'Purchase Order Raised\', \'Job_JobMe" +
"taNonWarranty_PurchaseOrderRaisedDate\', \'Job_JobMetaNonWarranty_PurchaseOrderRai" +
"sedUser\', \'NonWarrantyPurchaseOrderRaised\', \'Not Raised\', jobOpenDate, true);\r\n " +
" document.DiscoFunctions.DateDialogCreateUpdater(\'Purchase Order Sent\', \'J" +
"ob_JobMetaNonWarranty_PurchaseOrderSentDate\', \'Job_JobMetaNonWarranty_PurchaseOr" +
"derSentUser\', \'NonWarrantyPurchaseOrderSent\', \'Not Sent\', jobOpenDate, true);\r\n " +
" document.DiscoFunctions.DateDialogCreateUpdater(\'Invoice Received\', \'Job_" +
"JobMetaNonWarranty_InvoiceReceivedDate\', \'Job_JobMetaNonWarranty_InvoiceReceived" +
"User\', \'NonWarrantyInvoiceReceived\', \'Not Received\', jobOpenDate, true);\r\n })" +
";\r\n</script>\r\n");
WriteLiteral("\';\r\n\r\n document.DiscoFunctions.DateDialogCreateUpdater(updateUrl, \'Account" +
"ing Charge Required\', \'Job_JobMetaNonWarranty_AccountingChargeRequiredDate\', \'Jo" +
"b_JobMetaNonWarranty_AccountingChargeRequiredUser\', \'NonWarrantyAccountingCharge" +
"Required\', \'Not Required\', jobOpenDate, false);\r\n document.DiscoFunctions" +
".DateDialogCreateUpdater(updateUrl, \'Accounting Charge Added\', \'Job_JobMetaNonWa" +
"rranty_AccountingChargeAddedDate\', \'Job_JobMetaNonWarranty_AccountingChargeAdded" +
"User\', \'NonWarrantyAccountingChargeAdded\', \'Not Added\', jobOpenDate, false);\r\n " +
" document.DiscoFunctions.DateDialogCreateUpdater(updateUrl, \'Accounting Cha" +
"rge Paid\', \'Job_JobMetaNonWarranty_AccountingChargePaidDate\', \'Job_JobMetaNonWar" +
"ranty_AccountingChargePaidUser\', \'NonWarrantyAccountingChargePaid\', \'Not Paid\', " +
"jobOpenDate, false);\r\n document.DiscoFunctions.DateDialogCreateUpdater(up" +
"dateUrl, \'Purchase Order Raised\', \'Job_JobMetaNonWarranty_PurchaseOrderRaisedDat" +
"e\', \'Job_JobMetaNonWarranty_PurchaseOrderRaisedUser\', \'NonWarrantyPurchaseOrderR" +
"aised\', \'Not Raised\', jobOpenDate, true);\r\n document.DiscoFunctions.DateD" +
"ialogCreateUpdater(updateUrl, \'Purchase Order Sent\', \'Job_JobMetaNonWarranty_Pur" +
"chaseOrderSentDate\', \'Job_JobMetaNonWarranty_PurchaseOrderSentUser\', \'NonWarrant" +
"yPurchaseOrderSent\', \'Not Sent\', jobOpenDate, true);\r\n document.DiscoFunc" +
"tions.DateDialogCreateUpdater(updateUrl, \'Invoice Received\', \'Job_JobMetaNonWarr" +
"anty_InvoiceReceivedDate\', \'Job_JobMetaNonWarranty_InvoiceReceivedUser\', \'NonWar" +
"rantyInvoiceReceived\', \'Not Received\', jobOpenDate, true);\r\n });\r\n</script>\r\n" +
"");
}
}