diff --git a/.travis.yml b/.travis.yml
index 7f01b737c..5a7241d0e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,6 +8,10 @@ php:
- 7.1
- 7.2
+matrix:
+ allow_failures:
+ - php: 7.2
+
addons:
chrome: stable
diff --git a/modules/bat_event/bat_event.info.yml b/modules/bat_event/bat_event.info.yml
index 682cbdef9..e9ee5a623 100644
--- a/modules/bat_event/bat_event.info.yml
+++ b/modules/bat_event/bat_event.info.yml
@@ -6,3 +6,4 @@ package: bat
dependencies:
- bat_unit
+ - datetime_range
diff --git a/modules/bat_event/bat_event.install b/modules/bat_event/bat_event.install
index 796241dd8..7bae19517 100644
--- a/modules/bat_event/bat_event.install
+++ b/modules/bat_event/bat_event.install
@@ -6,6 +6,8 @@
* the entity types.
*/
+use Drupal\Core\Database\Database;
+
/**
* Implements hook_requirements().
*/
@@ -34,3 +36,37 @@ function bat_event_requirements($phase) {
];
}
}
+
+/**
+ * Migrate event's dates on the new field.
+ */
+function bat_event_update_8001() {
+ $events = db_select('event', 'e')
+ ->fields('e', [])
+ ->condition('start', '', '<>')
+ ->execute()
+ ->fetchAll();
+
+ foreach ($events as $event) {
+ $event_object = bat_event_load($event->id);
+
+ $start_date = new DateTime();
+ $start_date->setTimestamp($event->start);
+
+ $end_date = new DateTime();
+ $end_date->setTimestamp($event->end);
+
+ $event_object->setStartDate($start_date);
+ $event_object->setEndDate($end_date);
+
+ $event_object->save();
+ }
+}
+
+/**
+ * Drop old "start" and "end" columns on event table.
+ */
+function bat_event_update_8002() {
+ Database::getConnection()->schema()->dropField('event', 'start');
+ Database::getConnection()->schema()->dropField('event', 'end');
+}
diff --git a/modules/bat_event/bat_event.module b/modules/bat_event/bat_event.module
index baebd5e30..2c5833987 100644
--- a/modules/bat_event/bat_event.module
+++ b/modules/bat_event/bat_event.module
@@ -78,6 +78,60 @@ function bat_event_type_add_event_state_reference($entity) {
}
}
+/**
+ * Create "Event Dates" field.
+ */
+function bat_event_type_add_event_dates_field($entity) {
+ $entity_info = \Drupal::entityTypeManager()->getDefinition($entity->target_entity_type);
+ $field_name = 'event_dates';
+
+ $field_storage = FieldStorageConfig::loadByName('bat_event', $field_name);
+ $field = FieldConfig::loadByName('bat_event', $entity->id(), $field_name);
+
+ if (empty($field_storage)) {
+ $field_storage = FieldStorageConfig::create([
+ 'field_name' => $field_name,
+ 'entity_type' => 'bat_event',
+ 'type' => 'daterange',
+ 'cardinality' => 1,
+ 'locked' => 1,
+ 'settings' => [
+ 'datetime_type' => 'datetime',
+ ],
+ ]);
+ $field_storage->save();
+ }
+
+ if (empty($field)) {
+ $field = FieldConfig::create([
+ 'field_storage' => $field_storage,
+ 'entity_type' => 'bat_event',
+ 'label' => 'Event Dates',
+ 'bundle' => $entity->id(),
+ 'required' => FALSE,
+ 'settings' => [
+ 'datetime_type' => 'datetime',
+ ],
+ ]);
+ $field->save();
+
+ $form_display = \Drupal::entityTypeManager()->getStorage('entity_form_display')->load('bat_event.' . $entity->id() . '.default');
+ if (!$form_display) {
+ $form_display = EntityFormDisplay::create([
+ 'targetEntityType' => 'bat_event',
+ 'bundle' => $entity->id(),
+ 'mode' => 'default',
+ 'status' => TRUE,
+ ]);
+ }
+ $form_display->setComponent($field_name, [
+ 'type' => 'daterange_default',
+ 'weight' => 1,
+ ]);
+ $form_display->save();
+ }
+}
+
/**
* Create fields of type 'Entity Reference' to reference the target entity.
*
diff --git a/modules/bat_event/src/Entity/Event.php b/modules/bat_event/src/Entity/Event.php
index 404968117..a3fec1c83 100644
--- a/modules/bat_event/src/Entity/Event.php
+++ b/modules/bat_event/src/Entity/Event.php
@@ -145,30 +145,38 @@ public function setUnit(UnitInterface $unit) {
* {@inheritdoc}
*/
public function getStartDate() {
- $date = new \DateTime();
- return $date->setTimestamp($this->get('start')->value);
+ $date = new \DateTime($this->get('event_dates')->value);
+ return $date;
}
/**
* {@inheritdoc}
*/
public function getEndDate() {
- $date = new \DateTime();
- return $date->setTimestamp($this->get('end')->value);
+ $date = new \DateTime($this->get('event_dates')->end_value);
+ return $date;
}
/**
* {@inheritdoc}
*/
public function setStartDate(\DateTime $date) {
- $this->set('start', $date->getTimestamp());
+ $value = [
+ 'value' => $date->format('Y-m-d\TH:i:00'),
+ 'end_value' => $this->getEndDate()->format('Y-m-d\TH:i:00'),
+ ];
+ $this->set('event_dates', $value);
}
/**
* {@inheritdoc}
*/
public function setEndDate(\DateTime $date) {
- $this->set('end', $date->getTimestamp());
+ $value = [
+ 'value' => $this->getStartDate()->format('Y-m-d\TH:i:00'),
+ 'end_value' => $date->format('Y-m-d\TH:i:00'),
+ ];
+ $this->set('event_dates', $value);
}
/**
@@ -203,7 +211,7 @@ public function save() {
$this->batStoreSave($unit,
$entity_original->getStartDate(),
- $entity_original->getEndDate(),
+ $entity_original->getEndDate()->sub(new \DateInterval('PT1M')),
$event_type->id(),
$event_type->getEventGranularity(),
$unit->getDefaultValue(),
@@ -250,7 +258,7 @@ public function save() {
$this->batStoreSave($unit,
$this->getStartDate(),
- $this->getEndDate(),
+ $this->getEndDate()->sub(new \DateInterval('PT1M')),
$event_type->id(),
$event_type->getEventGranularity(),
$event_value,
@@ -311,36 +319,6 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
->setLabel(t('Changed'))
->setDescription(t('The time that the entity was last edited.'));
- $fields['start'] = BaseFieldDefinition::create('created')
- ->setLabel(t('Start Date'))
- ->setDescription(t('The time that this event starts.'))
- ->setDisplayOptions('view', [
- 'label' => 'hidden',
- 'type' => 'timestamp',
- 'weight' => 0,
- ])
- ->setDisplayOptions('form', [
- 'type' => 'datetime_timestamp',
- 'weight' => 0,
- ])
- ->setDisplayConfigurable('form', TRUE)
- ->setRequired(TRUE);
-
- $fields['end'] = BaseFieldDefinition::create('created')
- ->setLabel(t('End Date'))
- ->setDescription(t('The time that this event ends.'))
- ->setDisplayOptions('view', [
- 'label' => 'hidden',
- 'type' => 'timestamp',
- 'weight' => 1,
- ])
- ->setDisplayOptions('form', [
- 'type' => 'datetime_timestamp',
- 'weight' => 1,
- ])
- ->setDisplayConfigurable('form', TRUE)
- ->setRequired(TRUE);
-
$fields['type'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Type'))
->setDescription(t('The event type.'))
diff --git a/modules/bat_event/src/Entity/EventType.php b/modules/bat_event/src/Entity/EventType.php
index 9c78357fd..dbf862f9c 100644
--- a/modules/bat_event/src/Entity/EventType.php
+++ b/modules/bat_event/src/Entity/EventType.php
@@ -96,6 +96,9 @@ public function save() {
// Create all tables necessary for this Event Type.
bat_event_create_event_type_schema($this->id());
+ // Create a field of type "Date range" for event dates.
+ bat_event_type_add_event_dates_field($this);
+
// Create a field of type 'Entity Reference' to reference a Bat Unit.
bat_event_type_add_target_entity_field($this);
diff --git a/modules/bat_event/src/Entity/EventViewsData.php b/modules/bat_event/src/Entity/EventViewsData.php
index 6fc8e7c55..f4672b55a 100644
--- a/modules/bat_event/src/Entity/EventViewsData.php
+++ b/modules/bat_event/src/Entity/EventViewsData.php
@@ -27,30 +27,6 @@ public function getViewsData() {
'help' => $this->t('The Event ID.'),
];
- $data['event']['start_date'] = [
- 'title' => $this->t('Start Date'),
- 'help' => $this->t("A event's start date."),
- 'field' => [
- 'float' => TRUE,
- 'id' => 'bat_event_handler_date_field',
- 'click sortable' => TRUE,
- ],
- 'filter' => [
- 'id' => 'bat_event_handler_date_filter',
- ],
- ];
- $data['event']['end_date'] = [
- 'title' => $this->t('End Date'),
- 'help' => $this->t("A event's end date."),
- 'field' => [
- 'float' => TRUE,
- 'id' => 'bat_event_handler_date_field',
- 'click sortable' => TRUE,
- ],
- 'filter' => [
- 'id' => 'bat_event_handler_date_filter',
- ],
- ];
$data['event']['type']['field'] = [
'title' => $this->t('Event Type'),
'help' => $this->t('The event type label.'),
diff --git a/modules/bat_event/src/Entity/Form/EventForm.php b/modules/bat_event/src/Entity/Form/EventForm.php
index d75d03fb2..03b434ff9 100644
--- a/modules/bat_event/src/Entity/Form/EventForm.php
+++ b/modules/bat_event/src/Entity/Form/EventForm.php
@@ -91,24 +91,23 @@ public function buildForm(array $form, FormStateInterface $form_state) {
$form['created']['#group'] = 'author';
}
- if ($entity->isNew()) {
- $form['start']['widget'][0]['value']['#default_value'] = '';
- $form['end']['widget'][0]['value']['#default_value'] = '';
+ if ($event_type->getEventGranularity() == 'bat_daily') {
+ $form['event_dates']['widget'][0]['value']['#date_time_element'] = 'none';
+ $form['event_dates']['widget'][0]['end_value']['#date_time_element'] = 'none';
}
else {
- $form['end']['widget'][0]['value']['#default_value']->add(new \DateInterval('PT1M'));
+ $form['event_dates']['widget'][0]['value']['#date_increment'] = 60;
+ $form['event_dates']['widget'][0]['end_value']['#date_increment'] = 60;
}
- unset($form['start']['widget'][0]['value']['#description']);
- unset($form['end']['widget'][0]['value']['#description']);
+ $form['event_dates']['widget'][0]['value']['#date_timezone'] = 'UTC';
+ $form['event_dates']['widget'][0]['end_value']['#date_timezone'] = 'UTC';
- if ($event_type->getEventGranularity() == 'bat_daily') {
- $form['start']['widget'][0]['value']['#date_time_element'] = 'none';
- $form['end']['widget'][0]['value']['#date_time_element'] = 'none';
+ if (isset($form['event_dates']['widget'][0]['value']['#default_value'])) {
+ $form['event_dates']['widget'][0]['value']['#default_value']->setTimezone(new \DateTimeZone('UTC'));
}
- else {
- $form['start']['widget'][0]['value']['#date_increment'] = 60;
- $form['end']['widget'][0]['value']['#date_increment'] = 60;
+ if (isset($form['event_dates']['widget'][0]['end_value']['#default_value'])) {
+ $form['event_dates']['widget'][0]['end_value']['#default_value']->setTimezone(new \DateTimeZone('UTC'));
}
if (\Drupal::request()->query->get(MainContentViewSubscriber::WRAPPER_FORMAT) == 'drupal_ajax') {
@@ -130,12 +129,12 @@ public function validateForm(array &$form, FormStateInterface $form_state) {
$values = $form_state->getValues();
- $start_date = new \DateTime($values['start'][0]['value']->format('Y-m-d H:i:s'));
- $end_date = new \DateTime($values['end'][0]['value']->format('Y-m-d H:i:s'));
+ $start_date = new \DateTime($values['event_dates'][0]['value']->format('Y-m-d H:i:s'));
+ $end_date = new \DateTime($values['event_dates'][0]['end_value']->format('Y-m-d H:i:s'));
// The end date must be greater or equal than start date.
if ($end_date < $start_date) {
- $form_state->setErrorByName('end', t('End date must be on or after the start date.'));
+ $form_state->setErrorByName('event_dates', t('End date must be on or after the start date.'));
}
$event_type = bat_event_type_load($this->entity->bundle());
@@ -183,17 +182,14 @@ public function save(array $form, FormStateInterface $form_state) {
$event = $this->entity;
$event_type = bat_event_type_load($event->bundle());
- $end_date = $event->getEndDate();
if ($event_type->getEventGranularity() == 'bat_daily') {
$start_date = $event->getStartDate()->setTime(0, 0);
$event->setStartDate($start_date);
- $end_date->setTime(0, 0);
+ $end_date = $event->getEndDate()->setTime(0, 0);
+ $event->setEndDate($end_date);
}
- $end_date->sub(new \DateInterval('PT1M'));
- $event->setEndDate($end_date);
-
$status = $event->save();
switch ($status) {
diff --git a/modules/bat_event/src/EventListBuilder.php b/modules/bat_event/src/EventListBuilder.php
index 6983f8a94..9e5b76022 100644
--- a/modules/bat_event/src/EventListBuilder.php
+++ b/modules/bat_event/src/EventListBuilder.php
@@ -84,13 +84,13 @@ public function buildHeader() {
],
'start_date' => [
'data' => $this->t('Start Date'),
- 'field' => 'start',
+ 'field' => 'event_dates',
'specifier' => 'start',
'class' => [RESPONSIVE_PRIORITY_LOW],
],
'end_date' => [
'data' => $this->t('End Date'),
- 'field' => 'end',
+ 'field' => 'event_dates',
'specifier' => 'end',
'class' => [RESPONSIVE_PRIORITY_LOW],
],
@@ -112,7 +112,7 @@ public function buildRow(EntityInterface $entity) {
$row['id'] = $entity->id();
$row['start_date'] = $entity->getStartDate()->format($date_format);
- $row['end_date'] = $entity->getEndDate()->add(new \DateInterval('PT1M'))->format($date_format);
+ $row['end_date'] = $entity->getEndDate()->format($date_format);
$row['type'] = bat_event_type_load($entity->bundle())->label();
return $row + parent::buildRow($entity);
}
diff --git a/modules/bat_event/src/Plugin/views/field/BatEventHandlerDateField.php b/modules/bat_event/src/Plugin/views/field/BatEventHandlerDateField.php
deleted file mode 100644
index 71411be22..000000000
--- a/modules/bat_event/src/Plugin/views/field/BatEventHandlerDateField.php
+++ /dev/null
@@ -1,75 +0,0 @@
-get_value($values);
- $date = new DateTime($value);
-
- if ($this->table == 'bat_events' && $this->field == 'end_date') {
- // Add a minute to then end date.
- $date->add(new DateInterval('PT1M'));
- }
-
- $value = $date->getTimestamp();
- $format = $this->options['date_format'];
- if (in_array($format, ['custom', 'raw time ago', 'time ago', 'raw time span', 'time span', 'raw time span', 'inverse time span', 'time span'])) {
- $custom_format = $this->options['custom_date_format'];
- }
-
- if ($value) {
- $time_diff = REQUEST_TIME - $value;
- switch ($format) {
- case 'raw time ago':
- return format_interval($time_diff, is_numeric($custom_format) ? $custom_format : 2);
-
- case 'time ago':
- return t('%time ago', ['%time' => format_interval($time_diff, is_numeric($custom_format) ? $custom_format : 2)]);
-
- case 'raw time hence':
- return format_interval(-$time_diff, is_numeric($custom_format) ? $custom_format : 2);
-
- case 'time hence':
- return t('%time hence', ['%time' => format_interval(-$time_diff, is_numeric($custom_format) ? $custom_format : 2)]);
-
- case 'raw time span':
- return ($time_diff < 0 ? '-' : '') . format_interval(abs($time_diff), is_numeric($custom_format) ? $custom_format : 2);
-
- case 'inverse time span':
- return ($time_diff > 0 ? '-' : '') . format_interval(abs($time_diff), is_numeric($custom_format) ? $custom_format : 2);
-
- case 'time span':
- return t(($time_diff < 0 ? '%time hence' : '%time ago'), ['%time' => format_interval(abs($time_diff), is_numeric($custom_format) ? $custom_format : 2)]);
-
- case 'custom':
- if ($custom_format == 'r') {
- return format_date($value, $format, $custom_format, NULL, 'en');
- }
- return format_date($value, $format, $custom_format);
-
- default:
- return format_date($value, $format);
- }
- }
- }
-
-}
diff --git a/modules/bat_event/src/Plugin/views/field/BatEventHandlerDurationField.php b/modules/bat_event/src/Plugin/views/field/BatEventHandlerDurationField.php
index 1442b9bed..d21fe4a90 100644
--- a/modules/bat_event/src/Plugin/views/field/BatEventHandlerDurationField.php
+++ b/modules/bat_event/src/Plugin/views/field/BatEventHandlerDurationField.php
@@ -24,8 +24,7 @@ public function query() {
public function render(ResultRow $values) {
$event = $this->getEntity($values);
- $value = $event->end->value - $event->start->value;
- $value += 60;
+ $value = $event->getEndDate()->getTimestamp() - $event->getStartDate()->getTimestamp();
return $this->sanitizeValue(\Drupal::service('date.formatter')->formatInterval($value));
}
diff --git a/modules/bat_event/src/Plugin/views/filter/BatEventHandlerDateFilter.php b/modules/bat_event/src/Plugin/views/filter/BatEventHandlerDateFilter.php
deleted file mode 100644
index 4e3f97c04..000000000
--- a/modules/bat_event/src/Plugin/views/filter/BatEventHandlerDateFilter.php
+++ /dev/null
@@ -1,37 +0,0 @@
-view);
-
- $value = date('Y-m-d', intval(strtotime($this->value['value'], $query_substitutions['***CURRENT_TIME***'])));
-
- $this->query->addWhereExpression($this->options['group'], "$field $this->operator '$value'");
- }
-
- protected function opBetween($field) {
- // Use the substitutions to ensure a consistent timestamp.
- $query_substitutions = views_views_query_substitutions($this->view);
- $a = date('Y-m-d', intval(strtotime($this->value['min'], $query_substitutions['***CURRENT_TIME***'])));
- $b = date('Y-m-d', intval(strtotime($this->value['max'], $query_substitutions['***CURRENT_TIME***'])));
-
- // This is safe because we are manually scrubbing the values.
- // It is necessary to do it this way because $a and $b are formulas when using an offset.
- $operator = strtoupper($this->operator);
- $this->query->addWhereExpression($this->options['group'], "$field $operator '$a' AND '$b'");
- }
-
-}
diff --git a/modules/bat_event_ui/src/Form/BatEventUiBulkUpdateForm.php b/modules/bat_event_ui/src/Form/BatEventUiBulkUpdateForm.php
index ac28cabd6..8a00cb798 100644
--- a/modules/bat_event_ui/src/Form/BatEventUiBulkUpdateForm.php
+++ b/modules/bat_event_ui/src/Form/BatEventUiBulkUpdateForm.php
@@ -109,11 +109,15 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
foreach ($units as $unit) {
$event = bat_event_create([
'type' => $event_type->id(),
- 'start' => $start_date->getTimestamp(),
- 'end' => $end_date->getTimestamp(),
'uid' => $type->uid->entity->uid->value,
]);
+ $event_dates = [
+ 'value' => $start_date->format('Y-m-d'),
+ 'end_value' => $end_date->format('Y-m-d'),
+ ];
+ $event->set('event_dates', $event_dates);
+
$target_field_name = 'event_' . $event_type->target_entity_type . '_reference';
$event->set($target_field_name, $unit->id());
diff --git a/modules/bat_fullcalendar/bat_fullcalendar.info.yml b/modules/bat_fullcalendar/bat_fullcalendar.info.yml
index f293195f4..fc41df49a 100644
--- a/modules/bat_fullcalendar/bat_fullcalendar.info.yml
+++ b/modules/bat_fullcalendar/bat_fullcalendar.info.yml
@@ -7,3 +7,4 @@ package: bat
dependencies:
- bat_api
- bat_event
+ - fullcalendar_library
diff --git a/modules/bat_fullcalendar/bat_fullcalendar.install b/modules/bat_fullcalendar/bat_fullcalendar.install
deleted file mode 100644
index 9107798f4..000000000
--- a/modules/bat_fullcalendar/bat_fullcalendar.install
+++ /dev/null
@@ -1,44 +0,0 @@
- [
- 'title' => t('Fullcalendar'),
- 'value' => t('FullCalendar Library loaded via CDN'),
- 'description' => t('BAT is using a CDN to load the Fullcalendar library. To use a local copy, download the library and extract it into the /libraries/fullcalendar folder in your Drupal installation directory.', ['@url' => 'https://fullcalendar.io/download/']),
- 'severity' => REQUIREMENT_INFO,
- ],
- ];
- }
- elseif (!file_exists(DRUPAL_ROOT . '/libraries/fullcalendar-scheduler/scheduler.min.js')) {
- return [
- 'fullcalendar' => [
- 'title' => t('Fullcalendar'),
- 'value' => t('FullCalendar Scheduler Library loaded via CDN'),
- 'description' => t('BAT is using a CDN to load the Fullcalendar Scheduler library. To use a local copy, download the library and extract it into the /libraries/fullcalendar folder in your Drupal installation directory.', ['@url' => 'https://fullcalendar.io/scheduler/']),
- 'severity' => REQUIREMENT_INFO,
- ],
- ];
- }
-
- return [
- 'fullcalendar' => [
- 'title' => t('Fullcalendar'),
- 'value' => t('The FullCalendar, FullCalendar Scheduler and the Moment Library are installed'),
- 'severity' => REQUIREMENT_OK,
- ],
- ];
-}
diff --git a/modules/bat_fullcalendar/bat_fullcalendar.libraries.yml b/modules/bat_fullcalendar/bat_fullcalendar.libraries.yml
index 0cf8f356b..03777522a 100644
--- a/modules/bat_fullcalendar/bat_fullcalendar.libraries.yml
+++ b/modules/bat_fullcalendar/bat_fullcalendar.libraries.yml
@@ -1,35 +1,13 @@
-fullcalendar:
- version: VERSION
- js:
- /libraries/fullcalendar/lib/moment.min.js: { minified: true }
- /libraries/fullcalendar/fullcalendar.min.js: { minified: true }
- /libraries/fullcalendar/locale-all.js: { minified: true }
- dependencies:
- - core/jquery
- css:
- theme:
- css/fullcalendar.theme.css: {}
- /libraries/fullcalendar/fullcalendar.min.css: { minified: true }
-
-fullcalendar-scheduler:
+bat-fullcalendar-scheduler:
version: VERSION
js:
- /libraries/fullcalendar-scheduler/scheduler.min.js: { minified: true }
+ js/bat_fullcalendar_timeline.js: {}
dependencies:
- - bat_fullcalendar/fullcalendar
+ - fullcalendar_library/fullcalendar-scheduler
- core/drupalSettings
- core/drupal.dialog.ajax
css:
theme:
css/bat_fullcalendar_timeline.css: {}
- /libraries/fullcalendar-scheduler/scheduler.min.css: { minified: true }
-
-bat-fullcalendar-scheduler:
- version: VERSION
- js:
- js/bat_fullcalendar_timeline.js: {}
- dependencies:
- - bat_fullcalendar/fullcalendar-scheduler
- css:
- theme:
css/bat_modal.css: {}
+ css/fullcalendar.theme.css: {}
diff --git a/modules/bat_fullcalendar/bat_fullcalendar.module b/modules/bat_fullcalendar/bat_fullcalendar.module
index 60ec9ac75..366720ef2 100644
--- a/modules/bat_fullcalendar/bat_fullcalendar.module
+++ b/modules/bat_fullcalendar/bat_fullcalendar.module
@@ -7,13 +7,6 @@
* to easily modify it.
*/
-define('FULLCALENDAR_JS_CDN', 'https://cdn.jsdelivr.net/npm/fullcalendar@3.7.0/dist/fullcalendar.min.js');
-define('FULLCALENDAR_LOCALE_JS_CDN', 'https://cdn.jsdelivr.net/npm/fullcalendar@3.7.0/dist/locale-all.js');
-define('FULLCALENDAR_CSS_CDN', 'https://cdn.jsdelivr.net/npm/fullcalendar@3.7.0/dist/fullcalendar.min.css');
-define('FULLCALENDAR_SCHEDULER_JS_CDN', 'https://cdn.jsdelivr.net/npm/fullcalendar-scheduler@1.9.0/dist/scheduler.min.js');
-define('FULLCALENDAR_SCHEDULER_CSS_CDN', 'https://cdn.jsdelivr.net/npm/fullcalendar-scheduler@1.9.0/dist/scheduler.min.css');
-define('MOMENT_JS_CDN', 'https://cdn.jsdelivr.net/npm/moment@2.19.1/moment.min.js');
-
use Drupal\Core\Ajax\CloseModalDialogCommand;
use Drupal\Core\Template\Attribute;
use Drupal\Component\Utility\Html;
@@ -292,40 +285,3 @@ function bat_fullcalendar_modal_style($style = 'default') {
return $modal_style;
}
-
-/**
- * Implements hook_library_info_alter().
- */
-function bat_fullcalendar_library_info_alter(&$libraries, $extension) {
- if ($extension == 'bat_fullcalendar') {
- if (!file_exists(DRUPAL_ROOT . '/libraries/fullcalendar/lib/moment.min.js')) {
- unset($libraries['fullcalendar']['js']['/libraries/fullcalendar/lib/moment.min.js']);
- $libraries['fullcalendar']['js'][MOMENT_JS_CDN] = ['type' => 'external', 'minified' => TRUE];
- }
-
- if (!file_exists(DRUPAL_ROOT . '/libraries/fullcalendar/fullcalendar.min.js')) {
- unset($libraries['fullcalendar']['js']['/libraries/fullcalendar/fullcalendar.min.js']);
- $libraries['fullcalendar']['js'][FULLCALENDAR_JS_CDN] = ['type' => 'external', 'minified' => TRUE];
- }
-
- if (!file_exists(DRUPAL_ROOT . '/libraries/fullcalendar/locale-all.js')) {
- unset($libraries['fullcalendar']['js']['/libraries/fullcalendar/locale-all.js']);
- $libraries['fullcalendar']['js'][FULLCALENDAR_LOCALE_JS_CDN] = ['type' => 'external', 'minified' => TRUE];
- }
-
- if (!file_exists(DRUPAL_ROOT . '/libraries/fullcalendar/fullcalendar.min.css')) {
- unset($libraries['fullcalendar']['css']['theme']['/libraries/fullcalendar/fullcalendar.min.css']);
- $libraries['fullcalendar']['css']['theme'][FULLCALENDAR_CSS_CDN] = ['type' => 'external', 'minified' => TRUE];
- }
-
- if (!file_exists(DRUPAL_ROOT . '/libraries/fullcalendar-scheduler/scheduler.min.js')) {
- unset($libraries['fullcalendar-scheduler']['js']['/libraries/fullcalendar-scheduler/scheduler.min.js']);
- $libraries['fullcalendar-scheduler']['js'][FULLCALENDAR_SCHEDULER_JS_CDN] = ['type' => 'external', 'minified' => TRUE];
- }
-
- if (!file_exists(DRUPAL_ROOT . '/libraries/fullcalendar-scheduler/scheduler.min.css')) {
- unset($libraries['fullcalendar-scheduler']['css']['theme']['/libraries/fullcalendar-scheduler/scheduler.min.css']);
- $libraries['fullcalendar-scheduler']['css']['theme'][FULLCALENDAR_SCHEDULER_CSS_CDN] = ['type' => 'external', 'minified' => TRUE];
- }
- }
-}
diff --git a/modules/bat_fullcalendar/src/Form/FullcalendarEventManagerForm.php b/modules/bat_fullcalendar/src/Form/FullcalendarEventManagerForm.php
index 8d2e5596b..539604286 100644
--- a/modules/bat_fullcalendar/src/Form/FullcalendarEventManagerForm.php
+++ b/modules/bat_fullcalendar/src/Form/FullcalendarEventManagerForm.php
@@ -149,12 +149,11 @@ public function ajaxEventStatusChange($form, FormStateInterface $form_state) {
$event = bat_event_create(['type' => $event_type]);
$event->uid = \Drupal::currentUser()->id();
- $event->start = $start_date->getTimestamp();
- // Always subtract one minute from the end time. FullCalendar provides
- // start and end time with the assumption that the last minute is *excluded*
- // while BAT deals with times assuming that the last minute is included.
- $end_date->sub(new \DateInterval('PT1M'));
- $event->end = $end_date->getTimestamp();
+ $event_dates = [
+ 'value' => $start_date->format('Y-m-d\TH:i:00'),
+ 'end_value' => $end_date->format('Y-m-d\TH:i:00'),
+ ];
+ $event->set('event_dates', $event_dates);
$event_type_entity = bat_event_type_load($event_type);
// Construct target entity reference field name using this event type's target entity type.
@@ -192,12 +191,11 @@ public function eventManagerAjaxSubmit($form, FormStateInterface $form_state) {
$event = bat_event_create(['type' => $event_type]);
$event->uid = \Drupal::currentUser()->id();
- $event->start = $start_date->getTimestamp();
- // Always subtract one minute from the end time. FullCalendar provides
- // start and end time with the assumption that the last minute is *excluded*
- // while BAT deals with times assuming that the last minute is included.
- $end_date->sub(new \DateInterval('PT1M'));
- $event->end = $end_date->getTimestamp();
+ $event_dates = [
+ 'value' => $start_date->format('Y-m-d\TH:i:00'),
+ 'end_value' => $end_date->format('Y-m-d\TH:i:00'),
+ ];
+ $event->set('event_dates', $event_dates);
$event_type_entity = bat_event_type_load($event_type);
// Construct target entity reference field name using this event type's target entity type.
diff --git a/test/project.make b/test/project.make
index 19257dd2b..d2a9dd37f 100644
--- a/test/project.make
+++ b/test/project.make
@@ -6,6 +6,12 @@ projects[drupal][version] = 8.4.4
defaults[projects][subdir] = contrib
+; Pull fullcalendar_library
+projects[fullcalendar_library][type] = module
+projects[fullcalendar_library][download][type] = git
+projects[fullcalendar_library][download][url] = https://github.com/Roomify/fullcalendar_library.git
+projects[fullcalendar_library][download][branch] = 8.x-1.x
+
; Pull the latest version of bat_api
projects[bat_api][type] = module
projects[bat_api][download][type] = git