[TikiWiki-commits] [Git][tikiwiki/tiki][26.x] [FIX] Fix module calendar_new and wikiplugin-calendar feature
"franck franck kalunga \(@francksfkal\) via TikiWiki-cvs" <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <68f95e1be96d5_2ce1b68580f9@gitlab-sidekiq-low-urgency-cpu-bound-v2-6c5ddc6df8-dswrn.mail> |
franck franck kalunga pushed to branch 26.x at Tiki Wiki CMS Groupware / Tiki
Commits:
6c1d007e by franck franck kalunga at 2025-10-22T22:38:51+00:00
[FIX] Fix module calendar_new and wikiplugin-calendar feature
---
* [FIX] Fix module calendar_new and wikiplugin-calendar feature
---
* [FIX] Fix module calendar_new and wikiplugin-calendar feature
---
* [FIX] Fix module calendar_new and wikiplugin-calendar feature
---
* [FIX] Fix module calendar_new and wikiplugin-calendar feature
---
* [FIX] Fix module calendar_new and wikiplugin-calendar feature
See merge request tikiwiki/tiki!8779
See merge request tikiwiki/tiki!8802
See merge request tikiwiki/tiki!8804
See merge request tikiwiki/tiki!8806
See merge request tikiwiki/tiki!8838
- - - - -
6 changed files:
- lib/calendar/calendarlib.php
- lib/jquery_tiki/tiki-calendar.js
- lib/wiki-plugins/wikiplugin_calendar.php
- modules/mod-func-calendar_new.php
- templates/modules/mod-calendar_new.tpl
- templates/wiki-plugins/wikiplugin_calendar.tpl
Changes:
=====================================
lib/calendar/calendarlib.php
=====================================
@@ -129,6 +129,7 @@ class CalendarLib extends TikiLib
{
global $prefs;
$canEditAnything = false;
+ $calendars = [];
foreach ($rawcalsData as $calendar) {
$calendar['perms'] = Perms::get([ 'type' => 'calendar', 'object' => $calendar['calendarId']]);
$calendars[$calendar['calendarId']] = $calendar;
@@ -152,6 +153,7 @@ class CalendarLib extends TikiLib
'slotDuration' => '00:' . str_pad($prefs['calendar_timespan'], 2, '0', STR_PAD_LEFT),
'initialDate' => date("Y-m-d"),
'canEditAnything' => $canEditAnything,
+ 'calendars' => $calendars,
];
}
=====================================
lib/jquery_tiki/tiki-calendar.js
=====================================
@@ -102,6 +102,7 @@ $.fn.setupFullCalendar = function (
return event;
},
eventDidMount: function (arg) {
+ $(calendarEl).tikiModal();
const event = arg.event;
const element = $(arg.el);
const dayGrid = $('.fc-daygrid-event').length;
@@ -205,7 +206,7 @@ $.fn.setupFullCalendar = function (
dateClick: function (info) {
let $this = $(info.dayEl).tikiModal(" ");
const countCals = $("#filtercal ul li").length;
- if (countCals >= 1) {
+ if (countCals >= 1 || targetId != "calendar") {
$.openModal({
title: tr("New event"),
size: "modal-lg",
@@ -213,11 +214,7 @@ $.fn.setupFullCalendar = function (
open: function () {
$this.tikiModal();
- $("form:not(.no-ajax)", this)
- .addClass('no-ajax') // Remove default ajax handling, we replace it
- .submit(ajaxSubmitEventHandler(function (data) {
- calendarEditSubmit(data, this);
- }));
+ $("form:not(.no-ajax)", this).addClass('no-ajax');
}
});
} else {
=====================================
lib/wiki-plugins/wikiplugin_calendar.php
=====================================
@@ -80,7 +80,7 @@ function wikiplugin_calendar_info()
function wikiplugin_calendar($data, $params)
{
- global $prefs, $tiki_p_admin, $tiki_p_view_calendar;
+ global $prefs, $tiki_p_admin, $tiki_p_view_calendar, $tikiroot;
global $dc, $user;
$smarty = TikiLib::lib('smarty');
@@ -126,6 +126,7 @@ function wikiplugin_calendar($data, $params)
$rawcals['data'] = array_filter($rawcals['data'], fn($current) => in_array($current['calendarId'], $params['calIds']));
+ $focusdate = date("Y-m-d");
switch ($params['viewmode']) {
case 'week':
$initialView = 'timeGridWeek';
@@ -143,10 +144,10 @@ function wikiplugin_calendar($data, $params)
$viewend = $viewstart + 90 * 86400 - 1; // 1 month approx
$defaultCalendarId = $params['calIds'][0];
- $calendars = [];
$calendarInitialParams = $calendarlib->generalParamsOfCalendar($rawcals['data']);
$calendarInitialParams['initialView'] = $initialView;
+ $calendars = $calendarInitialParams['calendars'];
$smarty->assign(
'fullCalendarParams',
$calendarInitialParams
@@ -161,14 +162,15 @@ function wikiplugin_calendar($data, $params)
$smarty->assign('pluginCalendarIds', $pluginCalendarIds);
$smarty->assign('displayedcals', $params['calIds']);
$thiscal = [];
- $checkedCalIds = [];
+ $checkedCalIds = $params['calIds'];
if (isset($_REQUEST["calIds"]) and is_array($_REQUEST["calIds"]) and count($_REQUEST["calIds"])) {
$defaultCalendarId = $_REQUEST["calIds"][0];
}
- $smarty->assign_by_ref('checkedCalIds', $checkedCalIds);
+ $smarty->assign_by_ref('checkedCalIds', $params['calIds']);
$smarty->assign('calendars', $calendars);
+ $smarty->assign('focusdate', $focusdate);
$smarty->assign('viewlist', $params['viewlist']);
$out = '';
=====================================
modules/mod-func-calendar_new.php
=====================================
@@ -145,16 +145,17 @@ function module_calendar_new($mod_reference, $module_params)
if (empty($rawcals['data'])) {
Feedback::errorAndDie(tra("You do not have permission to view the calendar"), \Laminas\Http\Response::STATUS_CODE_401);
}
-
+ $moduleCalendarFocusdate = date("Y-m-d");
$rawcals['data'] = array_filter($rawcals['data'], fn($current) => in_array($current['calendarId'], $calIds));
- $calendars = [];
$calendarInitialParams = $calendarlib->generalParamsOfCalendar($rawcals['data']);
$calendarInitialParams['initialView'] = $initialView;
+ $calendars = $calendarInitialParams['calendars'];
$smarty->assign(
'eventCalendarParams',
$calendarInitialParams
);
+ $smarty->assign('moduleCalendarFocusdate', $moduleCalendarFocusdate);
$smarty->assign('moduleCalendarIds', $moduleCalendarIds);
if ($calendarInitialParams['canEditAnything']) {
TikiLib::lib('header')
@@ -182,6 +183,9 @@ function module_calendar_new($mod_reference, $module_params)
}
$smarty->assign('name', 'calendar_new');
+ $smarty->assign('calendars', $calendars);
+ $smarty->assign_by_ref('checkedCalIds', $calIds);
+
$smarty->assign('show_calendar_module', 'y');
if (isset($save_todate)) {
=====================================
templates/modules/mod-calendar_new.tpl
=====================================
@@ -21,15 +21,48 @@
{if $viewlist neq 'list'}
{jq}
+ let paramOfModuleCalendar = {{$fullCalendarParams|json_encode}};
+ const moduleCalendarFocusDate = document.getElementById('date-module-calendar');
+ paramOfModuleCalendar['initialDate'] = $('#date-module-calendar').val();
+
const calendarContainer = [window.moduleCalendar];
$("#module-calendar").setupFullCalendar({{$fullCalendarParams|json_encode}}, calendarContainer, 'module-calendar', 'tiki-ajax_services.php?controller=calendar&action=list_items&calIds={{$moduleCalendarIds}}');
- {{if $prefs.print_pdf_from_url neq 'none'}$("#module-calendar").addFullCalendarPrint('#module-calendar-pdf-btn', calendarContainer[0]);{/if}}
+ moduleCalendarFocusDate.addEventListener('change', () => {
+ document.getElementById('module-calendar').innerHTML = "";
+ paramOfModuleCalendar['initialDate'] = $('#date-module-calendar').val();
+ $("#module-calendar").setupFullCalendar(paramOfModuleCalendar, calendarContainer, 'module-calendar', 'tiki-ajax_services.php?controller=calendar&action=list_items&calIds={{$moduleCalendarIds}}');
+ })
+ {{if $prefs.print_pdf_from_url neq 'none'}$("#module-calendar").addEventCalendarPrint('#module-calendar-pdf-btn', calendarContainer[0]);{/if}}
{/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>
+ <div id="configlinks" class="mb-3 text-end">
+ <div id="configlinks" class="mb-3 text-end">
+ {if count($checkedCalIds)}
+ {$maxCalsForButton = 20}
+ {if count($checkedCalIds) > $maxCalsForButton}<select size="5">{/if}
+ {foreach $checkedCalIds as $checkedCalId}
+ {if $calendars}
+ {$thiscustombgcolor = $calendars[$checkedCalId].custombgcolor}
+ {$thiscustomfgcolor = $calendars[$checkedCalId].customfgcolor}
+ {$thiscalendarsname = $calendars[$checkedCalId].displayName|escape}
+ {if count($checkedCalIds) > $maxCalsForButton}
+ <option style="background:#{$thiscustombgcolor};color:#{$thiscustomfgcolor};" onclick="toggle('filtercal')">
+ {$thiscalendarsname}
+ </option>
+ {else}
+ {button href="{$checkedCalId|sefurl:'calendar'}" _style="background:#$thiscustombgcolor;color:#$thiscustomfgcolor;border:1px solid #$thiscustomfgcolor; " _text="{$thiscalendarsname}" _class='btn btn-sm me-2 mt-2' _icon_name='calendar'}
+ {/if}
+ {/if}
+ {/foreach}
+ {if count($checkedCalIds) > $maxCalsForButton}</select>{/if}
+ {/if}
+ </div>
+ </div>
+ <input type="date" value="{$moduleCalendarFocusdate}" id="date-module-calendar">
<div id='module-calendar'></div>
{if $viewlist eq 'list'}
{$out}
=====================================
templates/wiki-plugins/wikiplugin_calendar.tpl
=====================================
@@ -1,5 +1,5 @@
-<div>
- {if $tiki_p_add_events eq 'y'}
+<div class="border border-secondary p-2">
+ {if $tiki_p_add_events eq 'y' and $viewlist neq 'list'}
<a href="{bootstrap_modal controller='calendar' action='edit_item' size='modal-lg' defaultCalendarId=$defaultCalendarId}" class="btn btn-primary">{icon name='create'} {tr}Add Event{/tr}</a>
{/if}
{if count($calendars) >= 1 && $viewnavbar eq 'y'}
@@ -8,15 +8,50 @@
{if $viewlist neq 'list'}
{jq}
+ let content = {{$fullCalendarParams|json_encode}};
+ const elt = document.getElementById('date-plugin-calendar');
+ content['initialDate'] = $('#date-plugin-calendar').val();
const wikipluginCalendar = [window.pluginCalendar]
- $("#plugin-calendar").setupFullCalendar({{$fullCalendarParams|json_encode}}, wikipluginCalendar, 'plugin-calendar', 'tiki-ajax_services.php?controller=calendar&action=list_items&calIds={{$pluginCalendarIds}}');
- {{if $prefs.print_pdf_from_url neq 'none'}$("#calendar").addEventCalendarPrint('#calendar-pdf-btn', wikipluginCalendar[0]);{/if}}
+ $("#plugin-calendar").setupFullCalendar(content, wikipluginCalendar, 'plugin-calendar', 'tiki-ajax_services.php?controller=calendar&action=list_items&calIds={{$pluginCalendarIds}}');
+ elt.addEventListener('change', () => {
+ document.getElementById('plugin-calendar').innerHTML = "";
+ content['initialDate'] = $('#date-plugin-calendar').val();
+ $("#plugin-calendar").setupFullCalendar(content, wikipluginCalendar, 'plugin-calendar', 'tiki-ajax_services.php?controller=calendar&action=list_items&calIds={{$pluginCalendarIds}}');
+ })
+ {{if $prefs.print_pdf_from_url neq 'none'}$("#plugin-calendar").addEventCalendarPrint('#calendar-pdf-btn', wikipluginCalendar[0]);{/if}}
{/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>
+ <div id="configlinks" class="mb-3 text-end">
+ <div id="configlinks" class="mb-3 text-end">
+ {if count($checkedCalIds)}
+ {$maxCalsForButton = 20}
+ {if count($checkedCalIds) > $maxCalsForButton}<select size="5">{/if}
+ {foreach $checkedCalIds as $checkedCalId}
+ {if $calendars}
+ {$thiscustombgcolor = $calendars[$checkedCalId].custombgcolor}
+ {$thiscustomfgcolor = $calendars[$checkedCalId].customfgcolor}
+ {$thiscalendarsname = $calendars[$checkedCalId].displayName|escape}
+ {if count($checkedCalIds) > $maxCalsForButton}
+ <option style="background:#{$thiscustombgcolor};color:#{$thiscustomfgcolor};" onclick="toggle('filtercal')">
+ {$thiscalendarsname}
+ </option>
+ {else}
+ {button href="{$checkedCalId|sefurl:'calendar'}" _style="background:#$thiscustombgcolor;color:#$thiscustomfgcolor;border:1px solid #$thiscustomfgcolor; " _text="{$thiscalendarsname}" _class='btn btn-sm me-2 mt-2' _icon_name='calendar'}
+ {/if}
+ {/if}
+ {/foreach}
+ {if count($checkedCalIds) > $maxCalsForButton}</select>{/if}
+ {/if}
+ </div>
+ </div>
+ {if $viewlist neq 'list'}
+ <input type="date" value="{$focusdate}" id="date-plugin-calendar">
+ {/if}
+
<div id='plugin-calendar'></div>
{if $viewlist eq 'list'}
{$out}
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/6c1d007e3a263c0b86a0901dc8c26b5095be4c61
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/6c1d007e3a263c0b86a0901dc8c26b5095be4c61
You're receiving this email because of your account on gitlab.com.
_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs