Modifications pour le document Confluence bridge for Attachments
Modifié par Admin le 21/07/2025 - 09:06
Depuis la version 5.1
modifié par superadmin
sur 25/05/2025 - 00:00
sur 25/05/2025 - 00:00
Commentaire de modification :
Install extension [com.xwiki.pro:xwiki-pro-macros-confluence-bridges-ui/1.26.20]
Résumé
-
Propriétés de la Page (1 modifications, 0 ajouts, 0 suppressions)
-
Objets (3 modifications, 0 ajouts, 0 suppressions)
Détails
- Propriétés de la Page
-
- Auteur du document
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. superadmin1 +XWiki.admin
- 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]
-
- Code de la macro
-
... ... @@ -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 = { ... ... @@ -118,14 +118,35 @@ 118 118 } 119 119 }) 120 120 129 + #if ("$!wikimacro.parameters.patterns" != '') 130 + #set ($liveDataConfig.query = {}) 131 + #set ($liveDataConfig.query.filters = [ 132 + { 133 + "property": "filename", 134 + "matchAll": true, 135 + "constraints": [] 136 + } 137 + ]) 138 + #set ($filters = $stringtool.split($wikimacro.parameters.patterns, ',')) 139 + #foreach ($filter in $filters) 140 + #set ($discard = $liveDataConfig.query.filters[0].constraints.add( 141 + { "operator": "contains", "value": "$!filter.trim()" } 142 + )) 143 + #end 144 + #end 121 121 #set ($sourceParams = { 122 122 'translationPrefix': 'core.viewers.attachments.livetable.', 123 123 'className': 'XWiki.AllAttachments', 124 - "\$doc": "$attachmentsDoc", 125 - 'patterns': "$!wikimacro.parameters.patterns" 148 + "\$doc": "$attachmentsDoc" 126 126 }) 127 - #set ($discard = $sourceParams.put('template', 'xpart.vm')) 128 - #set ($discard = $sourceParams.put('vm', 'filteredAttachments.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 129 129 #getLiveDataSort($liveDataSort) 130 130 #if ($invalidSortBy) 131 131 {{warning}} ... ... @@ -161,8 +161,8 @@ 161 161 'forceSkinAction': true, 162 162 'language': $xcontext.locale 163 163 })) 164 - #set ($discard = $xwiki.jsx.use("Confluence.Macros. ConfluenceAttachments"))165 - #set ($discard = $xwiki.ssx.use("Confluence.Macros. ConfluenceAttachments"))193 + #set ($discard = $xwiki.jsx.use("Confluence.Macros.Attachments")) 194 + #set ($discard = $xwiki.ssx.use("Confluence.Macros.Attachments")) 166 166 #set ($document = $doc) 167 167 #if ("$!wikimacro.parameters.page" != '') 168 168 #set ($document = $xwiki.getDocument("$!wikimacro.parameters.page")) ... ... @@ -181,7 +181,7 @@ 181 181 ## We need to check if there is a valid license because the macro is registered even if the user doesn't have view right 182 182 ## on the macro definition page. See XWIKI-14828: Rendering macros defined in wiki pages are available to users that 183 183 ## don't have view right on those pages. 184 -#if ($services.licensing. licensor.hasLicensureForEntity($xcontext.macro.doc.documentReference))213 +#if ($services.promacrolicensing.hasLicensureForEntity($xcontext.macro.doc.documentReference)) 185 185 #executeMacro 186 186 #else 187 187 {{missingLicenseMessage extensionName="proMacros.extension.name"/}}