osseed / com.osseed.eventcalendar

CiviCRM Event Calendar
GNU General Public License v3.0
11 stars 37 forks source link

Support request - trying to find how to set initial view to week rather than month... #80

Closed HeneryH closed 3 years ago

HeneryH commented 4 years ago

Looking at the code here and the FullCalendar docs, it seems like this is using the "Initialize with Script Tags" method to initialize the calendar as described in Initialize Globals

Not exactly one for one but in templates/CRM/EventCalendar/Page/ShowEvents.tpl I see variables that look similar to the docs. Taking a guess, I tried to put the new variable "initialView" into this code using various formats but they don't seem to be working.

function buildCalendar( ) {
  var events_data = {/literal}{$civicrm_events}{literal};
  var jsonStr = JSON.stringify(events_data);
  var showTime = events_data.timeDisplay;
  var weekStartDay = {/literal}{$weekBeginDay}{literal};

  cj('#calendar').fullCalendar({
    eventSources: [
      { events: events_data.events,}
    ],
    displayEventTime: showTime ? 1 : 0,
    firstDay:weekStartDay,
    timeFormat: 'h(:mm)A',
/*  initialView: 'dayGridWeek', */
    initialView: 'week',
    header: {
      left: 'prev,next today',
      center: 'title',
      right: 'month,agendaWeek,agendaDay'
    },

    eventRender: function eventRender( event, element, view ) {
      if(event.eventType && events_data.isfilter == "1" ) {
        return ['all', event.eventType].indexOf(cj('#event_selector').val()) >= 0
      }
    }
  });

Can anyone help me identify where in this module the equivalent of

  var calendar = new Calendar(calendarEl, {
    plugins: [ dayGridPlugin ]
  });

  calendar.render();

or

        var calendarEl = document.getElementById('calendar');
        var calendar = new FullCalendar.Calendar(calendarEl, {
          initialView: 'dayGridMonth'
        });

might be hidden? I am trying to set my initial view to week or agenda week. Once I figure out how to hard-code it I can look into making it a user option.

Thanks.

HeneryH commented 3 years ago

Bump, please anyone? I would like to demo this and the initial view being one of the weekly format instead of the monthly format would be incredibly helpful.

HeneryH commented 3 years ago

Ah!!!!!! Got it. This module is using the V3 version of the FullCalendar library and I was looking at the V5 docs. The names of the views have changed.