Änderungen von Dokument Confluence bridge for Attachments
Zuletzt geändert von xwikiadmin am 2025/01/07 11:39
Von Version 2.1
bearbeitet von xwikiadmin
am 2025/01/07 11:39
am 2025/01/07 11:39
Änderungskommentar:
Install extension [com.xwiki.pro:xwiki-pro-macros-confluence-bridges-ui/1.25.4]
Auf Version 1.1
bearbeitet von xwikiadmin
am 2024/06/24 14:35
am 2024/06/24 14:35
Änderungskommentar:
Install extension [com.xwiki.pro:xwiki-pro-macros-confluence-bridges-ui/1.19.4]
Zusammenfassung
-
Objekte (3 geändert, 0 hinzugefügt, 0 gelöscht)
Details
- XWiki.JavaScriptExtension[0]
-
- Code
-
... ... @@ -32,8 +32,14 @@ 32 32 if ($(e.target).prop('id').startsWith('confluenceAttachments')) { 33 33 // Select the livedata above the upload form. 34 34 const uploadForm = $(e.target).closest('form'); 35 - let associatedLivedata = uploadForm.prevAll('.liveData').first(); 36 - associatedLivedata.data('liveData').updateEntries(); 35 + // The 'xwiki-livedata' CSS class is present only before XWiki version 14.4. 36 + let associatedLivedata = uploadForm.prevAll('.liveData, .xwiki-livedata').first(); 37 + // We do not have access to a liveData object before XWiki 14.4. 38 + if (associatedLivedata.data('liveData') === undefined) { 39 + location.reload(); 40 + } else { 41 + associatedLivedata.data('liveData').updateEntries(); 42 + } 37 37 } 38 38 }); 39 39 ... ... @@ -48,7 +48,8 @@ 48 48 */ 49 49 $(document).on('click', '.confluenceAttachmentsMacro .attachmentActions .actiondelete', function(e) { 50 50 e.preventDefault(); 51 - let liveData = $(e.currentTarget).closest('.liveData'); 57 + // The 'xwiki-livedata' CSS class is present only before XWiki version 14.4. 58 + let liveData = $(e.currentTarget).closest('.liveData, .xwiki-livedata'); 52 52 var modal = liveData.nextAll('.deleteConfluenceAttachment'); 53 53 modal.data('relatedTarget', e.currentTarget); 54 54 modal.modal('show'); ... ... @@ -61,7 +61,8 @@ 61 61 e.preventDefault(); 62 62 var modal = $(e.currentTarget).closest('.deleteConfluenceAttachment'); 63 63 var button = $(modal.data('relatedTarget')); 64 - let liveData = button.closest('.liveData'); 71 + // The 'xwiki-livedata' CSS class is present only before XWiki version 14.4. 72 + let liveData = button.closest('.liveData, .xwiki-livedata'); 65 65 var notification; 66 66 67 67 $.ajax({ ... ... @@ -70,8 +70,13 @@ 70 70 notification = new XWiki.widgets.Notification(l10n['inProgress'], 'inprogress'); 71 71 }, 72 72 success : function() { 73 - liveData.data('liveData').updateEntries(); 74 - notification.replace(new XWiki.widgets.Notification(l10n['done'], 'done')); 81 + // We do not have access to a liveData object before XWiki 14.4. 82 + if (liveData.data('liveData') !== undefined) { 83 + liveData.data('liveData').updateEntries(); 84 + notification.replace(new XWiki.widgets.Notification(l10n['done'], 'done')); 85 + } else { 86 + location.reload(); 87 + } 75 75 }, 76 76 error: function() { 77 77 notification.replace(new XWiki.widgets.Notification(l10n['failed'], 'error'));
- XWiki.StyleSheetExtension[0]
-
- Code
-
... ... @@ -1,3 +1,15 @@ 1 1 .confluenceAttachmentsMacro legend { 2 2 font-size: 1em; 3 3 } 4 + /* These should be deleted after upgrading to a XWiki parent >= 14.6. */ 5 +.attachmentMimeType { 6 + color: $theme.textSecondaryColor; 7 + font-size: 32px; 8 + height: 32px; 9 + line-height: 32px; 10 + text-align: center; 11 +} 12 +.attachmentMimeType img { 13 + max-height: 32px; 14 + max-width: 48px; 15 +}
- XWiki.WikiMacroClass[0]
-
- Makro-Code
-
... ... @@ -100,6 +100,14 @@ 100 100 #end 101 101 #end 102 102 103 +#macro (supportsAttachJSON $supportsAttachJSON) 104 + ## The attachments.json code uses macros from attachment_macro.vm, so the existence of the attachments livedata macro 105 + ## is an indicator that the template exists and is adapted for livedata. 106 + #template('attachment_macros.vm') 107 + #set ($macroResult = "#showAttachmentsLiveData($doc 'id')") 108 + #set ($supportsAttachJSON = $macroResult.startsWith('{{liveData')) 109 +#end 110 + 103 103 ## Display a liveData with attachments from the specified document. 104 104 #macro (showConfluenceAttachmentsLiveData $attachmentsDoc $liveDataId) 105 105 #set ($liveDataConfig = { ... ... @@ -139,8 +139,14 @@ 139 139 'className': 'XWiki.AllAttachments', 140 140 "\$doc": "$attachmentsDoc" 141 141 }) 142 - #set ($discard = $sourceParams.put('template', 'xpart.vm')) 143 - #set ($discard = $sourceParams.put('vm', 'attachmentsjson.vm')) 150 + ## Since the correct attachmentsjson.vm was added in XWiki 14.8, we use a copy of its code for backwards compatibility. 151 + #supportsAttachJSON($supportsAttachJSON) 152 + #if ($supportsAttachJSON) 153 + #set ($discard = $sourceParams.put('template', 'xpart.vm')) 154 + #set ($discard = $sourceParams.put('vm', 'attachmentsjson.vm')) 155 + #else 156 + #set ($discard = $sourceParams.put('resultPage', 'Confluence.Macros.AttachmentsJSON')) 157 + #end 144 144 #getLiveDataSort($liveDataSort) 145 145 #if ($invalidSortBy) 146 146 {{warning}}