Änderungen von Dokument Calendar Macro
Zuletzt geändert von xwikiadmin am 2025/12/03 10:04
Von Version 7.1
bearbeitet von xwikiadmin
am 2025/05/21 09:32
am 2025/05/21 09:32
Änderungskommentar:
Install extension [com.xwiki.mocca-calendar:application-mocca-calendar-ui/2.15.2]
Auf Version 5.1
bearbeitet von xwikiadmin
am 2025/01/07 11:32
am 2025/01/07 11:32
Änderungskommentar:
Install extension [com.xwiki.mocca-calendar:application-mocca-calendar-ui/2.15]
Zusammenfassung
-
Objekte (2 geändert, 0 hinzugefügt, 0 gelöscht)
Details
- XWiki.JavaScriptExtension[0]
-
- Code
-
... ... @@ -746,14 +746,13 @@ 746 746 747 747 }); 748 748 749 -define('mocca-calendar-notification', { 750 - prefix: 'MoccaCalendar.notification.', 749 +define('mocca-calendar-import-notification', { 750 + prefix: 'MoccaCalendar.import.notification.', 751 751 keys: [ 752 - 'import.inprogress', 753 - 'import.done', 754 - 'import.error', 755 - 'import.filetoolarge', 756 - 'addObject.error' 752 + 'inprogress', 753 + 'done', 754 + 'error', 755 + 'filetoolarge' 757 757 ] 758 758 }); 759 759 ... ... @@ -760,7 +760,7 @@ 760 760 /** 761 761 * Delete event and calendar import actions. 762 762 */ 763 -require(['jquery', 'xwiki-meta', 'xwiki-job-runner', 'xwiki-l10n!mocca-calendar-notification'], 762 +require(['jquery', 'xwiki-meta', 'xwiki-job-runner', 'xwiki-l10n!mocca-calendar-import-notification'], 764 764 function($, xwikiMeta, JobRunner, l10n) { 765 765 /** 766 766 * Events triggered before deleteEvents modal is shown: save the button that triggers ... ... @@ -806,32 +806,6 @@ 806 806 startUploading(form); 807 807 }); 808 808 809 - $(document).on('click', '.box.infomessage > p > span > a', function(event) { 810 - event.preventDefault(); 811 - const addObjectButton = $('#add-calendar-object'); 812 - const target = addObjectButton.data('target'); 813 - // To be adapted to the standard XWiki rest endpoint for object creation after 814 - // XWIKI-20704: NullPointerException (NPE) when accessing objects with ComputedField properties from REST is fixed. 815 - var documentReference = XWiki.Model.resolve('MoccaCalendar.Code.MoccaCalendarObjectCreator', 816 - XWiki.EntityType.DOCUMENT); 817 - var targetUrl = new XWiki.Document(documentReference).getURL(); 818 - var params = { 819 - 'documentRef': target 820 - }; 821 - $.ajax({ 822 - url: targetUrl, 823 - type: 'POST', 824 - data: params, 825 - success: function (response) { 826 - window.location.reload(); 827 - }, 828 - error: function (xhr, status, error) { 829 - console.error('Failed to add the MoccaCalendarClass object', error); 830 - var notification = new XWiki.widgets.Notification(l10n.get('addObject.error'), 'error'); 831 - } 832 - }); 833 - }); 834 - 835 835 // Start uploading this file by creating a new XHR object with the file data. 836 836 var startUploading = function (form) { 837 837 var formData = new FormData(form); ... ... @@ -847,7 +847,7 @@ 847 847 request.send(formData); 848 848 checkImportJob(select.value); 849 849 } else { 850 - var notification = new XWiki.widgets.Notification(l10n.get(' import.filetoolarge'), 'error');823 + var notification = new XWiki.widgets.Notification(l10n.get('filetoolarge'), 'error'); 851 851 } 852 852 } 853 853 ... ... @@ -864,7 +864,7 @@ 864 864 {name: 'data', value: 'jobStatus'}, 865 865 {name: 'form_token', value: xwikiMeta.form_token} 866 866 ); 867 - var notification = new XWiki.widgets.Notification(l10n.get('i mport.inprogress'), 'inprogress');840 + var notification = new XWiki.widgets.Notification(l10n.get('inprogress'), 'inprogress'); 868 868 $('#import-calendar-file-button').prop('disabled', true); 869 869 return Promise.resolve(new JobRunner({ 870 870 createStatusRequest: function(jobId) { ... ... @@ -883,10 +883,10 @@ 883 883 throw new Error(response.error.message); 884 884 } else { 885 885 document.dispatchEvent(new Event('calendarImportCompleted')); 886 - notification.replace(new XWiki.widgets.Notification(l10n.get(' import.done'),'done'));859 + notification.replace(new XWiki.widgets.Notification(l10n.get('done'),'done')); 887 887 } 888 888 }).catch((reason) => { 889 - notification.replace(new XWiki.widgets.Notification(l10n.get(' import.error'),'error'));862 + notification.replace(new XWiki.widgets.Notification(l10n.get('error'),'error')); 890 890 return Promise.reject(reason); 891 891 }).finally(() => { 892 892 $('#import-calendar-file-button').prop('disabled', false);
- XWiki.WikiMacroClass[0]
-
- Makro-Code
-
... ... @@ -166,29 +166,22 @@ 166 166 #set ($escapedCalendarSpace = $escapetool.xml($doc.getSpace())) 167 167 #set ($escapedCalendarName = $escapetool.xml($doc.getDocumentReference().getName())) 168 168 #set ($actionURL = "$request.getContextPath()/rest/moccacalendar/import") 169 - #set ($xwikiCalendarDoc = $xwiki.getDocument($calendarDoc)) 170 - #set ($calendarObject = $xwikiCalendarDoc.getObject('MoccaCalendar.MoccaCalendarClass')) 171 171 <form class="xform" action="$actionURL" method="post"> 172 172 <div class="import-form"> 173 - #if ($calendarObject || $xwikiCalendarDoc.getFullName() == 'MoccaCalendar.Events') 174 - <label for="import-calendar-parent"> 175 - $escapetool.xml($services.localization.render('MoccaCalendar.calendar'))</label> 176 - <select id="import-calendar-parent" name="parentCalendar"> 177 - #foreach ($item in $services.moccacalendar.getAllCalendars()) ## TODO: add filter here, see MOCCACAL-76 178 - #set ($itemdoc = $xwiki.getDocument($item)) 179 - #if ($!{itemdoc} && ${itemdoc.hasAccessLevel("edit")}) 180 - #set ($selected="") 181 - #if ($itemdoc.getId() == $doc.getId()) 182 - #set ($selected=" selected='selected'") 183 - #end 184 - <option value="$escapetool.html($itemdoc.getFullName())"$selected> 185 - $itemdoc.getDisplayTitle()</option> 171 + <label for="import-calendar-parent"> 172 + $escapetool.xml($services.localization.render('MoccaCalendar.calendar'))</label> 173 + <select id="import-calendar-parent" name="parentCalendar"> 174 + #foreach ($item in $services.moccacalendar.getAllCalendars()) ## TODO: add filter here, see MOCCACAL-76 175 + #set ($itemdoc = $xwiki.getDocument($item)) 176 + #if ($!{itemdoc} && ${itemdoc.hasAccessLevel("edit")}) 177 + #set ($selected="") 178 + #if ($itemdoc.getId() == $doc.getId()) 179 + #set ($selected=" selected='selected'") 186 186 #end 181 + <option value="$escapetool.html($itemdoc.getFullName())"$selected> 182 + $itemdoc.getDisplayTitle()</option> 187 187 #end 188 - </select> 189 - #end 190 - <select id="import-calendar-parent" name="parentCalendar" hidden> 191 - <option value="$calendarDoc" selected>$calendarDoc.getDisplayTitle()</option> 184 + #end 192 192 </select> 193 193 <label for="import-ical-file-input">$escapetool.xml($services.localization.render( 194 194 'MoccaCalendar.import.modal.file.label'))</label> ... ... @@ -207,16 +207,6 @@ 207 207 </div> 208 208 </div> 209 209 #end 210 -#macro (addCalendarObject $docRef) 211 - {{html clean=false wiki=true}} 212 - <input type="hidden" id="add-calendar-object" data-target="$docRef"> 213 - 214 - {{info}} 215 - $escapetool.xml($services.localization.render('rendering.macro.moccacalendar.addObject.description')) 216 - [[**$escapetool.xml($services.localization.render('rendering.macro.moccacalendar.addObject.button'))**>>$docRef]] 217 - {{/info}} 218 - {{/html}} 219 -#end 220 220 {{/velocity}} 221 221 222 222 {{velocity}} ... ... @@ -279,13 +279,7 @@ 279 279 #if (!$services.licensing.licensor.hasLicensureForEntity($mainReference)) 280 280 {{missingLicenseMessage extensionName="moccacalendar.extension.name"/}} 281 281 #else 282 -#if($xcontext.action=='view') 283 -#set ($xwikiCalendarDoc = $xwiki.getDocument($calendarDoc)) 284 -#set ($calendarObject = $xwikiCalendarDoc.getObject('MoccaCalendar.MoccaCalendarClass')) 285 -#if ($filter == 'page' && !$calendarObject) 286 - #addCalendarObject($calendarDoc) 287 -#end 288 -{{html clean="false" wiki="false"}} 265 +#if($xcontext.action=='view'){{html clean="false" wiki="false"}} 289 289 #if($canCreateEvents) 290 290 ## create event link 291 291 <div class="calendar-buttons">