Skip to content

Commit

Permalink
Fixed Core.UI.js bugs - AttachmentExist is only generated for one upl…
Browse files Browse the repository at this point in the history
…oad field. However, it should be generated for all of them. In addition, the UploadField is not selected correctly.
  • Loading branch information
dennykorsukewitz committed Feb 21, 2025
1 parent 40c50d6 commit f28d711
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# 7.1.7 2025-xx-xx
- 2025-02-21 Fixed Core.UI.js bugs - AttachmentExist is only generated for one upload field. However, it should be generated for all of them. In addition, the UploadField is not selected correctly.
- 2025-02-21 Fixed broken documentation link in ACL Edit Screen and changed text of hint.

# 7.1.6 2025-02-19
Expand Down
9 changes: 5 additions & 4 deletions var/httpd/htdocs/js/Core.UI.js
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ Core.UI = (function (TargetNS) {

var $ContainerObj = $DropObj.closest('.Field'),
$FileuploadFieldObj = $ContainerObj.find('.AjaxDnDUpload'),
FieldID = $FileuploadFieldObj.attr('id'),
FormID = $FileuploadFieldObj.data('form-id') ? $FileuploadFieldObj.data('form-id') : $DropObj.closest('form').find('input[name=FormID]').val(),
ChallengeToken = $DropObj.closest('form').find('input[name=ChallengeToken]').val(),
IsMultiple = ($FileuploadFieldObj.attr('multiple') == 'multiple'),
Expand Down Expand Up @@ -744,8 +745,9 @@ Core.UI = (function (TargetNS) {
}

// Append input field for validation (see bug#13081).
if (!$('#AttachmentExists').length) {
$('.AttachmentListContainer').append('<input type="hidden" id="AttachmentExists" name="AttachmentExists" value="1" />');
// Add the FieldID to the input field value to make it easier to identify the upload field, which gets a new file.
if (!$ContainerObj.find('.AttachmentListContainer').find('#AttachmentExists').length) {
$ContainerObj.find('.AttachmentListContainer').append('<input type="hidden" id="AttachmentExists" name="AttachmentExists" value="' + FieldID + '" />');
}
});

Expand All @@ -755,7 +757,6 @@ Core.UI = (function (TargetNS) {
$DropObj.removeClass('Uploading');
},
error: function() {
// TODO: show an error tooltip?
$DropObj.removeClass('Uploading');
}
});
Expand Down Expand Up @@ -836,7 +837,7 @@ Core.UI = (function (TargetNS) {

var $TriggerObj = $(this),
$AttachmentListContainerObj = $TriggerObj.closest('.AttachmentListContainer'),
$UploadFieldObj = $AttachmentListContainerObj.next('.AjaxDnDUpload'),
$UploadFieldObj = $AttachmentListContainerObj.nextAll('.AjaxDnDUpload'),
FormID = $UploadFieldObj.data('form-id') ? $UploadFieldObj.data('form-id') : $(this).closest('form').find('input[name=FormID]').val(),
Data = {
Action: $(this).data('delete-action') ? $(this).data('delete-action') : 'AjaxAttachment',
Expand Down

0 comments on commit f28d711

Please sign in to comment.