bug fixed: users with Remove Own Attachment permission had to refresh before they could remove

This commit is contained in:
Gary Sharp
2025-07-12 19:51:54 +10:00
parent 092c6249ee
commit 42e9045d5e
4 changed files with 127 additions and 185 deletions
@@ -19,7 +19,7 @@
<table id="deviceShowResources"> <table id="deviceShowResources">
<tr> <tr>
<td id="AttachmentsContainer"> <td id="AttachmentsContainer">
<div id="Attachments" class="@(canAddAttachments ? "canAddAttachments" : "cannotAddAttachments")" data-uploadurl="@(Url.Action(MVC.API.Device.AttachmentUpload(Model.Device.SerialNumber, null)))" data-onlineuploadurl="@(Url.Action(MVC.API.Device.AttachmentOnlineUploadSession(Model.Device.SerialNumber)))" data-qrcodeurl="@Url.Content("~/ClientSource/Scripts/Modules/qrcode.min.js")"> <div id="Attachments" class="@(canAddAttachments ? "canAddAttachments" : "cannotAddAttachments") @(canRemoveAnyAttachments ? "canRemoveAnyAttachments" : "cannotRemoveAnyAttachments") @(canRemoveOwnAttachments ? "canRemoveOwnAttachments" : "cannotRemoveOwnAttachments")" data-userid="@CurrentUser.UserId" data-uploadurl="@(Url.Action(MVC.API.Device.AttachmentUpload(Model.Device.SerialNumber, null)))" data-onlineuploadurl="@(Url.Action(MVC.API.Device.AttachmentOnlineUploadSession(Model.Device.SerialNumber)))" data-qrcodeurl="@Url.Content("~/ClientSource/Scripts/Modules/qrcode.min.js")">
@Html.AntiForgeryToken() @Html.AntiForgeryToken()
<div class="Disco-AttachmentUpload-DropTarget"> <div class="Disco-AttachmentUpload-DropTarget">
<h2>Drop Attachments Here</h2> <h2>Drop Attachments Here</h2>
@@ -121,18 +121,13 @@
success: function (d) { success: function (d) {
if (d.Result == 'OK') { if (d.Result == 'OK') {
var a = d.Attachment; var a = d.Attachment;
@if (canRemoveAnyAttachments)
{ if ($Attachments.hasClass('canRemoveAnyAttachments'))
<text>buildAttachment(a, true, quick);</text> buildAttachment(a, true, quick);
} else if ($Attachments.hasClass('canRemoveOwnAttachments'))
else if (canRemoveOwnAttachments) buildAttachment(a, (a.AuthorId === $Attachments.attr('data-userid')), quick);
{
<text>buildAttachment(a, (a.AuthorId === '@(CurrentUser.UserId)'), quick);</text>
}
else else
{ buildAttachment(a, false, quick);
<text>buildAttachment(a, false, quick);</text>
}
} else { } else {
alert('Unable to add attachment: ' + d.Result); alert('Unable to add attachment: ' + d.Result);
} }
+8 -13
View File
@@ -54,7 +54,7 @@
@if (canShowAttachments) @if (canShowAttachments)
{ {
<td id="AttachmentsContainer"> <td id="AttachmentsContainer">
<div id="Attachments" class="@(canAddAttachments ? "canAddAttachments" : "cannotAddAttachments")" data-uploadurl="@(Url.Action(MVC.API.Job.AttachmentUpload(Model.Job.Id, null)))" data-onlineuploadurl="@(Url.Action(MVC.API.Job.AttachmentOnlineUploadSession(Model.Job.Id)))" data-qrcodeurl="@Url.Content("~/ClientSource/Scripts/Modules/qrcode.min.js")"> <div id="Attachments" class="@(canAddAttachments ? "canAddAttachments" : "cannotAddAttachments") @(canRemoveAnyAttachments ? "canRemoveAnyAttachments" : "cannotRemoveAnyAttachments") @(canRemoveOwnAttachments ? "canRemoveOwnAttachments" : "cannotRemoveOwnAttachments")" data-userid="@CurrentUser.UserId" data-uploadurl="@(Url.Action(MVC.API.Job.AttachmentUpload(Model.Job.Id, null)))" data-onlineuploadurl="@(Url.Action(MVC.API.Job.AttachmentOnlineUploadSession(Model.Job.Id)))" data-qrcodeurl="@Url.Content("~/ClientSource/Scripts/Modules/qrcode.min.js")">
@Html.AntiForgeryToken() @Html.AntiForgeryToken()
<div class="Disco-AttachmentUpload-DropTarget"> <div class="Disco-AttachmentUpload-DropTarget">
<h2>Drop Attachments Here</h2> <h2>Drop Attachments Here</h2>
@@ -230,7 +230,7 @@
}); });
if (!response.ok) { if (!response.ok) {
alert('Unable to load live comment ' + id + ': ' + textStatus); alert('Unable to load live comment ' + id + ': ' + response.statusText);
} else { } else {
const comment = await response.json(); const comment = await response.json();
@@ -417,18 +417,13 @@
success: function (d) { success: function (d) {
if (d.Result == 'OK') { if (d.Result == 'OK') {
var a = d.Attachment; var a = d.Attachment;
@if (canRemoveAnyAttachments)
{ if ($Attachments.hasClass('canRemoveAnyAttachments'))
<text>buildAttachment(a, true, quick);</text> buildAttachment(a, true, quick);
} else if ($Attachments.hasClass('canRemoveOwnAttachments'))
else if (canRemoveOwnAttachments) buildAttachment(a, (a.AuthorId === $Attachments.attr('data-userid')), quick);
{
<text>buildAttachment(a, (a.AuthorId === '@(CurrentUser.UserId)'), quick);</text>
}
else else
{ buildAttachment(a, false, quick);
<text>buildAttachment(a, false, quick);</text>
}
} else { } else {
alert('Unable to add attachment: ' + d.Result); alert('Unable to add attachment: ' + d.Result);
} }
@@ -403,7 +403,7 @@ WriteLiteral(">\r\n <div");
WriteLiteral(" id=\"Attachments\""); WriteLiteral(" id=\"Attachments\"");
WriteAttribute("class", Tuple.Create(" class=\"", 3335), Tuple.Create("\"", 3410) WriteAttribute("class", Tuple.Create(" class=\"", 3335), Tuple.Create("\"", 3582)
#line 57 "..\..\Views\Job\JobParts\Resources.cshtml" #line 57 "..\..\Views\Job\JobParts\Resources.cshtml"
, Tuple.Create(Tuple.Create("", 3343), Tuple.Create<System.Object, System.Int32>(canAddAttachments ? "canAddAttachments" : "cannotAddAttachments" , Tuple.Create(Tuple.Create("", 3343), Tuple.Create<System.Object, System.Int32>(canAddAttachments ? "canAddAttachments" : "cannotAddAttachments"
@@ -411,8 +411,33 @@ WriteAttribute("class", Tuple.Create(" class=\"", 3335), Tuple.Create("\"", 3410
#line default #line default
#line hidden #line hidden
, 3343), false) , 3343), false)
#line 57 "..\..\Views\Job\JobParts\Resources.cshtml"
, Tuple.Create(Tuple.Create(" ", 3410), Tuple.Create<System.Object, System.Int32>(canRemoveAnyAttachments ? "canRemoveAnyAttachments" : "cannotRemoveAnyAttachments"
#line default
#line hidden
, 3411), false)
#line 57 "..\..\Views\Job\JobParts\Resources.cshtml"
, Tuple.Create(Tuple.Create(" ", 3496), Tuple.Create<System.Object, System.Int32>(canRemoveOwnAttachments ? "canRemoveOwnAttachments" : "cannotRemoveOwnAttachments"
#line default
#line hidden
, 3497), false)
); );
WriteLiteral(" data-userid=\"");
#line 57 "..\..\Views\Job\JobParts\Resources.cshtml"
Write(CurrentUser.UserId);
#line default
#line hidden
WriteLiteral("\"");
WriteLiteral(" data-uploadurl=\""); WriteLiteral(" data-uploadurl=\"");
@@ -484,14 +509,14 @@ WriteLiteral(">\r\n");
#line hidden #line hidden
WriteLiteral(" <a"); WriteLiteral(" <a");
WriteAttribute("href", Tuple.Create(" href=\"", 4075), Tuple.Create("\"", 4132) WriteAttribute("href", Tuple.Create(" href=\"", 4281), Tuple.Create("\"", 4338)
#line 65 "..\..\Views\Job\JobParts\Resources.cshtml" #line 65 "..\..\Views\Job\JobParts\Resources.cshtml"
, Tuple.Create(Tuple.Create("", 4082), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.API.Job.AttachmentDownload(ja.Id)) , Tuple.Create(Tuple.Create("", 4288), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.API.Job.AttachmentDownload(ja.Id))
#line default #line default
#line hidden #line hidden
, 4082), false) , 4288), false)
); );
WriteLiteral(" data-attachmentid=\""); WriteLiteral(" data-attachmentid=\"");
@@ -520,28 +545,28 @@ WriteLiteral(">\r\n <span");
WriteLiteral(" class=\"icon\""); WriteLiteral(" class=\"icon\"");
WriteAttribute("title", Tuple.Create(" title=\"", 4242), Tuple.Create("\"", 4262) WriteAttribute("title", Tuple.Create(" title=\"", 4448), Tuple.Create("\"", 4468)
#line 66 "..\..\Views\Job\JobParts\Resources.cshtml" #line 66 "..\..\Views\Job\JobParts\Resources.cshtml"
, Tuple.Create(Tuple.Create("", 4250), Tuple.Create<System.Object, System.Int32>(ja.Filename , Tuple.Create(Tuple.Create("", 4456), Tuple.Create<System.Object, System.Int32>(ja.Filename
#line default #line default
#line hidden #line hidden
, 4250), false) , 4456), false)
); );
WriteLiteral(">\r\n <img"); WriteLiteral(">\r\n <img");
WriteLiteral(" alt=\"Attachment Thumbnail\""); WriteLiteral(" alt=\"Attachment Thumbnail\"");
WriteAttribute("src", Tuple.Create(" src=\"", 4333), Tuple.Create("\"", 4392) WriteAttribute("src", Tuple.Create(" src=\"", 4539), Tuple.Create("\"", 4598)
#line 67 "..\..\Views\Job\JobParts\Resources.cshtml" #line 67 "..\..\Views\Job\JobParts\Resources.cshtml"
, Tuple.Create(Tuple.Create("", 4339), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.API.Job.AttachmentThumbnail(ja.Id)) , Tuple.Create(Tuple.Create("", 4545), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.API.Job.AttachmentThumbnail(ja.Id))
#line default #line default
#line hidden #line hidden
, 4339), false) , 4545), false)
); );
WriteLiteral(" />\r\n </span>\r\n <sp" + WriteLiteral(" />\r\n </span>\r\n <sp" +
@@ -549,14 +574,14 @@ WriteLiteral(" />\r\n </span>\r\n
WriteLiteral(" class=\"comments\""); WriteLiteral(" class=\"comments\"");
WriteAttribute("title", Tuple.Create(" title=\"", 4493), Tuple.Create("\"", 4513) WriteAttribute("title", Tuple.Create(" title=\"", 4699), Tuple.Create("\"", 4719)
#line 69 "..\..\Views\Job\JobParts\Resources.cshtml" #line 69 "..\..\Views\Job\JobParts\Resources.cshtml"
, Tuple.Create(Tuple.Create("", 4501), Tuple.Create<System.Object, System.Int32>(ja.Comments , Tuple.Create(Tuple.Create("", 4707), Tuple.Create<System.Object, System.Int32>(ja.Comments
#line default #line default
#line hidden #line hidden
, 4501), false) , 4707), false)
); );
WriteLiteral(">\r\n"); WriteLiteral(">\r\n");
@@ -651,14 +676,14 @@ WriteLiteral(" data-livestamp=\"");
#line hidden #line hidden
WriteLiteral("\""); WriteLiteral("\"");
WriteAttribute("title", Tuple.Create(" title=\"", 5198), Tuple.Create("\"", 5236) WriteAttribute("title", Tuple.Create(" title=\"", 5404), Tuple.Create("\"", 5442)
#line 75 "..\..\Views\Job\JobParts\Resources.cshtml" #line 75 "..\..\Views\Job\JobParts\Resources.cshtml"
, Tuple.Create(Tuple.Create("", 5206), Tuple.Create<System.Object, System.Int32>(ja.Timestamp.ToFullDateTime() , Tuple.Create(Tuple.Create("", 5412), Tuple.Create<System.Object, System.Int32>(ja.Timestamp.ToFullDateTime()
#line default #line default
#line hidden #line hidden
, 5206), false) , 5412), false)
); );
WriteLiteral(">"); WriteLiteral(">");
@@ -908,35 +933,35 @@ WriteLiteral("\r\n async function loadLiveComment(id) {\r\n\r\n
"tch($Comments.attr(\'data-geturl\'), {\r\n method: \'POST\',\r\n " + "tch($Comments.attr(\'data-geturl\'), {\r\n method: \'POST\',\r\n " +
" body: formData\r\n });\r\n\r\n if (!respo" + " body: formData\r\n });\r\n\r\n if (!respo" +
"nse.ok) {\r\n alert(\'Unable to load live comment \' + id + \': \' " + "nse.ok) {\r\n alert(\'Unable to load live comment \' + id + \': \' " +
"+ textStatus);\r\n } else {\r\n const comment = aw" + "+ response.statusText);\r\n } else {\r\n const com" +
"ait response.json();\r\n\r\n if ($Comments.hasClass(\'canRemoveAny" + "ment = await response.json();\r\n\r\n if ($Comments.hasClass(\'can" +
"Logs\'))\r\n addComment(comment, false, true);\r\n " + "RemoveAnyLogs\'))\r\n addComment(comment, false, true);\r\n " +
" else if ($Comments.hasClass(\'canRemoveOwnLogs\'))\r\n " + " else if ($Comments.hasClass(\'canRemoveOwnLogs\'))\r\n " +
" addComment(comment, false, (comment.AuthorId === $Comments.attr(\'data-userid\')" + " addComment(comment, false, (comment.AuthorId === $Comments.attr(\'data" +
"));\r\n else\r\n addComment(comment, false" + "-userid\')));\r\n else\r\n addComment(comme" +
", false);\r\n }\r\n }\r\n function liveRemoveComm" + "nt, false, false);\r\n }\r\n }\r\n function liveR" +
"ent(id) {\r\n $CommentOutput.children(\'div[data-logid=\"\' + id + \'\"]" + "emoveComment(id) {\r\n $CommentOutput.children(\'div[data-logid=\"\' +" +
"\').slideUp(300).delay(300).queue(function () {\r\n const $this " + " id + \'\"]\').slideUp(300).delay(300).queue(function () {\r\n con" +
"= $(this);\r\n $this.find(\'.timestamp\').livestamp(\'destroy\');\r\n" + "st $this = $(this);\r\n $this.find(\'.timestamp\').livestamp(\'des" +
" $this.remove();\r\n });\r\n }\r\n " + "troy\');\r\n $this.remove();\r\n });\r\n }" +
" function addComment(c, quick, canRemove) {\r\n let t = \'<div><" + "\r\n function addComment(c, quick, canRemove) {\r\n let t " +
"span class=\"author\" />\';\r\n if (canRemove)\r\n t " + "= \'<div><span class=\"author\" />\';\r\n if (canRemove)\r\n " +
"+= \'<span class=\"remove fa fa-times-circle\" />\';\r\n t += \'<span cl" + " t += \'<span class=\"remove fa fa-times-circle\" />\';\r\n t += " +
"ass=\"timestamp\" /><div class=\"comment\" /></div>\';\r\n\r\n const e = $" + "\'<span class=\"timestamp\" /><div class=\"comment\" /></div>\';\r\n\r\n co" +
"(t);\r\n e.attr(\'data-logid\', c.Id);\r\n e.find(\'.auth" + "nst e = $(t);\r\n e.attr(\'data-logid\', c.Id);\r\n e.fi" +
"or\').text(c.Author);\r\n e.find(\'.timestamp\').text(c.TimestampFull)" + "nd(\'.author\').text(c.Author);\r\n e.find(\'.timestamp\').text(c.Times" +
".attr(\'title\', c.TimestampFull).livestamp(c.TimestampUnixEpoc);\r\n " + "tampFull).attr(\'title\', c.TimestampFull).livestamp(c.TimestampUnixEpoc);\r\n " +
" e.find(\'.comment\').html(c.HtmlComments);\r\n\r\n $CommentOutput.appe" + " e.find(\'.comment\').html(c.HtmlComments);\r\n\r\n $CommentOu" +
"nd(e);\r\n\r\n if (!quick) {\r\n e.animate({ backgro" + "tput.append(e);\r\n\r\n if (!quick) {\r\n e.animate(" +
"undColor: \'#ffff99\' }, 500, function () {\r\n e.animate({ b" + "{ backgroundColor: \'#ffff99\' }, 500, function () {\r\n e.an" +
"ackgroundColor: \'#fafafa\' }, 500, function () {\r\n e.c" + "imate({ backgroundColor: \'#fafafa\' }, 500, function () {\r\n " +
"ss(\'background-color\', \'\');\r\n });\r\n })" + " e.css(\'background-color\', \'\');\r\n });\r\n " +
";\r\n $CommentOutput.animate({ scrollTop: $CommentOutput[0].scr" + " });\r\n $CommentOutput.animate({ scrollTop: $CommentOutp" +
"ollHeight }, 250)\r\n }\r\n }\r\n\r\n // Add Global" + "ut[0].scrollHeight }, 250)\r\n }\r\n }\r\n\r\n // A" +
"ly Available Functions\r\n document.DiscoFunctions.liveLoadComment = fu" + "dd Globally Available Functions\r\n document.DiscoFunctions.liveLoadCom" +
"nction (id) {\r\n loadLiveComment(id);\r\n };\r\n " + "ment = function (id) {\r\n loadLiveComment(id);\r\n };\r\n " +
" document.DiscoFunctions.liveRemoveComment = liveRemoveComment;\r\n //#" + " document.DiscoFunctions.liveRemoveComment = liveRemoveComment;\r\n " +
"endregion\r\n });\r\n </script>\r\n"); " //#endregion\r\n });\r\n </script>\r\n");
#line 284 "..\..\Views\Job\JobParts\Resources.cshtml" #line 284 "..\..\Views\Job\JobParts\Resources.cshtml"
@@ -1139,96 +1164,28 @@ WriteLiteral("\r\n function addAttachment(key, quick) {\r\n
#line hidden #line hidden
WriteLiteral("\',\r\n dataType: \'json\',\r\n data: data,\r\n " + WriteLiteral("\',\r\n dataType: \'json\',\r\n data: data,\r\n " +
" success: function (d) {\r\n if (d.Result == " + " success: function (d) {\r\n if (d.Result == " +
"\'OK\') {\r\n var a = d.Attachment;\r\n"); "\'OK\') {\r\n var a = d.Attachment;\r\n\r\n " +
" if ($Attachments.hasClass(\'canRemoveAnyAttachments\'))\r\n " +
" buildAttachment(a, true, quick);\r\n e" +
"lse if ($Attachments.hasClass(\'canRemoveOwnAttachments\'))\r\n " +
" buildAttachment(a, (a.AuthorId === $Attachments.attr(\'data-userid\'))," +
" quick);\r\n else\r\n buil" +
"dAttachment(a, false, quick);\r\n } else {\r\n " +
" alert(\'Unable to add attachment: \' + d.Result);\r\n " +
" }\r\n },\r\n error: function (jqXHR, tex" +
"tStatus, errorThrown) {\r\n alert(\'Unable to add attachment" +
": \' + textStatus);\r\n }\r\n });\r\n }\r\n " +
" function buildAttachment(a, canRemove, quick) {\r\n if (" +
"parseInt(a.ParentId) == jobId) {\r\n var t = \'<a><span class=\"i" +
"con\"><img alt=\"Attachment Thumbnail\" /></span><span class=\"comments\"></span><spa" +
"n class=\"author\"></span>\';\r\n if (canRemove)\r\n " +
" t += \'<span class=\"remove fa fa-times-circle\"></span>\';\r\n " +
" t += \'<span class=\"timestamp\"></span></a>\';\r\n\r\n var e = " +
"$(t);\r\n\r\n e.attr(\'data-attachmentid\', a.Id).attr(\'data-mimety" +
"pe\', a.MimeType).attr(\'href\', \'");
#line 420 "..\..\Views\Job\JobParts\Resources.cshtml" #line 445 "..\..\Views\Job\JobParts\Resources.cshtml"
#line default
#line hidden
#line 420 "..\..\Views\Job\JobParts\Resources.cshtml"
if (canRemoveAnyAttachments)
{
#line default
#line hidden
WriteLiteral(" ");
WriteLiteral("buildAttachment(a, true, quick);");
WriteLiteral("\r\n");
#line 423 "..\..\Views\Job\JobParts\Resources.cshtml"
}
else if (canRemoveOwnAttachments)
{
#line default
#line hidden
WriteLiteral(" ");
WriteLiteral("buildAttachment(a, (a.AuthorId === \'");
#line 426 "..\..\Views\Job\JobParts\Resources.cshtml"
Write(CurrentUser.UserId);
#line default
#line hidden
WriteLiteral("\'), quick);");
WriteLiteral("\r\n");
#line 427 "..\..\Views\Job\JobParts\Resources.cshtml"
}
else
{
#line default
#line hidden
WriteLiteral(" ");
WriteLiteral("buildAttachment(a, false, quick);");
WriteLiteral("\r\n");
#line 431 "..\..\Views\Job\JobParts\Resources.cshtml"
}
#line default
#line hidden
WriteLiteral(@" } else {
alert('Unable to add attachment: ' + d.Result);
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert('Unable to add attachment: ' + textStatus);
}
});
}
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)
t += '<span class=""remove fa fa-times-circle""></span>';
t += '<span class=""timestamp""></span></a>';
var e = $(t);
e.attr('data-attachmentid', a.Id).attr('data-mimetype', a.MimeType).attr('href', '");
#line 450 "..\..\Views\Job\JobParts\Resources.cshtml"
Write(Url.Action(MVC.API.Job.AttachmentDownload())); Write(Url.Action(MVC.API.Job.AttachmentDownload()));
@@ -1260,7 +1217,7 @@ WriteLiteral(@"/' + a.Id);
img.attr('src', '"); img.attr('src', '");
#line 473 "..\..\Views\Job\JobParts\Resources.cshtml" #line 468 "..\..\Views\Job\JobParts\Resources.cshtml"
Write(Url.Action(MVC.API.Job.AttachmentThumbnail())); Write(Url.Action(MVC.API.Job.AttachmentThumbnail()));
@@ -1307,14 +1264,14 @@ WriteLiteral("/\' + a.Id + \'?v=\' + retryCount);\r\n };\
"script>\r\n"); "script>\r\n");
#line 543 "..\..\Views\Job\JobParts\Resources.cshtml" #line 538 "..\..\Views\Job\JobParts\Resources.cshtml"
} }
#line default #line default
#line hidden #line hidden
#line 544 "..\..\Views\Job\JobParts\Resources.cshtml" #line 539 "..\..\Views\Job\JobParts\Resources.cshtml"
if (canShowLogs || canShowAttachments) if (canShowLogs || canShowAttachments)
{ {
@@ -1324,7 +1281,7 @@ WriteLiteral("/\' + a.Id + \'?v=\' + retryCount);\r\n };\
WriteLiteral(" <script>\r\n $(function () {\r\n var jobId = parseInt(\'"); WriteLiteral(" <script>\r\n $(function () {\r\n var jobId = parseInt(\'");
#line 548 "..\..\Views\Job\JobParts\Resources.cshtml" #line 543 "..\..\Views\Job\JobParts\Resources.cshtml"
Write(Model.Job.Id); Write(Model.Job.Id);
@@ -1334,7 +1291,7 @@ WriteLiteral("\');\r\n\r\n //#region LiveEvents\r\n var hu
"dates;\r\n\r\n // Map Functions\r\n"); "dates;\r\n\r\n // Map Functions\r\n");
#line 554 "..\..\Views\Job\JobParts\Resources.cshtml" #line 549 "..\..\Views\Job\JobParts\Resources.cshtml"
if (canShowLogs) if (canShowLogs)
{ {
@@ -1345,14 +1302,14 @@ WriteLiteral("\r\n hub.client.addLog = document.DiscoFunctions.liveLo
" "); " ");
#line 558 "..\..\Views\Job\JobParts\Resources.cshtml" #line 553 "..\..\Views\Job\JobParts\Resources.cshtml"
} }
#line default #line default
#line hidden #line hidden
#line 559 "..\..\Views\Job\JobParts\Resources.cshtml" #line 554 "..\..\Views\Job\JobParts\Resources.cshtml"
if (canShowAttachments) if (canShowAttachments)
{ {
@@ -1373,7 +1330,7 @@ WriteLiteral(@"
"); ");
#line 572 "..\..\Views\Job\JobParts\Resources.cshtml" #line 567 "..\..\Views\Job\JobParts\Resources.cshtml"
} }
@@ -1415,7 +1372,7 @@ WriteLiteral("\r\n $.connection.hub.qs = { JobId: jobId };\r\n
"egion\r\n });\r\n </script>\r\n"); "egion\r\n });\r\n </script>\r\n");
#line 625 "..\..\Views\Job\JobParts\Resources.cshtml" #line 620 "..\..\Views\Job\JobParts\Resources.cshtml"
} }
#line default #line default
@@ -19,7 +19,7 @@
<table id="userShowResources"> <table id="userShowResources">
<tr> <tr>
<td id="AttachmentsContainer"> <td id="AttachmentsContainer">
<div id="Attachments" class="@(canAddAttachments ? "canAddAttachments" : "cannotAddAttachments")" data-uploadurl="@(Url.Action(MVC.API.User.AttachmentUpload(Model.User.UserId, null)))" data-onlineuploadurl="@(Url.Action(MVC.API.User.AttachmentOnlineUploadSession(Model.User.UserId)))" data-qrcodeurl="@Url.Content("~/ClientSource/Scripts/Modules/qrcode.min.js")"> <div id="Attachments" class="@(canAddAttachments ? "canAddAttachments" : "cannotAddAttachments") @(canRemoveAnyAttachments ? "canRemoveAnyAttachments" : "cannotRemoveAnyAttachments") @(canRemoveOwnAttachments ? "canRemoveOwnAttachments" : "cannotRemoveOwnAttachments")" data-userid="@CurrentUser.UserId" data-uploadurl="@(Url.Action(MVC.API.User.AttachmentUpload(Model.User.UserId, null)))" data-onlineuploadurl="@(Url.Action(MVC.API.User.AttachmentOnlineUploadSession(Model.User.UserId)))" data-qrcodeurl="@Url.Content("~/ClientSource/Scripts/Modules/qrcode.min.js")">
@Html.AntiForgeryToken() @Html.AntiForgeryToken()
<div class="Disco-AttachmentUpload-DropTarget"> <div class="Disco-AttachmentUpload-DropTarget">
<h2>Drop Attachments Here</h2> <h2>Drop Attachments Here</h2>
@@ -120,18 +120,13 @@
success: function (d) { success: function (d) {
if (d.Result == 'OK') { if (d.Result == 'OK') {
var a = d.Attachment; var a = d.Attachment;
@if (canRemoveAnyAttachments)
{ if ($Attachments.hasClass('canRemoveAnyAttachments'))
<text>buildAttachment(a, true, quick);</text> buildAttachment(a, true, quick);
} else if ($Attachments.hasClass('canRemoveOwnAttachments'))
else if (canRemoveOwnAttachments) buildAttachment(a, (a.AuthorId === $Attachments.attr('data-userid')), quick);
{
<text>buildAttachment(a, (a.AuthorId === '@(CurrentUser.UserId)'), quick);</text>
}
else else
{ buildAttachment(a, false, quick);
<text>buildAttachment(a, false, quick);</text>
}
} else { } else {
alert('Unable to add attachment: ' + d.Result); alert('Unable to add attachment: ' + d.Result);
} }