[TikiWiki-commits] [Git][tikiwiki/tiki][28.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 <68f252cc2b081_2ce0d5833212@gitlab-sidekiq-low-urgency-cpu-bound-v2-76b7565557-xtwms.mail>

franck franck kalunga pushed to branch 28.x at Tiki Wiki CMS Groupware / Tiki


Commits:
5e35eeda by franck franck kalunga at 2025-10-17T14:22:43+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

See merge request tikiwiki/tiki!8779

See merge request tikiwiki/tiki!8802

See merge request tikiwiki/tiki!8804

- - - - -


7 changed files:

- doc/devtools/provide_tarballs.sh
- lib/calendar/calendarlib.php
- lib/wiki-plugins/wikiplugin_calendar.php
- modules/mod-func-calendar_new.php
- src/js/jquery-tiki/tiki-calendar.js
- templates/modules/mod-calendar_new.tpl
- templates/wiki-plugins/wikiplugin_calendar.tpl


Changes:

=====================================
doc/devtools/provide_tarballs.sh
=====================================
@@ -75,7 +75,7 @@ fi
 
 echo "Cleanup packaging folder and rebuild"
 rm -rf "${PACKDIR:?}/${BRANCH:?}"
-cp -r ${BASE}/data/"${BRANCH}" ${PACKDIR}
+cp -a ${BASE}/data/"${BRANCH}" ${PACKDIR}
 
 # cleanup
 if [ -d "${PACKDIR}/${BRANCH}" ]; then


=====================================
lib/calendar/calendarlib.php
=====================================
@@ -140,6 +140,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;
@@ -163,6 +164,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/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');
@@ -102,7 +102,7 @@ function wikiplugin_calendar($data, $params)
     $pluginCalendarIds = implode(',', $params['calIds']);
 
     $rawcals = $calendarlib->list_calendars();
-
+    $focusdate = date("Y-m-d");
     switch ($params['viewmode']) {
         case 'week':
             $initialView = 'timeGridWeek';
@@ -120,10 +120,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
@@ -138,14 +138,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)) {


=====================================
src/js/jquery-tiki/tiki-calendar.js
=====================================
@@ -222,22 +222,14 @@ $.fn.setupFullCalendar = function (
                 } else {
                     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",
                             remote: $.service("calendar", "edit_item", { todate: info.date.toUnix(), modal: 1 }),
                             open: function () {
                                 $this.tikiModal();
-
-                                $("form:not(.no-ajax)", this)
-                                    .addClass("no-ajax") // Remove default ajax handling, we replace it
-                                    .on(
-                                        "submit",
-                                        ajaxSubmitEventHandler(function (data) {
-                                            calendarEditSubmit(data, this);
-                                        })
-                                    );
+                                $("form:not(.no-ajax)", this).addClass("no-ajax"); // Remove default ajax handling, we replace it
                             },
                         });
                     } else {


=====================================
templates/modules/mod-calendar_new.tpl
=====================================
@@ -21,15 +21,48 @@
 
                 {if $viewlist neq 'list'}
                     {jq}
+                        let paramOfModuleCalendar = {{$eventCalendarParams|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}}
+                        $("#module-calendar").setupFullCalendar({{$eventCalendarParams|json_encode}}, calendarContainer, 'module-calendar', 'tiki-ajax_services.php?controller=calendar&action=list_items&calIds={{$moduleCalendarIds}}');
+                        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 = {{$eventCalendarParams|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/5e35eeda8d72c1f2e7e474cdea7f561ba39163bf

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/5e35eeda8d72c1f2e7e474cdea7f561ba39163bf
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.