[TikiWiki-commits] [Git][tikiwiki/tiki][29.x] [FIX] Enable viewing of multiple module calendars simultaneously and fix the...
"franck franck kalunga \(@francksfkal\) via TikiWiki-cvs" <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <69d439376f442_3b190924325b7@gitlab-sidekiq-low-urgency-cpu-bound-v2-56f49f545c-6tpg5.mail> |
franck franck kalunga pushed to branch 29.x at Tiki Wiki CMS Groupware / Tiki
Commits:
b649e6f6 by franck franck kalunga at 2026-04-07T00:45:04+02:00
[FIX] Enable viewing of multiple module calendars simultaneously and fix the...
---
* [FIX] Enable viewing of multiple module calendars simultaneously and fix the...
---
* [FIX] Enable viewing of multiple module calendars simultaneously and fix the...
---
* [FIX] Enable viewing of multiple module calendars simultaneously and fix the display of the tracker list calendar view
See merge request tikiwiki/tiki!9665
See merge request tikiwiki/tiki!9957
See merge request tikiwiki/tiki!9958
- - - - -
8 changed files:
- lib/wiki-plugins/wikiplugin_calendar.php
- lib/wiki-plugins/wikiplugin_trackerlist.php
- modules/mod-func-calendar_new.php
- src/js/jquery-tiki/tiki-calendar.js
- templates/modules/mod-calendar_new.tpl
- templates/tiki-calendar.tpl
- templates/wiki-plugins/wikiplugin_calendar.tpl
- tiki-setup.php
Changes:
=====================================
lib/wiki-plugins/wikiplugin_calendar.php
=====================================
@@ -164,7 +164,7 @@ function wikiplugin_calendar($data, $params)
'eventCalendarParams',
$calendarInitialParams
);
-
+ $smarty->assign('uniqueId', rand());
if ($calendarInitialParams['canEditAnything']) {
TikiLib::lib('header')
->add_cssfile('themes/base_files/feature_css/calendar.css', 20)
=====================================
lib/wiki-plugins/wikiplugin_trackerlist.php
=====================================
@@ -2283,10 +2283,10 @@ function wikiplugin_trackerlist($data, $params)
Feedback::errorAndDie(tra("This feature is disabled, Please go into the settings and enable the calendar feature"), \Laminas\Http\Response::STATUS_CODE_401);
}
- foreach ($items['data'] as $i => $item) {
+ for ($i = 0; $i < count($items['data']); $i++) {
if (! empty($wiki)) {
- $smarty->assign('fields', $item['field_values']);
- $smarty->assign('item', $item);
+ $smarty->assign('fields', $items['data'][$i]['field_values']);
+ $smarty->assign('item', $items['data'][$i]);
$smarty->assign('wiki', "wiki:$wiki");
$smarty->assign('showpopup', 'n');
try {
@@ -2296,8 +2296,8 @@ function wikiplugin_trackerlist($data, $params)
}
}
if (! empty($tplwiki)) {
- $smarty->assign('fields', $item['field_values']);
- $smarty->assign('item', $item);
+ $smarty->assign('fields', $items['data'][$i]['field_values']);
+ $smarty->assign('item', $items['data'][$i]);
$smarty->assign('wiki', "tplwiki:$tplwiki");
$smarty->assign('showpopup', 'n');
try {
@@ -2306,7 +2306,6 @@ function wikiplugin_trackerlist($data, $params)
$associatedWikiPage[$items['data'][$i]['itemId']] = $se->getMessage();
}
}
-
if (empty($associatedWikiPage[$items['data'][$i]['itemId']])) {
$associatedWikiPage[$items['data'][$i]['itemId']] = $trklib->get_isMain_value($trackerId, $item['itemId']);
}
@@ -2322,12 +2321,13 @@ function wikiplugin_trackerlist($data, $params)
foreach (array_diff(array_keys($takePermNames), $calendarfielddate) as $value) {
$takeKeysOfTitleAndDescriptionOfEvent[] = $value;
}
+
$urlOfFetchingData = [
'title' => array_key_exists($takeKeysOfTitleAndDescriptionOfEvent[0], $takePermNames) ? $takePermNames[$takeKeysOfTitleAndDescriptionOfEvent[0]] : '',
'description' => array_key_exists($takeKeysOfTitleAndDescriptionOfEvent[1], $takePermNames) ? $takePermNames[$takeKeysOfTitleAndDescriptionOfEvent[1]] : '',
'trackerId' => $trackerId,
'beginField' => $takePermNames[$calendarfielddate[0]],
- 'endField' => array_key_exists($calendarfielddate[1], $takePermNames) ? $takePermNames[$calendarfielddate[0]] : null,
+ 'endField' => array_key_exists($calendarfielddate[1], $takePermNames) ? $takePermNames[$calendarfielddate[1]] : null,
'filters' => '',
'maxRecords' => 200,
];
@@ -2345,7 +2345,9 @@ function wikiplugin_trackerlist($data, $params)
'initialView' => 'dayGridMonth',
]
);
+ $moduleCalendarIds = '';
$moduleCalendarFocusdate = date("Y-m-d");
+ $smarty->assign('moduleCalendarIds', $moduleCalendarIds);
$smarty->assign('associatedWikiPage', $associatedWikiPage);
$smarty->assign('moduleCalendarFocusdate', $moduleCalendarFocusdate);
$smarty->assign('urlOfFetchingData', $urlOfFetchingData);
@@ -2374,6 +2376,7 @@ function wikiplugin_trackerlist($data, $params)
$smarty->assign('showpopup', 'n');
$headerlib = TikiLib::lib('header');
$headerlib->add_cssfile('themes/base_files/feature_css/calendar.css', 20);
+ $smarty->assign('uniqueId', rand());
return $smarty->fetch('modules/mod-calendar_new.tpl');
}
if (! empty($wiki)) {
=====================================
modules/mod-func-calendar_new.php
=====================================
@@ -219,7 +219,7 @@ function module_calendar_new($mod_reference, $module_params)
$smarty->assign('returnURL', $current_url);
$smarty->assign('moduleCalendarFocusdate', $moduleCalendarFocusdate);
$smarty->assign('defaultCalendarId', $defaultCalendarId);
-
+ $smarty->assign('uniqueId', rand());
$smarty->assign('show_calendar_module', 'y');
if (isset($save_todate)) {
$_REQUEST['todate'] = $save_todate;
=====================================
src/js/jquery-tiki/tiki-calendar.js
=====================================
@@ -404,3 +404,70 @@ $(function () {
window.location.href = url.toString();
});
});
+
+$.fn.defineParameterOfMultipleCalendar = function (
+ eventCalendarParams,
+ printingParams,
+ divClassContainer,
+ moduleCalendarFocusdate,
+ linkToFindItemsOfCalendar,
+ associatedWikiPage,
+ returnUrl
+) {
+ let paramOfModuleCalendar = eventCalendarParams;
+
+ /**
+ *Since window.moduleCalendar is a global variable, It’s the one we use to contain all the calendars that are currently being displayed,
+ *I first push an empty array into it as preparation
+ *for the container where the calendar will be placed. I do this initially because I also need to know
+ *the index of the calendar I will be using.
+
+ *After that, I create the node where the calendar will be displayed and set the parameters around the
+ *calendar currently being created.
+ */
+
+ window.moduleCalendar.push([]);
+ let takeLength = window.moduleCalendar.length;
+ const calendarContainer = window.moduleCalendar[takeLength - 1];
+
+ var newNode = $('<div class="calendar"></div>').attr("id", "calendar-" + takeLength);
+ const dateOfChangeCalendar = $('<input type="date" class="form-control date-calendar mt-2 mb-2 w-50" >')
+ .attr("id", "date-calendar-" + takeLength)
+ .attr("value", moduleCalendarFocusdate);
+
+ $(divClassContainer)
+ .eq(takeLength - 1)
+ .append(dateOfChangeCalendar);
+ $(divClassContainer)
+ .eq(takeLength - 1)
+ .append(newNode);
+ paramOfModuleCalendar["initialDate"] = $("#date-calendar" + takeLength).val();
+
+ displayCalendarAndPrintButton(takeLength);
+ dateOfChangeCalendar.on("change", function () {
+ paramOfModuleCalendar["initialDate"] = dateOfChangeCalendar.val();
+ let takeIndex = dateOfChangeCalendar.attr("id").split("-")[2];
+ newNode.empty();
+ displayCalendarAndPrintButton(takeIndex);
+ });
+ function displayCalendarAndPrintButton(takeIndex) {
+ const { pdf_export, pdf_warning, pref_print_pdf_from_url } = printingParams;
+ newNode.setupEventCalendar(
+ paramOfModuleCalendar,
+ calendarContainer,
+ "calendar-" + takeIndex,
+ linkToFindItemsOfCalendar,
+ returnUrl,
+ associatedWikiPage
+ );
+ if (pdf_export == "y" && pdf_warning == "n") {
+ const printButton = $('<a href="#" class="text-end d-none" role="button"> Export as PDF</a>').attr("id", "calendar-pdf-btn-" + takeIndex);
+ $(divClassContainer)
+ .eq(takeIndex - 1)
+ .append(printButton);
+ }
+ if (pref_print_pdf_from_url != "none") {
+ newNode.addEventCalendarPrint("#calendar-pdf-btn-" + takeIndex, calendarContainer);
+ }
+ }
+};
=====================================
templates/modules/mod-calendar_new.tpl
=====================================
@@ -19,32 +19,26 @@
{/if}
{if $viewlist neq 'list'}
{jq}
- let paramOfModuleCalendar = {{$eventCalendarParams|json_encode}};
- const moduleCalendarFocusDate = document.getElementById('date-module-calendar');
- paramOfModuleCalendar['initialDate'] = $('#date-module-calendar').val();
- let returnUrl = ('{{$returnURL}}');
- let associatedWikiPage = {{$associatedWikiPage|json_encode}} || null;
- returnUrl = returnUrl.toString();
- let dataToBuildUrl = {{$urlOfFetchingData|json_encode}} || null;
- let urlOfFetchingData = $.service("tracker_calendar", "list", $.extend(dataToBuildUrl, dataToBuildUrl));
+ var printingParams = {pdf_export: '{{$pdf_export}}', pdf_warning: '{{$pdf_warning}}', pref_print_pdf_from_url: '{{$prefs.print_pdf_from_url}}'};
+ var associatedWikiPage = {{$associatedWikiPage|json_encode}} || null;
+ var eventCalendarParams = {{$eventCalendarParams|json_encode}};
+ var returnUrl = ('{{$returnURL}}');
+ var uniqueId = ({{$uniqueId|json_encode}}) || null; // In the case user want to display the same calendar with the same parameter more than one time
+ var moduleCalendarFocusdate = '{{$moduleCalendarFocusdate}}';
- const calendarContainer = [window.moduleCalendar];
- $("#module-calendar").setupEventCalendar({{$eventCalendarParams|json_encode}}, calendarContainer, 'module-calendar',dataToBuildUrl ? urlOfFetchingData : 'tiki-ajax_services.php?controller=calendar&action=list_items&calIds={{$moduleCalendarIds}}', returnUrl, associatedWikiPage);
- moduleCalendarFocusDate.addEventListener('change', () => {
- document.getElementById('module-calendar').innerHTML = "";
- paramOfModuleCalendar['initialDate'] = $('#date-module-calendar').val();
- $("#module-calendar").setupEventCalendar(paramOfModuleCalendar, calendarContainer, 'module-calendar',dataToBuildUrl ? urlOfFetchingData : 'tiki-ajax_services.php?controller=calendar&action=list_items&calIds={{$moduleCalendarIds}}', returnUrl, associatedWikiPage);
- })
- {{if $prefs.print_pdf_from_url neq 'none'}$("#module-calendar").addEventCalendarPrint('#module-calendar-pdf-btn', calendarContainer[0]);{/if}}
+ var dataToBuildUrl = '{{$moduleCalendarIds}}' ? null : {{$urlOfFetchingData|json_encode}};
+ var divClassContainer = ".calendar-container";
+ var urlOfFetchingData = $.service("tracker_calendar", "list", $.extend(dataToBuildUrl, dataToBuildUrl));
+ var linkToFindItemsOfCalendar = dataToBuildUrl ? urlOfFetchingData : 'tiki-ajax_services.php?controller=calendar&action=list_items&calIds=' + '{{$moduleCalendarIds}}'
+ $('.calendar-container').defineParameterOfMultipleCalendar(eventCalendarParams, printingParams, divClassContainer, moduleCalendarFocusdate, linkToFindItemsOfCalendar, associatedWikiPage, returnUrl);
{/jq}
{/if}
{if $pdf_export eq 'y' and $pdf_warning eq 'n'}
- <a id="module-calendar-pdf-btn" href="#" class="text-end d-none" role="button">{icon name='pdf'} {tr}Export as PDF{/tr}</a>
+
{/if}
<div id="test"></div>
{include file="configlinks_calendar.tpl" filterCal="filterModuleCal"}
- <input type="date" value="{$moduleCalendarFocusdate}" id="date-module-calendar">
- <div id='module-calendar'></div>
+ <div class='calendar-container'></div>
{if $viewlist eq 'list'}
{$out}
{/if}
=====================================
templates/tiki-calendar.tpl
=====================================
@@ -62,13 +62,6 @@
{/if}
</div>
{* show jscalendar if set *}
- {if $prefs.feature_jscalendar eq 'y'}
- <div class=" mb-2" style="display: inline-block">
- <form action="{$myurl}" method="post" name="f">
- {jscalendar date="$focusdate" goto="$jscal_url" showtime="n"}
- </form>
- </div>
- {/if}
{if $user and $prefs.feature_user_watches eq 'y' and isset($category_watched) and $category_watched eq 'y'}
<div class="categbar">
@@ -109,15 +102,13 @@
{include file='tiki-calendar_listmode.tpl'}
{else}
{jq}
- const mainCalendarContainer = [window.calendar];
- $("#calendar").setupEventCalendar({{$eventCalendarParams|json_encode}}, mainCalendarContainer);
- {{if $prefs.print_pdf_from_url neq 'none'}$("#calendar").addEventCalendarPrint('#calendar-pdf-btn', mainCalendarContainer[0]);{/if}}
+ let today = new Date();
+ var printingParams = {pdf_export: '{{$pdf_export}}', pdf_warning: '{{$pdf_warning}}', pref_print_pdf_from_url: '{{$prefs.print_pdf_from_url}}'};
+ $('.calendar-container').defineParameterOfMultipleCalendar({{$eventCalendarParams|json_encode}}, printingParams, '.calendar-container', today.toISOString().split('T')[0], undefined, undefined, undefined);
{/jq}
{/if}
- {if $pdf_export eq 'y' and $pdf_warning eq 'n'}
- <a id="calendar-pdf-btn" href="#" class="text-end d-none" role="button">{icon name='pdf'} {tr}Export as PDF{/tr}</a>
- {/if}
- <div id='calendar'></div>
+
+ <div class='calendar-container'></div>
</div>
</div>
=====================================
templates/wiki-plugins/wikiplugin_calendar.tpl
=====================================
@@ -9,30 +9,20 @@
{if $viewlist neq 'list'}
{jq}
- let content = {{$eventCalendarParams|json_encode}};
- const elt = document.getElementById('date-plugin-calendar');
- content['initialDate'] = $('#date-plugin-calendar').val();
- const wikipluginCalendar = [window.pluginCalendar];
- let returnUrlForPlugin = ('{{$returnURL}}');
- returnUrlForPlugin = returnUrlForPlugin.toString();
- $("#plugin-calendar").setupEventCalendar(content, wikipluginCalendar, 'plugin-calendar', 'tiki-ajax_services.php?controller=calendar&action=list_items&calIds={{$pluginCalendarIds}}', returnUrlForPlugin);
- elt.addEventListener('change', () => {
- document.getElementById('plugin-calendar').innerHTML = "";
- content['initialDate'] = $('#date-plugin-calendar').val();
- $("#plugin-calendar").setupEventCalendar(content, wikipluginCalendar, 'plugin-calendar', 'tiki-ajax_services.php?controller=calendar&action=list_items&calIds={{$pluginCalendarIds}}', returnUrlForPlugin);
- })
- {{if $prefs.print_pdf_from_url neq 'none'}$("#plugin-calendar").addEventCalendarPrint('#calendar-pdf-btn', wikipluginCalendar[0]);{/if}}
+ var printingParams = {pdf_export: '{{$pdf_export}}', pdf_warning: '{{$pdf_warning}}', pref_print_pdf_from_url: '{{$prefs.print_pdf_from_url}}'}
+ var uniqueId = ({{$uniqueId|json_encode}}) || null; // In the case user want to display the same calendar with the same parameter more than one time
+ var moduleCalendarFocusdate = '{{$focusdate}}';
+ var divClassContainer = ".calendar-container";
+ var uniqueId = ({{$uniqueId|json_encode}}) || null;
+ var linkToFindItemsOfCalendar = 'tiki-ajax_services.php?controller=calendar&action=list_items&calIds={{$pluginCalendarIds}}'
+ $('.calendar-container').defineParameterOfMultipleCalendar({{$eventCalendarParams|json_encode}}, printingParams, divClassContainer, moduleCalendarFocusdate, linkToFindItemsOfCalendar, undefined, '{{$returnURL}}');
{/jq}
{/if}
- {if $pdf_export eq 'y' and $pdf_warning eq 'n'}
- <a id="calendar-pdf-btn" href="#" class="text-end d-none" role="button">{icon name='pdf'} {tr}Export as PDF{/tr}</a>
- {/if}
+
<div id="test"></div>
{include file="configlinks_calendar.tpl" filterCal="filterPluginCal"}
- {if $viewlist neq 'list'}
- <input type="date" value="{$focusdate}" id="date-plugin-calendar">
- {/if}
- <div id='plugin-calendar'></div>
+
+ <div class='calendar-container'></div>
{if $viewlist eq 'list'}
{$out}
{/if}
=====================================
tiki-setup.php
=====================================
@@ -1049,7 +1049,7 @@ if ($prefs['feature_realtime'] == 'y') {
if ($prefs['feature_calendar'] === 'y') {
$headerlib->add_cssfile(NODE_PUBLIC_DIST_PATH . "/@event-calendar/core/dist/index.css");
- $headerlib->add_js_module('import "@jquery-tiki/tiki-calendar";');
+ $headerlib->add_js_module('import "@jquery-tiki/tiki-calendar"; window.moduleCalendar = [];');
$headerlib->add_js_module('import "@jquery-tiki/fullcalendar_to_pdf";');
}
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/b649e6f6cd9932bcc0185bd904db05de02c730c2
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/b649e6f6cd9932bcc0185bd904db05de02c730c2
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help
_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs