Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #31: Performance with many events #34

Merged
merged 1 commit into from
Sep 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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