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
+9 -14
View File
@@ -54,7 +54,7 @@
@if (canShowAttachments)
{
<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()
<div class="Disco-AttachmentUpload-DropTarget">
<h2>Drop Attachments Here</h2>
@@ -230,7 +230,7 @@
});
if (!response.ok) {
alert('Unable to load live comment ' + id + ': ' + textStatus);
alert('Unable to load live comment ' + id + ': ' + response.statusText);
} else {
const comment = await response.json();
@@ -417,18 +417,13 @@
success: function (d) {
if (d.Result == 'OK') {
var a = d.Attachment;
@if (canRemoveAnyAttachments)
{
<text>buildAttachment(a, true, quick);</text>
}
else if (canRemoveOwnAttachments)
{
<text>buildAttachment(a, (a.AuthorId === '@(CurrentUser.UserId)'), quick);</text>
}
else
{
<text>buildAttachment(a, false, quick);</text>
}
if ($Attachments.hasClass('canRemoveAnyAttachments'))
buildAttachment(a, true, quick);
else if ($Attachments.hasClass('canRemoveOwnAttachments'))
buildAttachment(a, (a.AuthorId === $Attachments.attr('data-userid')), quick);
else
buildAttachment(a, false, quick);
} else {
alert('Unable to add attachment: ' + d.Result);
}