From b1048588e7ed6e2b22235fc54bdbc249cf58b7ee Mon Sep 17 00:00:00 2001 From: Gary Sharp Date: Tue, 12 Nov 2013 12:21:35 +1100 Subject: [PATCH] Bug Fix: Upload attachments required refresh --- .../Device/DeviceParts/_Resources.cshtml | 15 +- .../DeviceParts/_Resources.generated.cs | 74 +++-- Disco.Web/Views/Job/JobParts/Resources.cshtml | 87 +++--- .../Views/Job/JobParts/Resources.generated.cs | 276 +++++++++--------- .../Views/User/UserParts/_Resources.cshtml | 15 +- .../User/UserParts/_Resources.generated.cs | 84 +++--- 6 files changed, 306 insertions(+), 245 deletions(-) diff --git a/Disco.Web/Views/Device/DeviceParts/_Resources.cshtml b/Disco.Web/Views/Device/DeviceParts/_Resources.cshtml index c7378e75..c540a7c2 100644 --- a/Disco.Web/Views/Device/DeviceParts/_Resources.cshtml +++ b/Disco.Web/Views/Device/DeviceParts/_Resources.cshtml @@ -120,12 +120,17 @@ if (d.Result == 'OK') { var a = d.Attachment; @if (canRemoveAnyAttachments) - {buildAttachment(a, true);} + { + buildAttachment(a, true, quick); + } else if (canRemoveOwnAttachments) - {buildAttachment(a, (a.AuthorId === '@(CurrentUser.Id)'));} + { + buildAttachment(a, (a.AuthorId === '@(CurrentUser.Id)'), quick); + } else - {buildAttachment(a, false);} - + { + buildAttachment(a, false, quick); + } } else { alert('Unable to add attachment: ' + d.Result); } @@ -136,7 +141,7 @@ }); } - function buildAttachment(a, canRemove) { + function buildAttachment(a, canRemove, quick) { var t = 'Attachment Thumbnail'; if (canRemove) t += ''; diff --git a/Disco.Web/Views/Device/DeviceParts/_Resources.generated.cs b/Disco.Web/Views/Device/DeviceParts/_Resources.generated.cs index a5df6296..b6ba663d 100644 --- a/Disco.Web/Views/Device/DeviceParts/_Resources.generated.cs +++ b/Disco.Web/Views/Device/DeviceParts/_Resources.generated.cs @@ -2,7 +2,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.18051 +// Runtime Version:4.0.30319.34003 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -464,49 +464,63 @@ WriteLiteral(@"', #line 122 "..\..\Views\Device\DeviceParts\_Resources.cshtml" if (canRemoveAnyAttachments) { - - #line default - #line hidden -WriteLiteral("buildAttachment(a, true);"); - #line 123 "..\..\Views\Device\DeviceParts\_Resources.cshtml" - } + #line default + #line hidden +WriteLiteral(" "); + +WriteLiteral("buildAttachment(a, true, quick);"); + +WriteLiteral("\r\n"); + + + #line 125 "..\..\Views\Device\DeviceParts\_Resources.cshtml" + } else if (canRemoveOwnAttachments) { + #line default #line hidden +WriteLiteral(" "); + WriteLiteral("buildAttachment(a, (a.AuthorId === \'"); - #line 125 "..\..\Views\Device\DeviceParts\_Resources.cshtml" - Write(CurrentUser.Id); + #line 128 "..\..\Views\Device\DeviceParts\_Resources.cshtml" + Write(CurrentUser.Id); #line default #line hidden -WriteLiteral("\'));"); +WriteLiteral("\'), quick);"); + +WriteLiteral("\r\n"); - #line 125 "..\..\Views\Device\DeviceParts\_Resources.cshtml" - } + #line 129 "..\..\Views\Device\DeviceParts\_Resources.cshtml" + } else { - - #line default - #line hidden -WriteLiteral("buildAttachment(a, false);"); - - - #line 127 "..\..\Views\Device\DeviceParts\_Resources.cshtml" - } #line default #line hidden -WriteLiteral(@" - } else { +WriteLiteral(" "); + +WriteLiteral("buildAttachment(a, false, quick);"); + +WriteLiteral("\r\n"); + + + #line 133 "..\..\Views\Device\DeviceParts\_Resources.cshtml" + } + + + #line default + #line hidden +WriteLiteral(@" } else { alert('Unable to add attachment: ' + d.Result); } }, @@ -516,7 +530,7 @@ WriteLiteral(@" }); } - function buildAttachment(a, canRemove) { + function buildAttachment(a, canRemove, quick) { var t = '\';\r\n\r\n var e = $(t);\r "tr(\'href\', \'"); - #line 147 "..\..\Views\Device\DeviceParts\_Resources.cshtml" + #line 152 "..\..\Views\Device\DeviceParts\_Resources.cshtml" Write(Url.Action(MVC.API.Device.AttachmentDownload())); @@ -556,7 +570,7 @@ WriteLiteral(">\';\r\n\r\n var e = $(t);\r WriteLiteral("/\' + a.Id);\r\n e.find(\'.icon img\').attr(\'src\', \'"); - #line 148 "..\..\Views\Device\DeviceParts\_Resources.cshtml" + #line 153 "..\..\Views\Device\DeviceParts\_Resources.cshtml" Write(Url.Action(MVC.API.Device.AttachmentThumbnail())); @@ -581,7 +595,7 @@ WriteLiteral(@"/' + a.Id); "); - #line 164 "..\..\Views\Device\DeviceParts\_Resources.cshtml" + #line 169 "..\..\Views\Device\DeviceParts\_Resources.cshtml" } @@ -590,7 +604,7 @@ WriteLiteral(@"/' + a.Id); WriteLiteral(" "); - #line 165 "..\..\Views\Device\DeviceParts\_Resources.cshtml" + #line 170 "..\..\Views\Device\DeviceParts\_Resources.cshtml" if (canRemoveAnyAttachments || canRemoveOwnAttachments) { @@ -621,7 +635,7 @@ WriteLiteral(@" url: '"); - #line 188 "..\..\Views\Device\DeviceParts\_Resources.cshtml" + #line 193 "..\..\Views\Device\DeviceParts\_Resources.cshtml" Write(Url.Action(MVC.API.Device.AttachmentRemove())); @@ -653,7 +667,7 @@ WriteLiteral("\',\r\n dataType: \'json\', "egion\r\n "); - #line 220 "..\..\Views\Device\DeviceParts\_Resources.cshtml" + #line 225 "..\..\Views\Device\DeviceParts\_Resources.cshtml" } @@ -697,7 +711,7 @@ WriteLiteral(">\r\n Are you sure?\r\n

\r\n Attachments ["); - #line 243 "..\..\Views\Device\DeviceParts\_Resources.cshtml" + #line 248 "..\..\Views\Device\DeviceParts\_Resources.cshtml" Write(Model.Device.DeviceAttachments == null ? 0 : Model.Device.DeviceAttachments.Count); diff --git a/Disco.Web/Views/Job/JobParts/Resources.cshtml b/Disco.Web/Views/Job/JobParts/Resources.cshtml index 8dcdad3d..72a8c69f 100644 --- a/Disco.Web/Views/Job/JobParts/Resources.cshtml +++ b/Disco.Web/Views/Job/JobParts/Resources.cshtml @@ -30,7 +30,7 @@ {
@jl.TechUser.ToString()@if (canRemoveAnyLogs || (canRemoveOwnLogs && jl.TechUserId == CurrentUser.Id)) - {}@jl.Timestamp.ToFuzzy() + {}@jl.Timestamp.ToFuzzy() @jl.Comments.ToMultilineJobRefString()
} @@ -313,21 +313,6 @@ var $dialogUpload; var onLoadNavigation = null; var isLoaded = null; - Silverlight.createObject( - '@(Links.ClientBin.Disco_Silverlight_AttachmentUpload_xap)', - $('#silverlightHostUploadAttachment').get(0), - 'silverlightUploadAttachment', - { width: '840px', height: '500px', background: 'white', version: '4.0.60310.0' }, - { - onLoad: function () { - if (onLoadNavigation) { - silverlightUploadAttachment.content.Navigator.Navigate(onLoadNavigation); - isLoaded = true; - } - } - }, - 'UploadUrl=@(Url.Action(MVC.API.Job.AttachmentUpload(Model.Job.Id, null)))' - ); var $attachmentInput = $Attachments.find('.attachmentInput'); $attachmentInput.find('.photo').click(function () { @@ -340,25 +325,42 @@ var silverlightUploadAttachment = $('#silverlightUploadAttachment').get(0); function showDialog(navigationPath) { if (!$dialogUpload) { - $dialogUpload = $('#dialogUpload').dialog({ - autoOpen: false, - draggable: false, - modal: true, - resizable: false, - width: 860, - height: 550, - close: function () { - silverlightUploadAttachment.content.Navigator.Navigate('/Hidden'); - } - }); - } - $dialogUpload.dialog('open'); - if (isLoaded) { - silverlightUploadAttachment.content.Navigator.Navigate(navigationPath); - } else { - onLoadNavigation = navigationPath; - } - }; + Silverlight.createObject( + '@(Links.ClientBin.Disco_Silverlight_AttachmentUpload_xap)', + $('#silverlightHostUploadAttachment').get(0), + 'silverlightUploadAttachment', + { width: '840px', height: '500px', background: 'white', version: '4.0.60310.0' }, + { + onLoad: function () { + if (onLoadNavigation) { + $('#silverlightUploadAttachment').get(0).content.Navigator.Navigate(onLoadNavigation); + isLoaded = true; + } + } + }, + 'UploadUrl=@(Url.Action(MVC.API.Job.AttachmentUpload(Model.Job.Id, null)))' + ); + + $dialogUpload = $('#dialogUpload').dialog({ + autoOpen: false, + draggable: false, + modal: true, + resizable: false, + width: 860, + height: 550, + close: function () { + if (silverlightUploadAttachment && silverlightUploadAttachment.content) + silverlightUploadAttachment.content.Navigator.Navigate('/Hidden'); + } + }); + } + $dialogUpload.dialog('open'); + if (isLoaded) { + silverlightUploadAttachment.content.Navigator.Navigate(navigationPath); + } else { + onLoadNavigation = navigationPath; + } + }; //#endregion } @@ -438,12 +440,17 @@ if (d.Result == 'OK') { var a = d.Attachment; @if (canRemoveAnyAttachments) - {buildAttachment(a, true);} + { + buildAttachment(a, true, quick); + } else if (canRemoveOwnAttachments) - {buildAttachment(a, (a.AuthorId === '@(CurrentUser.Id)'));} + { + buildAttachment(a, (a.AuthorId === '@(CurrentUser.Id)'), quick); + } else - {buildAttachment(a, false);} - + { + buildAttachment(a, false, quick); + } } else { alert('Unable to add attachment: ' + d.Result); } @@ -454,7 +461,7 @@ }); } } - function buildAttachment(a, canRemove) { + function buildAttachment(a, canRemove, quick) { if (parseInt(a.ParentId) == jobId) { var t = 'Attachment Thumbnail'; if (canRemove) diff --git a/Disco.Web/Views/Job/JobParts/Resources.generated.cs b/Disco.Web/Views/Job/JobParts/Resources.generated.cs index 6fd0bbb4..3d0f4300 100644 --- a/Disco.Web/Views/Job/JobParts/Resources.generated.cs +++ b/Disco.Web/Views/Job/JobParts/Resources.generated.cs @@ -2,7 +2,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.18051 +// Runtime Version:4.0.30319.34003 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -172,7 +172,7 @@ WriteLiteral(""); #line 32 "..\..\Views\Job\JobParts\Resources.cshtml" if (canRemoveAnyLogs || (canRemoveOwnLogs && jl.TechUserId == CurrentUser.Id)) - { + { #line default #line hidden @@ -184,7 +184,7 @@ WriteLiteral(">"); #line 33 "..\..\Views\Job\JobParts\Resources.cshtml" - } + } #line default #line hidden @@ -192,21 +192,21 @@ WriteLiteral("(jl.Timestamp.ToFullDateTime() + , Tuple.Create(Tuple.Create("", 1820), Tuple.Create(jl.Timestamp.ToFullDateTime() #line default #line hidden -, 1827), false) +, 1820), false) ); WriteLiteral(">"); #line 33 "..\..\Views\Job\JobParts\Resources.cshtml" - Write(jl.Timestamp.ToFuzzy()); + Write(jl.Timestamp.ToFuzzy()); #line default @@ -295,14 +295,14 @@ WriteLiteral(" (canAddAttachments ? "canAddAttachments" : "cannotAddAttachments" +, Tuple.Create(Tuple.Create("", 2490), Tuple.Create(canAddAttachments ? "canAddAttachments" : "cannotAddAttachments" #line default #line hidden -, 2497), false) +, 2490), false) ); WriteLiteral(">\r\n \r\n"); #line hidden WriteLiteral(" (Url.Action(MVC.API.Job.AttachmentDownload(ja.Id)) +, Tuple.Create(Tuple.Create("", 2732), Tuple.Create(Url.Action(MVC.API.Job.AttachmentDownload(ja.Id)) #line default #line hidden -, 2739), false) +, 2732), false) ); WriteLiteral(" data-attachmentid=\""); @@ -363,42 +363,42 @@ WriteLiteral(">\r\n (ja.Filename +, Tuple.Create(Tuple.Create("", 2896), Tuple.Create(ja.Filename #line default #line hidden -, 2903), false) +, 2896), false) ); WriteLiteral(">\r\n (Url.Action(MVC.API.Job.AttachmentThumbnail(ja.Id)) +, Tuple.Create(Tuple.Create("", 2981), Tuple.Create(Url.Action(MVC.API.Job.AttachmentThumbnail(ja.Id)) #line default #line hidden -, 2988), false) +, 2981), false) ); WriteLiteral(" />\r\n (ja.Comments +, Tuple.Create(Tuple.Create("", 3105), Tuple.Create(ja.Comments #line default #line hidden -, 3112), false) +, 3105), false) ); WriteLiteral(">\r\n"); @@ -482,14 +482,14 @@ WriteLiteral("(ja.Timestamp.ToFullDateTime() + , Tuple.Create(Tuple.Create("", 3711), Tuple.Create(ja.Timestamp.ToFullDateTime() #line default #line hidden -, 3718), false) +, 3711), false) ); WriteLiteral(">"); @@ -1023,39 +1023,6 @@ WriteLiteral(@" var $dialogUpload; var onLoadNavigation = null; var isLoaded = null; - Silverlight.createObject( - '"); - - - #line 317 "..\..\Views\Job\JobParts\Resources.cshtml" - Write(Links.ClientBin.Disco_Silverlight_AttachmentUpload_xap); - - - #line default - #line hidden -WriteLiteral(@"', - $('#silverlightHostUploadAttachment').get(0), - 'silverlightUploadAttachment', - { width: '840px', height: '500px', background: 'white', version: '4.0.60310.0' }, - { - onLoad: function () { - if (onLoadNavigation) { - silverlightUploadAttachment.content.Navigator.Navigate(onLoadNavigation); - isLoaded = true; - } - } - }, - 'UploadUrl="); - - - #line 329 "..\..\Views\Job\JobParts\Resources.cshtml" - Write(Url.Action(MVC.API.Job.AttachmentUpload(Model.Job.Id, null))); - - - #line default - #line hidden -WriteLiteral(@"' - ); var $attachmentInput = $Attachments.find('.attachmentInput'); $attachmentInput.find('.photo').click(function () { @@ -1068,31 +1035,66 @@ WriteLiteral(@"' var silverlightUploadAttachment = $('#silverlightUploadAttachment').get(0); function showDialog(navigationPath) { if (!$dialogUpload) { - $dialogUpload = $('#dialogUpload').dialog({ - autoOpen: false, - draggable: false, - modal: true, - resizable: false, - width: 860, - height: 550, - close: function () { - silverlightUploadAttachment.content.Navigator.Navigate('/Hidden'); - } - }); - } - $dialogUpload.dialog('open'); - if (isLoaded) { - silverlightUploadAttachment.content.Navigator.Navigate(navigationPath); - } else { - onLoadNavigation = navigationPath; - } - }; + Silverlight.createObject( + '"); + + + #line 329 "..\..\Views\Job\JobParts\Resources.cshtml" + Write(Links.ClientBin.Disco_Silverlight_AttachmentUpload_xap); + + + #line default + #line hidden +WriteLiteral(@"', + $('#silverlightHostUploadAttachment').get(0), + 'silverlightUploadAttachment', + { width: '840px', height: '500px', background: 'white', version: '4.0.60310.0' }, + { + onLoad: function () { + if (onLoadNavigation) { + $('#silverlightUploadAttachment').get(0).content.Navigator.Navigate(onLoadNavigation); + isLoaded = true; + } + } + }, + 'UploadUrl="); + + + #line 341 "..\..\Views\Job\JobParts\Resources.cshtml" + Write(Url.Action(MVC.API.Job.AttachmentUpload(Model.Job.Id, null))); + + + #line default + #line hidden +WriteLiteral(@"' + ); + + $dialogUpload = $('#dialogUpload').dialog({ + autoOpen: false, + draggable: false, + modal: true, + resizable: false, + width: 860, + height: 550, + close: function () { + if (silverlightUploadAttachment && silverlightUploadAttachment.content) + silverlightUploadAttachment.content.Navigator.Navigate('/Hidden'); + } + }); + } + $dialogUpload.dialog('open'); + if (isLoaded) { + silverlightUploadAttachment.content.Navigator.Navigate(navigationPath); + } else { + onLoadNavigation = navigationPath; + } + }; //#endregion "); - #line 364 "..\..\Views\Job\JobParts\Resources.cshtml" + #line 366 "..\..\Views\Job\JobParts\Resources.cshtml" } @@ -1101,13 +1103,13 @@ WriteLiteral(@"' WriteLiteral("\r\n"); - #line 366 "..\..\Views\Job\JobParts\Resources.cshtml" + #line 368 "..\..\Views\Job\JobParts\Resources.cshtml" #line default #line hidden - #line 366 "..\..\Views\Job\JobParts\Resources.cshtml" + #line 368 "..\..\Views\Job\JobParts\Resources.cshtml" if (canRemoveAnyAttachments || canRemoveOwnAttachments) { @@ -1142,7 +1144,7 @@ WriteLiteral(@" url: '"); - #line 393 "..\..\Views\Job\JobParts\Resources.cshtml" + #line 395 "..\..\Views\Job\JobParts\Resources.cshtml" Write(Url.Action(MVC.API.Job.AttachmentRemove())); @@ -1170,7 +1172,7 @@ WriteLiteral("\',\r\n dataType: \'json\',\r\n " }\r\n\r\n //#endregion\r\n\r\n "); - #line 426 "..\..\Views\Job\JobParts\Resources.cshtml" + #line 428 "..\..\Views\Job\JobParts\Resources.cshtml" } @@ -1181,7 +1183,7 @@ WriteLiteral("\r\n function addAttachment(key, quick) {\r\n\r\n " $.ajax({\r\n url: \'"); - #line 434 "..\..\Views\Job\JobParts\Resources.cshtml" + #line 436 "..\..\Views\Job\JobParts\Resources.cshtml" Write(Url.Action(MVC.API.Job.Attachment())); @@ -1193,58 +1195,72 @@ WriteLiteral("\',\r\n dataType: \'json\',\r\n ""); - #line 440 "..\..\Views\Job\JobParts\Resources.cshtml" + #line 442 "..\..\Views\Job\JobParts\Resources.cshtml" #line default #line hidden - #line 440 "..\..\Views\Job\JobParts\Resources.cshtml" + #line 442 "..\..\Views\Job\JobParts\Resources.cshtml" if (canRemoveAnyAttachments) { - - #line default - #line hidden -WriteLiteral("buildAttachment(a, true);"); - - - #line 441 "..\..\Views\Job\JobParts\Resources.cshtml" - } - else if (canRemoveOwnAttachments) - { - - #line default - #line hidden -WriteLiteral("buildAttachment(a, (a.AuthorId === \'"); - - - #line 443 "..\..\Views\Job\JobParts\Resources.cshtml" - Write(CurrentUser.Id); #line default #line hidden -WriteLiteral("\'));"); +WriteLiteral(" "); - - #line 443 "..\..\Views\Job\JobParts\Resources.cshtml" - } - else - { - - #line default - #line hidden -WriteLiteral("buildAttachment(a, false);"); +WriteLiteral("buildAttachment(a, true, quick);"); + +WriteLiteral("\r\n"); #line 445 "..\..\Views\Job\JobParts\Resources.cshtml" - } + } + else if (canRemoveOwnAttachments) + { #line default #line hidden -WriteLiteral(@" - } else { +WriteLiteral(" "); + +WriteLiteral("buildAttachment(a, (a.AuthorId === \'"); + + + #line 448 "..\..\Views\Job\JobParts\Resources.cshtml" + Write(CurrentUser.Id); + + + #line default + #line hidden +WriteLiteral("\'), quick);"); + +WriteLiteral("\r\n"); + + + #line 449 "..\..\Views\Job\JobParts\Resources.cshtml" + } + else + { + + + #line default + #line hidden +WriteLiteral(" "); + +WriteLiteral("buildAttachment(a, false, quick);"); + +WriteLiteral("\r\n"); + + + #line 453 "..\..\Views\Job\JobParts\Resources.cshtml" + } + + + #line default + #line hidden +WriteLiteral(@" } else { alert('Unable to add attachment: ' + d.Result); } }, @@ -1254,7 +1270,7 @@ WriteLiteral(@" }); } } - function buildAttachment(a, canRemove) { + function buildAttachment(a, canRemove, quick) { if (parseInt(a.ParentId) == jobId) { var t = ''; if (canRemove) @@ -1266,7 +1282,7 @@ WriteLiteral(@" e.attr('data-attachmentid', a.Id).attr('data-mimetype', a.MimeType).attr('href', '"); - #line 466 "..\..\Views\Job\JobParts\Resources.cshtml" + #line 473 "..\..\Views\Job\JobParts\Resources.cshtml" Write(Url.Action(MVC.API.Job.AttachmentDownload())); @@ -1275,7 +1291,7 @@ WriteLiteral(@" WriteLiteral("/\' + a.Id);\r\n e.find(\'.icon img\').attr(\'src\', \'"); - #line 467 "..\..\Views\Job\JobParts\Resources.cshtml" + #line 474 "..\..\Views\Job\JobParts\Resources.cshtml" Write(Url.Action(MVC.API.Job.AttachmentThumbnail())); @@ -1308,14 +1324,14 @@ WriteLiteral("/\' + a.Id);\r\n e.find(\'.comments\').text(a.C " \r\n"); - #line 513 "..\..\Views\Job\JobParts\Resources.cshtml" + #line 520 "..\..\Views\Job\JobParts\Resources.cshtml" } #line default #line hidden - #line 514 "..\..\Views\Job\JobParts\Resources.cshtml" + #line 521 "..\..\Views\Job\JobParts\Resources.cshtml" if (canShowLogs && canShowAttachments) { @@ -1325,7 +1341,7 @@ WriteLiteral("/\' + a.Id);\r\n e.find(\'.comments\').text(a.C WriteLiteral("