Ä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 2.1
bearbeitet von xwikiadmin
am 2023/04/25 10:51
am 2023/04/25 10:51
Änderungskommentar:
Install extension [com.xwiki.mocca-calendar:application-mocca-calendar-ui/2.12]
Zusammenfassung
-
Objekte (3 geändert, 0 hinzugefügt, 3 gelöscht)
Details
- XWiki.JavaScriptExtension[0]
-
- Code
-
... ... @@ -1,11 +1,5 @@ 1 -require.config({ 2 - paths: { 3 - purify: "$services.webjars.url('org.webjars.npm:dompurify', 'dist/purify.js')" 4 - }, 5 -}); 1 +define('moccaCalendar', ['jquery', 'fullcalendar', 'moment'], function(jQuery, fullCalendar, moment) { 6 6 7 -define('moccaCalendar', ['jquery', 'fullcalendar', 'moment', 'purify'], function(jQuery, fullCalendar, moment, purify) { 8 - 9 9 // Make sure the XWiki 'namespace' and the ModalPopup class exist. 10 10 if (typeof(XWiki) == "undefined" || typeof(XWiki.widgets) == "undefined" || typeof(XWiki.widgets.ModalPopup) == "undefined") { 11 11 if (typeof console != "undefined" && typeof console.warn == "function") { ... ... @@ -40,9 +40,6 @@ 40 40 this.timeFormat = ''; 41 41 this.dayFormat = dateFormat; 42 42 } 43 - document.addEventListener('calendarImportCompleted', () => { 44 - calendar.fullCalendar('refetchEvents'); 45 - }); 46 46 }, 47 47 displayError: function(errorMessage) { 48 48 if (!errorMessage) { ... ... @@ -130,12 +130,6 @@ 130 130 document.cookie = cookieName + value + "; path=/"; 131 131 }; 132 132 133 - function removeColorPickers() { 134 - jQuery('#mocca-event-edit-form .color-picker').each(function(index) { 135 - jQuery('#' + jQuery(this).data('colpickId')).remove(); 136 - }); 137 - } 138 - 139 139 // 140 140 // the dialog to show / edit events 141 141 // ... ... @@ -151,7 +151,7 @@ 151 151 // call constructor from ModalPopup with params content, shortcuts, options 152 152 $super( 153 153 // this element will end up as 'this.content' 154 - new Element('form', {'class' : 'xform' , 'id' : 'mocca-event-edit-form'}),139 + new Element('form', {'class' : 'xform'}), 155 155 { 156 156 "show": {method: this.showDialog, keys: []}, 157 157 "close": {method: this.closeDialog, keys: ['Esc']} ... ... @@ -162,7 +162,6 @@ 162 162 title : this.interactionParameters.editMode ? "$escapetool.javascript($services.localization.render('MoccaCalendar.calendarevent.create'))" : "$escapetool.javascript($services.localization.render('MoccaCalendar.calendarevent.view'))", 163 163 removeOnClose : true, 164 164 onClose : function() { 165 - removeColorPickers(); 166 166 document.stopObserving('xwiki:moccacalendar:editmode'); 167 167 document.stopObserving('xwiki:moccacalendar:instancesaved'); 168 168 } ... ... @@ -203,7 +203,6 @@ 203 203 // and we only listen for the results to close the dialog 204 204 document.observe('xwiki:moccacalendar:instancesaved', function(event) { 205 205 this.savedBox.show(); 206 - removeColorPickers(); 207 207 this.closeDialog(); 208 208 this.helper.calendar.fullCalendar('refetchEvents'); 209 209 }.bind(this)); ... ... @@ -299,7 +299,6 @@ 299 299 } else { 300 300 saveUrl = this.interactionParameters.event.saveUrl; 301 301 } 302 - this.content.title.value = purify.sanitize(this.content.title.value) 303 303 this.content.writeAttribute('action', saveUrl + '&xpage=plain&ajax=true'); 304 304 this.content.request({ 305 305 onSuccess: function() { ... ... @@ -306,7 +306,6 @@ 306 306 this.saving = false; 307 307 this.savingBox.hide(); 308 308 this.savedBox.show(); 309 - removeColorPickers(); 310 310 this.closeDialog(); 311 311 this.helper.calendar.fullCalendar('refetchEvents'); 312 312 }.bind(this), ... ... @@ -403,20 +403,18 @@ 403 403 var buttons = new Element('div', {'class':'buttons'}); 404 404 var oldSkin = ! $('body').hasClassName('skin-flamingo'); // FIXME: bad b/w compat hack 405 405 formcontent.insert(buttons); 406 - // When you are in a read only calendar you only need the close button for the modal and you MUST Not fire 407 - // the xwiki:moccacalendar:editloaded event because you will get a bunch of errors. 408 408 if (this.interactionParameters.editMode) { 409 409 var that = this; 410 - if(this.helper.createEventBaseUrl.indexOf('disabled=disabled') === -1) { 411 - buttons.insert(this.createButton("submit","$escapetool.javascript($services.localization.render('save'))","","save-moccacalendar-event","btn")); 412 - buttons.down('#save-moccacalendar-event').observe('click', this.submitForm.bind(this)); 413 - // MOCCACAL-128: the event template has a space in the title to avoid showing the page name, but we want to remove this on load 414 - var titleField = formcontent.down('input[name="title"]') 415 - if (titleField && titleField.getAttribute('value').trim() == '') { titleField.setAttribute('value','') } 416 - document.fire('xwiki:moccacalendar:editloaded'); 417 - } 389 + buttons.insert(this.createButton("submit","$escapetool.javascript($services.localization.render('save'))","","save-moccacalendar-event","btn")); 390 + buttons.down('#save-moccacalendar-event').observe('click', this.submitForm.bind(this)); 418 418 buttons.insert('<span class="buttonwrapper"><a href="#" id="cancel-moccacalendar-event" class="secondary button">' + "$escapetool.javascript($services.localization.render('cancel'))" + '</a></span>'); 419 419 buttons.down('#cancel-moccacalendar-event').observe('click', this.closeDialog.bind(this)); 393 + 394 + // MOCCACAL-128: the event template has a space in the title to avoid showing the page name, but we want to remove this on load 395 + var titleField = formcontent.down('input[name="title"]') 396 + if (titleField && titleField.getAttribute('value').trim() == '') { titleField.setAttribute('value','') } 397 + 398 + document.fire('xwiki:moccacalendar:editloaded'); 420 420 $("MoccaCalendarEvent.MoccaCalendarEventClass_0_title").focus(); 421 421 } else { 422 422 var leftGroup = new Element('div', {'class':'btn-group btn-group-left'}); ... ... @@ -431,19 +431,13 @@ 431 431 } 432 432 // FIXME: this should be a plain link, but then it has no styles 433 433 if (oldSkin) { 434 - if (this.interactionParameters.event.readOnly != true) { 435 - leftGroup.insert(this.createButton("button","$escapetool.javascript($services.localization.render('view'))","","view-moccacalendar-event","btn")); 436 - } 413 + leftGroup.insert(this.createButton("button","$escapetool.javascript($services.localization.render('view'))","","view-moccacalendar-event","btn")); 437 437 leftGroup.insert('<span class="buttonwrapper"><a href="#" id="cancel-moccacalendar-event" class="secondary button">' + "$escapetool.javascript($services.localization.render('cancel'))" + '</a></span>'); 438 438 } else { 439 - if (this.interactionParameters.event.readOnly != true) { 440 - leftGroup.insert(' <button class="button btn btn-default" id="view-moccacalendar-event"><span class="glyphicon glyphicon-file"></span> '+"$escapetool.javascript($services.localization.render('view'))"+'</button>'); 441 - } 416 + leftGroup.insert(' <button class="button btn btn-default" id="view-moccacalendar-event"><span class="glyphicon glyphicon-file"></span> '+"$escapetool.javascript($services.localization.render('view'))"+'</button>'); 442 442 leftGroup.insert('<button class="button btn btn-default" id="cancel-moccacalendar-event"><span class="glyphicon glyphicon-remove"></span> '+"$escapetool.javascript($services.localization.render('cancel'))"+'</button>'); 443 443 } 444 - if (this.interactionParameters.event.readOnly != true) { 445 - leftGroup.down("#view-moccacalendar-event").observe('click', function(e) { e.stop(); window.location.href = this.interactionParameters.event.viewUrl; }.bind(this)); 446 - } 419 + leftGroup.down("#view-moccacalendar-event").observe('click', function(e) { e.stop(); window.location.href = this.interactionParameters.event.viewUrl; }.bind(this)); 447 447 leftGroup.down('#cancel-moccacalendar-event').observe('click', this.closeDialog.bind(this)); 448 448 if (this.interactionParameters.event.canDelete) { 449 449 var rightGroup = new Element('div', {'class':'btn-group btn-group-right'}); ... ... @@ -483,9 +483,6 @@ 483 483 script.remove(); 484 484 }); 485 485 content.insert('<div id="formcontent"><div id="forminnercontent">' + container.innerHTML + '</div></div>'); 486 - 487 - var parentModalPopup = jQuery('.xdialog-box-moccacal-modal-popup').toArray(); 488 - document.fire('xwiki:dom:updated', {elements: parentModalPopup}); 489 489 }, 490 490 handleDatetimeFieldChange : function(event, element) { 491 491 if (this.saving) { return; } ... ... @@ -746,22 +746,10 @@ 746 746 747 747 }); 748 748 749 -define('mocca-calendar-notification', { 750 - prefix: 'MoccaCalendar.notification.', 751 - keys: [ 752 - 'import.inprogress', 753 - 'import.done', 754 - 'import.error', 755 - 'import.filetoolarge', 756 - 'addObject.error' 757 - ] 758 -}); 759 - 760 760 /** 761 - * Delet e eventandcalendar importactions.720 + * Deleting an event 762 762 */ 763 -require(['jquery', 'xwiki-meta', 'xwiki-job-runner', 'xwiki-l10n!mocca-calendar-notification'], 764 - function($, xwikiMeta, JobRunner, l10n) { 722 +require(['jquery'], function($) { 765 765 /** 766 766 * Events triggered before deleteEvents modal is shown: save the button that triggers 767 767 * the modal, close MoccaCalendarPopup, update the name of event on displayed text. ... ... @@ -796,100 +796,4 @@ 796 796 var calendarPopup = relatedTarget.data('calendarPopup'); 797 797 new XWiki.MoccaCalendar.MoccaCalendarPopup(calendarPopup.interactionParameters, calendarPopup.helper); 798 798 }); 799 - 800 - // Trigger the upload manually when the button is clicked. 801 - $(document).on('click', '#import-calendar-file-button', function(event) { 802 - var form = $('#import-calendar-file form').get(0); 803 - if (event) { 804 - event.preventDefault(); 805 - } 806 - startUploading(form); 807 - }); 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 - // Start uploading this file by creating a new XHR object with the file data. 836 - var startUploading = function (form) { 837 - var formData = new FormData(form); 838 - var select = form.down('#import-calendar-parent'); 839 - var input = form.down('#import-ical-file-input'); 840 - if (input.files[0].size < input.dataset.maxFileSize) { 841 - var params = {}; 842 - params[select.name] = select.value; 843 - formData.action = form.action + "?" + $.param(params); 844 - // Create XMLHttpRequest object and POST the data 845 - var request = this.request = new XMLHttpRequest(); 846 - request.open('POST', formData.action); 847 - request.send(formData); 848 - checkImportJob(select.value); 849 - } else { 850 - var notification = new XWiki.widgets.Notification(l10n.get('import.filetoolarge'), 'error'); 851 - } 852 - } 853 - 854 - const checkImportJob = function(selectedCalendar) { 855 - let documentReference = XWiki.Model.resolve('MoccaCalendar.Code.ImportJobResource', XWiki.EntityType.DOCUMENT); 856 - var targetURL = new XWiki.Document(documentReference).getURL('get'); 857 - var targetJobId = ['moccacalendar', 'import', selectedCalendar]; 858 - var data = []; 859 - data.push( 860 - {name: 'outputSyntax', value: 'plain'}, 861 - {name: 'sheet', value: 'MoccaCalendar.Code.ImportJobResource'}, 862 - {name: 'action', value: 'jobStatus'}, 863 - {name: 'jobId', value: targetJobId.join('/')}, 864 - {name: 'data', value: 'jobStatus'}, 865 - {name: 'form_token', value: xwikiMeta.form_token} 866 - ); 867 - var notification = new XWiki.widgets.Notification(l10n.get('import.inprogress'), 'inprogress'); 868 - $('#import-calendar-file-button').prop('disabled', true); 869 - return Promise.resolve(new JobRunner({ 870 - createStatusRequest: function(jobId) { 871 - return { 872 - url: targetURL, 873 - data: { 874 - outputSyntax: 'plain', 875 - sheet: 'MoccaCalendar.Code.ImportJobResource', 876 - data: 'jobStatus', 877 - jobId: jobId.join('/') 878 - } 879 - }; 880 - } 881 - }).run(targetURL, data)).then((response) => { 882 - if (response.error !== null) { 883 - throw new Error(response.error.message); 884 - } else { 885 - document.dispatchEvent(new Event('calendarImportCompleted')); 886 - notification.replace(new XWiki.widgets.Notification(l10n.get('import.done'),'done')); 887 - } 888 - }).catch((reason) => { 889 - notification.replace(new XWiki.widgets.Notification(l10n.get('import.error'),'error')); 890 - return Promise.reject(reason); 891 - }).finally(() => { 892 - $('#import-calendar-file-button').prop('disabled', false); 893 - }); 894 - }; 895 895 });
- XWiki.StyleSheetExtension[0]
-
- Code
-
... ... @@ -79,24 +79,3 @@ 79 79 .skin-flamingo .gadget .fc h2 { 80 80 font-size: 140%; 81 81 } 82 - 83 -.import-form { 84 - padding: 2em; 85 -} 86 - 87 -.import-form label { 88 - margin-bottom: 0.8em; 89 - font-weight: bold; 90 -} 91 - 92 -.import-form select, 93 -.import-form #import-ical-file-input { 94 - width: 100%; 95 - margin-bottom: 1.6em; 96 - border-radius: 0.4em; 97 -} 98 - 99 -.import-form #import-ical-file-input { 100 - padding: 0.6em 1em; 101 - border: 1px solid #ccc; 102 -}
- XWiki.WikiMacroClass[0]
-
- Makro-Code
-
... ... @@ -67,33 +67,6 @@ 67 67 #if(!$date) 68 68 #set($date = "") 69 69 #end 70 -#set($gCal = "$!xcontext.macro.params.gCal") 71 -#set($gApiKey = $xcontext.macro.params.gApiKey) 72 -#if(!$gApiKey) 73 - #set($gApiKey = "") 74 -#end 75 -#set($iCal = $xcontext.macro.params.iCal) 76 -#if(!$iCal) 77 - #set ($iCal = "") 78 -#end 79 -## Prepare the fields if the subscribed class is present 80 -#set ($subscribed = $doc.getObject('MoccaCalendar.MoccaCalendarSubscribeClass')) 81 -#if ($subscribed) 82 - #set ($subscribediCal = $subscribed.getValue('iCal')) 83 - #set ($subscribedgCals = $subscribed.getValue('gCal')) 84 - #set ($gApiKeySubscribed = $subscribed.getValue('gApiKey')) 85 - #set ($subscribedColor = $subscribed.getValue('color')) 86 - #set ($subscribedTextColor = $subscribed.getValue('textColor')) 87 - #set ($disableCreationEvent = 'disabled') 88 -#else 89 - #set ($subscribediCals = '') 90 - #set ($subscribedgCals = '') 91 - #set ($gApiKeySubscribed = '') 92 - #set ($subscribedColor = 'blue') 93 - #set ($subscribedTextColor = 'white') 94 - #set ($disableCreationEvent = "") 95 -#end 96 - 97 97 ## If the date format is not set in MoccaCalendarEventClass, we are going to use the date format from the current wiki. 98 98 #set($dateFormat = $!xwiki.getClass("MoccaCalendar.MoccaCalendarEventClass").get("startDate").getProperty('dateFormat').value) 99 99 #if("$!dateFormat" == "") ... ... @@ -151,148 +151,23 @@ 151 151 </div> 152 152 </div> 153 153 #end 154 - 155 -#macro(importCalendarFileModal) 156 - <div class="modal fade" id="import-calendar-file" tabindex="-1" role="dialog"> 157 - <div class="modal-dialog"> 158 - <div class="modal-content"> 159 - <div class="modal-header"> 160 - <button type="button" class="close" data-dismiss="modal">×</button> 161 - <h4 class="modal-title"> 162 - $escapetool.xml($services.localization.render('MoccaCalendar.import.modal.title')) 163 - </h4> 164 - </div> 165 - <div class="modal-body"> 166 - #set ($escapedCalendarSpace = $escapetool.xml($doc.getSpace())) 167 - #set ($escapedCalendarName = $escapetool.xml($doc.getDocumentReference().getName())) 168 - #set ($actionURL = "$request.getContextPath()/rest/moccacalendar/import") 169 - #set ($xwikiCalendarDoc = $xwiki.getDocument($calendarDoc)) 170 - #set ($calendarObject = $xwikiCalendarDoc.getObject('MoccaCalendar.MoccaCalendarClass')) 171 - <form class="xform" action="$actionURL" method="post"> 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> 186 - #end 187 - #end 188 - </select> 189 - #end 190 - <select id="import-calendar-parent" name="parentCalendar" hidden> 191 - <option value="$calendarDoc" selected>$calendarDoc.getDisplayTitle()</option> 192 - </select> 193 - <label for="import-ical-file-input">$escapetool.xml($services.localization.render( 194 - 'MoccaCalendar.import.modal.file.label'))</label> 195 - <input type="file" id="import-ical-file-input" accept=".ics" name="importedfile" 196 - data-max-file-size="$!escapetool.xml($xwiki.getSpacePreference('upload_maxsize'))"> 197 - </div> 198 - </form> 199 - </div> 200 - <div class="modal-footer"> 201 - <input type="button" class="btn btn-primary" id="import-calendar-file-button" 202 - value="$escapetool.xml($services.localization.render('MoccaCalendar.import.modal.button.start'))"> 203 - <input type="button" class="btn btn-default" 204 - value="$escapetool.xml($services.localization.render('cancel'))" data-dismiss="modal"> 205 - </div> 206 - </div> 207 - </div> 208 - </div> 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 -{{velocity}} 223 -#macro(getSubscribedCalendars) 224 - #set ($query = ", BaseObject as obj where doc.fullName = obj.name and obj.className = 'MoccaCalendar.MoccaCalendarSubscribeClass'") 225 - #set ($calendarDocumentsReferences = $services.query.hql($query).execute()) 226 - #set ($properties = []) 227 - #foreach($reference in $calendarDocumentsReferences) 228 - #set ($document = $xwiki.getDocument($reference)) 229 - #set ($class = $document.getObject('MoccaCalendar.MoccaCalendarSubscribeClass')) 230 - #if ($class.getValue('globalDisplay') == '1') 231 - #set ($discard = $properties.add({ 232 - 'iCal': $class.getValue('iCal'), 233 - 'gCal': $class.getValue('gCal'), 234 - 'gApiKey': $class.getValue('gApiKey'), 235 - 'color': $class.getValue('color'), 236 - 'textColor': $class.getValue('textColor') 237 - })) 238 - #end 239 - #end 240 -#end 129 +{{include reference="Licenses.Code.VelocityMacros"/}} 241 241 242 -## Macro for handling iCal sources 243 -#macro(handleICalSources $iCalList $color $textColor) 244 - #set($iCals = $stringtool.split($iCalList, ',')) 245 - #foreach($iCal in $iCals) 246 - #set($json = $xwiki.getDocument('Calendar.ICalToJSON').getURL('get', "iCal=$escapetool.url($stringtool.strip($iCal))")) 247 - { 248 - url: "$json&outputSyntax=plain&startfield=datetime", 249 - backgroundColor: "$color", 250 - textColor: "$textColor" 251 - } 252 - #if($foreach.count < $iCals.size()) 253 - , 254 - #end 255 - #end 256 -#end 257 - 258 -## Macro for handling Google Calendar sources 259 -#macro(handleGoogleCalendarSources $gCalList $apiKey $color, $textColor) 260 - #set($googleCalendars = $stringtool.split($gCalList, ',')) 261 - #foreach($calendar in $googleCalendars) 262 - { 263 - googleCalendarId: "$stringtool.strip($calendar)", 264 - googleCalendarApiKey: "$apiKey", 265 - backgroundColor: "$color", 266 - textColor: "$textColor" 267 - } 268 - #if($foreach.count < $googleCalendars.size()) 269 - , 270 - #end 271 - #end 272 -#end 273 - 274 - 131 +{{velocity}} 275 275 ## We need to check if there is a valid license because the macro is registered even if the user doesn't have view right 276 276 ## on the macro definition page. See XWIKI-14828: Rendering macros defined in wiki pages are available to users that 277 277 ## don't have view right on those pages. 278 278 #set ($mainReference = $services.model.createDocumentReference('', 'MoccaCalendar', 'MoccaCalendarClass')) 279 279 #if (!$services.licensing.licensor.hasLicensureForEntity($mainReference)) 280 - {{ missingLicenseMessageextensionName="moccacalendar.extension.name"/}}137 + {{error}}#getMissingLicenseMessage('moccacalendar.extension.name'){{/error}} 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"}} 139 +#if($xcontext.action=='view'){{html clean="false" wiki="false"}} 289 289 #if($canCreateEvents) 290 290 ## create event link 291 291 <div class="calendar-buttons"> 292 292 <span class="buttonwrapper"> 293 -<button data-toggle="modal" data-target="#import-calendar-file" 294 - title="$escapetool.xml($services.localization.render('MoccaCalendar.calendarevent.import.title'))"> 295 - $escapetool.html($services.localization.render('MoccaCalendar.calendarevent.import'))</button> 296 296 <button class="btn btn-success" id="calendar${calcounter}-btn"><span class="glyphicon glyphicon-plus"></span> $escapetool.html($services.localization.render('MoccaCalendar.calendarevent.create'))</button> 297 297 </span> 298 298 </div> ... ... @@ -300,14 +300,7 @@ 300 300 #end 301 301 <div id="calendar${calcounter}"></div> 302 302 <script type="text/javascript"> 303 -require.config({ 304 - paths: { 305 - purify: "$services.webjars.url('org.webjars.npm:dompurify', 'dist/purify.js')" 306 - }, 307 -}); 308 - 309 - 310 -require(['xwiki-meta', 'jquery', 'moment','purify', 'gcal', 'moccaCalendar'], function(xwikiMeta, jQuery, moment, purify) { 151 +require(['xwiki-meta', 'jquery', 'moccaCalendar'], function(xwikiMeta, jQuery) { 311 311 jQuery(document).ready(function() { 312 312 var defaultView = XWiki.MoccaCalendar.Helper.getCalendarView("$!escapetool.javascript($defaultView)"); 313 313 ... ... @@ -330,79 +330,21 @@ 330 330 331 331 // page is now ready, initialize the calendar... 332 332 var calendar = jQuery('#calendar${calcounter}').fullCalendar({ 333 - eventSources: [ 334 - ## Source where the xwiki events are stored. 335 - { 336 - url: "$!escapetool.javascript($jsonUrl)", 337 - type: 'GET', 338 - data: function() { 339 - // as we also get called before the calendar is fully initialized 340 - // we cannot get the current view reliably from the calendar itself 341 - // instead use our trusty helper 342 - return jQuery.extend(defaultEventData, {'outputView': XWiki.MoccaCalendar.Helper.getCalendarView(defaultView)} ); 343 - }, 344 - error: function() { 345 - calendarHelper.displayError(); 346 - }, 347 - traditional: true 348 - } 349 - ## Subscribed iCal sources 350 - #if($subscribediCal) 351 - , 352 - #handleICalSources($subscribediCal, $subscribedColor, $subscribedTextColor) 353 - #end 354 - ## Subscribed Google Calendar sources 355 - #if($!subscribedgCals != "") 356 - , 357 - #handleGoogleCalendarSources($subscribedgCals, $gApiKeySubscribed, $subscribedColor, $subscribedTextColor) 358 - #end 359 - ## Global events 360 - #if($doc.getFullName() == 'MoccaCalendar.WebHome') 361 - #getSubscribedCalendars() 362 - #foreach($property in $properties) 363 - , 364 - #handleICalSources($property['iCal'], $property['color'], $property['textColor']) 365 - , 366 - #handleGoogleCalendarSources($property['gCal'], $property['gApiKey'], $property['color'], $property['textColor']) 367 - #end 368 - #end 369 - ## In case the user uses the calendar macro directly and dosen't use the UI to create it. 370 - ## iCal sources 371 - #if($!iCal != "") 372 - , 373 - #handleICalSources($iCal 'black') 374 - #end 375 - ## Google Calendar public sources 376 - #if($!gCal != "") 377 - , 378 - #handleGoogleCalendarSources($gCal $gApiKey 'blue') 379 - #end 380 - ], 174 + events: { 175 + url : "$!escapetool.javascript($jsonUrl)", 176 + type: 'GET', 177 + data : function() { 178 + // as we also get called before the calendar is fully initialized 179 + // we cannot get the current view reliably from the calendar itself 180 + // instead use our trusty helper 181 + return jQuery.extend(defaultEventData, {'outputView': XWiki.MoccaCalendar.Helper.getCalendarView(defaultView)} ); 182 + }, 183 + error: function() { 184 + calendarHelper.displayError(); 185 + }, 186 + traditional: true 187 + }, 381 381 eventClick: function(calEvent, jsEvent, view) { 382 - // Prepare the read only events for the modal. 383 - if (!calEvent.viewUrl){ 384 - // The XWiki default format for date is yyyy/MM/dd, which translates into 2024/01/17. However, for some weird 385 - // reason, when using the date.format() from JavaScript, it translates into 2024/01/Mon. We need to use the 386 - // moment().toMomentFormatString(format) to get the right format. 387 - const dateFormat = moment().toMomentFormatString(calendarHelper.dateFormat); 388 - 389 - // Get the sheet URL. 390 - const sheetURL = new XWiki.Document('MoccaCalendarEventSheet', 'MoccaCalendar').getURL('get'); 391 - // Parameters for the modal content. 392 - const params = { 393 - title: purify.sanitize(calEvent.title), 394 - start: calEvent.start.format(dateFormat), 395 - end: calEvent.end ? calEvent.end.format(dateFormat) : null, 396 - allDay: calEvent.allDay ? "$escapetool.xml($services.localization.render('moccacalendar.subscribedevent.allday.yes'))" : 397 - "$escapetool.xml($services.localization.render('moccacalendar.subscribedevent.allday.no'))", 398 - description: purify.sanitize(calEvent.description), 399 - readOnly: 'true' 400 - }; 401 - const queryString = jQuery.param(params); 402 - const requestURL = `${sheetURL}?${queryString}`; 403 - calEvent.url = requestURL; 404 - calEvent.readOnly=true; 405 - } 406 406 new XWiki.MoccaCalendar.MoccaCalendarPopup({editMode: false, event: calEvent}, calendarHelper); 407 407 jsEvent.preventDefault(); 408 408 return false; ... ... @@ -471,7 +471,7 @@ 471 471 }); 472 472 jQuery('#calendar${calcounter}-btn').click( function(e) { calendarHelper.showCreateEvent(); e.preventDefault(); }); 473 473 // helper to be used in callback above 474 -#set($newPageParams = "template=MoccaCalendar.MoccaCalendarEventTemplate&parentFROM=${escapetool.url($calendarDoc)}&form_token=${services.csrf.getToken()}&ocalcaction=create &disabled=$disableCreationEvent")257 +#set($newPageParams = "template=MoccaCalendar.MoccaCalendarEventTemplate&parentFROM=${escapetool.url($calendarDoc)}&form_token=${services.csrf.getToken()}&ocalcaction=create") 475 475 #set($randomDocUrl = $xwiki.getURL("randomPage${util.generateRandomString(10)}",'edit',$newPageParams)) 476 476 #set($updateUrlParams="?xpage=plain&outputSyntax=plain&calendarDoc=${escapetool.url(${calendarDoc})}&") 477 477 var calendarHelper = new XWiki.MoccaCalendar.Helper(calendar, ... ... @@ -490,7 +490,6 @@ 490 490 </script> 491 491 #if($calcounter == 0) 492 492 #showDeleteEventsModal 493 - #importCalendarFileModal 494 494 #end 495 495 {{/html}} 496 496 #else ## of #if($xcontext.action=='view') - Default categories
-
... ... @@ -1,1 +1,0 @@ 1 -Content - Standardkategorie
-
... ... @@ -1,0 +1,1 @@ 1 +Content
- XWiki.WikiMacroParameterClass[11]
-
- Parameter verpflichtend
-
... ... @@ -1,1 +1,0 @@ 1 -Nein - Parameter-Name
-
... ... @@ -1,1 +1,0 @@ 1 -gCal
- XWiki.WikiMacroParameterClass[12]
-
- Parameter verpflichtend
-
... ... @@ -1,1 +1,0 @@ 1 -Nein - Parameter-Name
-
... ... @@ -1,1 +1,0 @@ 1 -gApiKey
- XWiki.WikiMacroParameterClass[13]
-
- Parameter verpflichtend
-
... ... @@ -1,1 +1,0 @@ 1 -Nein - Parameter-Name
-
... ... @@ -1,1 +1,0 @@ 1 -iCal