Bug Fix: Upload attachments required refresh

This commit is contained in:
Gary Sharp
2013-11-12 12:21:35 +11:00
parent 9ac487e7e0
commit b1048588e7
6 changed files with 306 additions and 245 deletions
+47 -40
View File
@@ -30,7 +30,7 @@
{
<div data-logid="@jl.Id">
<span class="author">@jl.TechUser.ToString()</span>@if (canRemoveAnyLogs || (canRemoveOwnLogs && jl.TechUserId == CurrentUser.Id))
{<text><span class="remove"></span></text>}<span class="timestamp" title="@jl.Timestamp.ToFullDateTime()">@jl.Timestamp.ToFuzzy()</span>
{<text><span class="remove"></span></text>}<span class="timestamp" title="@jl.Timestamp.ToFullDateTime()">@jl.Timestamp.ToFuzzy()</span>
<span class="comment">@jl.Comments.ToMultilineJobRefString()</span>
</div>
}
@@ -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
</text>}
@@ -438,12 +440,17 @@
if (d.Result == 'OK') {
var a = d.Attachment;
@if (canRemoveAnyAttachments)
{<text>buildAttachment(a, true);</text>}
{
<text>buildAttachment(a, true, quick);</text>
}
else if (canRemoveOwnAttachments)
{<text>buildAttachment(a, (a.AuthorId === '@(CurrentUser.Id)'));</text>}
{
<text>buildAttachment(a, (a.AuthorId === '@(CurrentUser.Id)'), quick);</text>
}
else
{<text>buildAttachment(a, false);</text>}
{
<text>buildAttachment(a, false, quick);</text>
}
} 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 = '<a><span class="icon"><img alt="Attachment Thumbnail" /></span><span class="comments"></span><span class="author"></span>';
if (canRemove)
@@ -2,7 +2,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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("</span>");
#line 32 "..\..\Views\Job\JobParts\Resources.cshtml"
if (canRemoveAnyLogs || (canRemoveOwnLogs && jl.TechUserId == CurrentUser.Id))
{
{
#line default
#line hidden
@@ -184,7 +184,7 @@ WriteLiteral("></span>");
#line 33 "..\..\Views\Job\JobParts\Resources.cshtml"
}
}
#line default
#line hidden
@@ -192,21 +192,21 @@ WriteLiteral("<span");
WriteLiteral(" class=\"timestamp\"");
WriteAttribute("title", Tuple.Create(" title=\"", 1819), Tuple.Create("\"", 1857)
WriteAttribute("title", Tuple.Create(" title=\"", 1812), Tuple.Create("\"", 1850)
#line 33 "..\..\Views\Job\JobParts\Resources.cshtml"
, Tuple.Create(Tuple.Create("", 1827), Tuple.Create<System.Object, System.Int32>(jl.Timestamp.ToFullDateTime()
, Tuple.Create(Tuple.Create("", 1820), Tuple.Create<System.Object, System.Int32>(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(" <td");
WriteLiteral(" id=\"Attachments\"");
WriteAttribute("class", Tuple.Create(" class=\"", 2489), Tuple.Create("\"", 2564)
WriteAttribute("class", Tuple.Create(" class=\"", 2482), Tuple.Create("\"", 2557)
#line 49 "..\..\Views\Job\JobParts\Resources.cshtml"
, Tuple.Create(Tuple.Create("", 2497), Tuple.Create<System.Object, System.Int32>(canAddAttachments ? "canAddAttachments" : "cannotAddAttachments"
, Tuple.Create(Tuple.Create("", 2490), Tuple.Create<System.Object, System.Int32>(canAddAttachments ? "canAddAttachments" : "cannotAddAttachments"
#line default
#line hidden
, 2497), false)
, 2490), false)
);
WriteLiteral(">\r\n <div");
@@ -327,14 +327,14 @@ WriteLiteral(">\r\n");
#line hidden
WriteLiteral(" <a");
WriteAttribute("href", Tuple.Create(" href=\"", 2732), Tuple.Create("\"", 2789)
WriteAttribute("href", Tuple.Create(" href=\"", 2725), Tuple.Create("\"", 2782)
#line 53 "..\..\Views\Job\JobParts\Resources.cshtml"
, Tuple.Create(Tuple.Create("", 2739), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.API.Job.AttachmentDownload(ja.Id))
, Tuple.Create(Tuple.Create("", 2732), Tuple.Create<System.Object, System.Int32>(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 <span");
WriteLiteral(" class=\"icon\"");
WriteAttribute("title", Tuple.Create(" title=\"", 2895), Tuple.Create("\"", 2915)
WriteAttribute("title", Tuple.Create(" title=\"", 2888), Tuple.Create("\"", 2908)
#line 54 "..\..\Views\Job\JobParts\Resources.cshtml"
, Tuple.Create(Tuple.Create("", 2903), Tuple.Create<System.Object, System.Int32>(ja.Filename
, Tuple.Create(Tuple.Create("", 2896), Tuple.Create<System.Object, System.Int32>(ja.Filename
#line default
#line hidden
, 2903), false)
, 2896), false)
);
WriteLiteral(">\r\n <img");
WriteLiteral(" alt=\"Attachment Thumbnail\"");
WriteAttribute("src", Tuple.Create(" src=\"", 2982), Tuple.Create("\"", 3041)
WriteAttribute("src", Tuple.Create(" src=\"", 2975), Tuple.Create("\"", 3034)
#line 55 "..\..\Views\Job\JobParts\Resources.cshtml"
, Tuple.Create(Tuple.Create("", 2988), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.API.Job.AttachmentThumbnail(ja.Id))
, Tuple.Create(Tuple.Create("", 2981), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.API.Job.AttachmentThumbnail(ja.Id))
#line default
#line hidden
, 2988), false)
, 2981), false)
);
WriteLiteral(" /></span>\r\n <span");
WriteLiteral(" class=\"comments\"");
WriteAttribute("title", Tuple.Create(" title=\"", 3104), Tuple.Create("\"", 3124)
WriteAttribute("title", Tuple.Create(" title=\"", 3097), Tuple.Create("\"", 3117)
#line 56 "..\..\Views\Job\JobParts\Resources.cshtml"
, Tuple.Create(Tuple.Create("", 3112), Tuple.Create<System.Object, System.Int32>(ja.Comments
, Tuple.Create(Tuple.Create("", 3105), Tuple.Create<System.Object, System.Int32>(ja.Comments
#line default
#line hidden
, 3112), false)
, 3105), false)
);
WriteLiteral(">\r\n");
@@ -482,14 +482,14 @@ WriteLiteral("<span");
WriteLiteral(" class=\"timestamp\"");
WriteAttribute("title", Tuple.Create(" title=\"", 3710), Tuple.Create("\"", 3748)
WriteAttribute("title", Tuple.Create(" title=\"", 3703), Tuple.Create("\"", 3741)
#line 62 "..\..\Views\Job\JobParts\Resources.cshtml"
, Tuple.Create(Tuple.Create("", 3718), Tuple.Create<System.Object, System.Int32>(ja.Timestamp.ToFullDateTime()
, Tuple.Create(Tuple.Create("", 3711), Tuple.Create<System.Object, System.Int32>(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 = '<a><span class=""icon""><img alt=""Attachment Thumbnail"" /></span><span class=""comments""></span><span class=""author""></span>';
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
" </script>\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(" <script>\r\n $(function () {\r\n var jobId = parseInt(\'");
#line 518 "..\..\Views\Job\JobParts\Resources.cshtml"
#line 525 "..\..\Views\Job\JobParts\Resources.cshtml"
Write(Model.Job.Id);
@@ -1354,7 +1370,7 @@ WriteLiteral("\');\r\n\r\n //#region LiveEvents\r\n functi
" var liveMessagesConnection = $.connection(\'");
#line 551 "..\..\Views\Job\JobParts\Resources.cshtml"
#line 558 "..\..\Views\Job\JobParts\Resources.cshtml"
Write(Url.Content("~/API/Repository/Notifications"));
@@ -1373,7 +1389,7 @@ WriteLiteral(@"', { addToGroups: 'JobLog,JobAttachment' })
");
#line 561 "..\..\Views\Job\JobParts\Resources.cshtml"
#line 568 "..\..\Views\Job\JobParts\Resources.cshtml"
}
else if (canShowLogs)
{
@@ -1384,7 +1400,7 @@ else if (canShowLogs)
WriteLiteral(" <script>\r\n $(function () {\r\n var jobId = parseInt(\'");
#line 566 "..\..\Views\Job\JobParts\Resources.cshtml"
#line 573 "..\..\Views\Job\JobParts\Resources.cshtml"
Write(Model.Job.Id);
@@ -1412,7 +1428,7 @@ WriteLiteral(@"');
var liveMessagesConnection = $.connection('");
#line 585 "..\..\Views\Job\JobParts\Resources.cshtml"
#line 592 "..\..\Views\Job\JobParts\Resources.cshtml"
Write(Url.Content("~/API/Repository/Notifications"));
@@ -1431,7 +1447,7 @@ WriteLiteral(@"', { addToGroups: 'JobLog' })
");
#line 595 "..\..\Views\Job\JobParts\Resources.cshtml"
#line 602 "..\..\Views\Job\JobParts\Resources.cshtml"
}
else if (canShowAttachments)
{
@@ -1442,7 +1458,7 @@ else if (canShowAttachments)
WriteLiteral(" <script>\r\n $(function () {\r\n var jobId = parseInt(\'");
#line 600 "..\..\Views\Job\JobParts\Resources.cshtml"
#line 607 "..\..\Views\Job\JobParts\Resources.cshtml"
Write(Model.Job.Id);
@@ -1468,7 +1484,7 @@ WriteLiteral(@"');
var liveMessagesConnection = $.connection('");
#line 617 "..\..\Views\Job\JobParts\Resources.cshtml"
#line 624 "..\..\Views\Job\JobParts\Resources.cshtml"
Write(Url.Content("~/API/Repository/Notifications"));
@@ -1487,7 +1503,7 @@ WriteLiteral(@"', { addToGroups: 'JobAttachment' })
");
#line 627 "..\..\Views\Job\JobParts\Resources.cshtml"
#line 634 "..\..\Views\Job\JobParts\Resources.cshtml"
}
#line default