Skip to content

Commit

Permalink
Issue #31: Performance with many events (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
indigoxela committed Sep 12, 2023
1 parent 8b75bbb commit 4f5ebc1
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions views/fullcalendar_views_style_calendar.inc
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ class FullcalendarViewsStyleCalendar extends views_plugin_style {
parent::options_form($form, $form_state);

$date_fields = $this->getDateFieldCandidates();
if (empty($date_fields)) {
backdrop_set_message(t('Fullcalendar views need a supported date field.'), 'warning', FALSE);
}
$mappings = $this->options['field_mapping'];
$setup = $this->options['calendar_setup'];
$all_fields = array('' => t('<none>')) + $this->display->handler->get_field_labels();
Expand All @@ -74,9 +71,8 @@ class FullcalendarViewsStyleCalendar extends views_plugin_style {
$form['field_mapping']['date'] = array(
'#type' => 'select',
'#title' => t('Date field'),
'#options' => $date_fields,
'#options' => array('' => t('None (empty calendar)')) + $date_fields,
'#default_value' => $mappings['date'],
'#required' => TRUE,
'#description' => t('Supported types are core Date fields, Resource timeslots, Repeating dates, and all timestamps natively handled by views.'),
);
$form['field_mapping']['title'] = array(
Expand Down Expand Up @@ -259,26 +255,18 @@ class FullcalendarViewsStyleCalendar extends views_plugin_style {
return NULL;
}

// A calendar always needs dates.
$date_fields = $this->getDateFieldCandidates();
if (empty($date_fields)) {
// Show the message only in live preview, not on possibly public pages.
if (!empty($this->view->live_preview)) {
backdrop_set_message(t('No date field available.'), 'warning');
}
return NULL;
}

global $language;
$view = $this->view;
$field = $view->field;
$options = $this->options;

$events = array();
// Render the fields with all token replacements and overrides.
$this->render_fields($view->result);
foreach ($view->result as $index => $row) {
$events[$index] = $this->renderRow($view, $index);
if (!empty($options['field_mapping']['date'])) {
// Render the fields with all token replacements and overrides.
$this->render_fields($view->result);
foreach ($view->result as $index => $row) {
$events[$index] = $this->renderRow($view, $index);
}
}

$settings = $this->buildCalendarSettings();
Expand Down

0 comments on commit 4f5ebc1

Please sign in to comment.