Neither timeline nor month view is showing up in node

Created on 16 October 2024, 6 months ago

Problem/Motivation

BAT, BAT_API, BAT_Event, BAT Booking, Fullcalendar - all installed.
I have an event with start and end date with an availability type and a BAT unit set.
Within a node I have a BAT Calendar Unit Reference with a unit and event type set.
Both units - in the event and in the node are the same.

I neither get the timeline nor the calendar view showing up.
The error in the console is:

drupal.js?v=10.3.2:64 Uncaught TypeError: $(...).once is not a function
    at Object.attach (bat_calendar_reference.js?v=10.3.2:13:17)
    at drupal.js?v=10.3.2:166:24
    at Array.forEach (<anonymous>)
    at Drupal.attachBehaviors (drupal.js?v=10.3.2:162:34)
    at big_pipe.js?v=10.3.2:153:10
    at big_pipe.js?v=10.3.2:184:3

Steps to reproduce

I used simpletest.me for a clean install with BAT and BAT API and depending modules and got the same problem.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

💬 Support request
Status

Active

Version

10.0

Component

Code

Created by

🇫🇮Finland Nchase

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @Nchase
  • Status changed to Needs work 3 months ago
  • 🇫🇮Finland Nchase

    Same on a fresh Drupal 11 installation. Additionally I get an error when adding events via admin/bat/events/event/add/availability_daily

  • First commit to issue fork.
  • 🇵🇱Poland dlevchik Poznan, Poland

    This was the last jQuery.once left since Drupal 10 update. Moved it to core/once function

  • 🇮🇹Italy afagioli Rome

    This issue is being worked on latest dev, with a more recent Fullcalendar version
    Please do not timeline view is now only available with commercial license

  • 🇮🇹Italy afagioli Rome

    In latest 11.1.x we have now a more recent Fullcalendar version.

    Fullcalendar Timeline may require a Premium release. See https://fullcalendar.io/license

  • Status changed to Needs review 22 days ago
  • 🇫🇮Finland Nchase

    Ok, So it seems like the bat_calendar_reference.js is

          $('.cal').once().each(function () {
            var lastSource;
            var cal_id = $(this).attr('id');
    
            $(this).fullCalendar({

    which when changed to something like

    once('bat-calendar', '.cal', context).forEach(function (el) {
            var lastSource;
            var cal_id = $(this).attr('id');
    
            $(el).fullCalendar({

    solves the JS error in the console but then all the settings from /admin/bat/config/fullcalendar are not read

    In order to just see if it works I hardcoded the options:

    (function ($, Drupal, once) {
      Drupal.behaviors.bat_calendar_reference = {
        attach: function (context) {
          const businessHours = {
            startTime: '00:00',
            endTime: '24:00',
            daysOfWeek: [0, 1, 2, 3, 4, 5, 6],
          };
    
          once('bat-calendar', '.cal', context).forEach(function (el) {
            $(el).fullCalendar({
              schedulerLicenseKey: 'GPL-My-Project-Is-Open-Source',
              themeSystem: 'standard',
              locale: 'en',
              editable: false,
              selectable: false,
              nowIndicator: true,
              businessHours: businessHours,
              initialView: 'dayGridMonth', // or 'timeGridWeek', etc.
              events: [], // will be filled automatically if Views integration is working
            });
          });
        }
      };
    })(jQuery, Drupal, once);
    

    and now the Calendar is visible. Could it be that In Drupal 10+, once is an ES6 utility and not part of jQuery?

  • 🇮🇹Italy afagioli Rome

    Currently working on this, with events produced by bat_api

    Thanks for contributing.

  • 🇮🇹Italy afagioli Rome

    fixed in latest dev. Feedback welcome

Production build 0.71.5 2024