v1.6 Added activity date time field

This commit is contained in:
Naomi 2020-02-22 14:10:46 +00:00
parent a6db6615df
commit a7a96ab03c
3 changed files with 53 additions and 0 deletions

View File

@ -0,0 +1,31 @@
<?php
/**
* Add 'activity_date_time' field to 'oc_activity' entities.
*/
function opencase_entities_update_8003() {
$storage_definition = \Drupal\Core\Field\BaseFieldDefinition::create('datetime')
->setLabel(t('Date and time'))
->setDescription(t('When the activity started.'))
->setRevisionable(TRUE)
->setSettings([
'datetime_type' => 'date'
])
->setDefaultValue('2000-01-01')
->setDisplayOptions('view', [
'type' => 'datetime_default',
'settings' => [
'format_type' => 'medium',
],
'label' => 'above',
'weight' => -3,
])
->setDisplayOptions('form', [
'type' => 'datetime_default',
'weight' => -3,
]);
\Drupal::entityDefinitionUpdateManager()
->installFieldStorageDefinition('activity_date_time', 'oc_activity', 'oc_activity', $storage_definition);
}

View File

@ -210,6 +210,27 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);
$fields['activity_date_time'] = BaseFieldDefinition::create('datetime')
->setLabel(t('Date and time'))
->setDescription(t('When the activity started.'))
->setRevisionable(TRUE)
->setSettings([
'datetime_type' => 'date'
])
->setDefaultValue('2000-01-01')
->setDisplayOptions('view', [
'label' => 'above',
'type' => 'datetime_default',
'settings' => [
'format_type' => 'medium',
],
'weight' => -3,
])
->setDisplayOptions('form', [
'type' => 'datetime_default',
'weight' => -3,
]);
// not currently in use. Will set view and form settings when ready
$fields['status'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Publishing status'))

View File

@ -2,6 +2,7 @@ name: 'OpenCase'
type: module
description: 'Simple Case Management'
core: 8.x
version: 8.x-1.6
package: 'OpenCase'
dependencies:
- opencase_entities