Improved new activity date & time field, also...

* Removed dependency of opencase_search on opencase so opencase_search doesn't get uninstalled when refreshing opencase for UI changes
* Changed no-results wording on case views (both displays: all cases & cases for a person)
This commit is contained in:
Naomi
2020-02-24 12:54:39 +00:00
parent a7a96ab03c
commit ae3976c7b8
9 changed files with 84 additions and 82 deletions

View File

@ -8,10 +8,7 @@ function opencase_entities_update_8003() {
->setLabel(t('Date and time'))
->setDescription(t('When the activity started.'))
->setRevisionable(TRUE)
->setSettings([
'datetime_type' => 'date'
])
->setDefaultValue('2000-01-01')
->setDefaultValueCallback('Drupal\opencase_entities\Entity\OCActivity::currentDateTime')
->setDisplayOptions('view', [
'type' => 'datetime_default',
'settings' => [

View File

@ -9,6 +9,8 @@ use Drupal\Core\Entity\RevisionableInterface;
use Drupal\Core\Entity\EntityChangedTrait;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\user\UserInterface;
use Drupal\datetime\Plugin\Field\FieldType\DateTimeItem;
use Drupal\Core\Datetime\DrupalDateTime;
/**
* Defines the Activity entity.
@ -81,6 +83,12 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte
return array(\Drupal::request()->query->get('case_id'));
}
public static function currentDateTime() {
$current_time = DrupalDateTime::createFromTimestamp(time());
$formatted = $current_time->format(DateTimeItem::DATETIME_STORAGE_FORMAT);
\Drupal::logger("nr_debug")->notice($formatted);
return $formatted;
}
/**
* {@inheritdoc}
*/
@ -212,12 +220,10 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte
$fields['activity_date_time'] = BaseFieldDefinition::create('datetime')
->setLabel(t('Date and time'))
->setDescription(t('When the activity started.'))
->setDescription('')
->setRevisionable(TRUE)
->setSettings([
'datetime_type' => 'date'
])
->setDefaultValue('2000-01-01')
->setRequired(TRUE)
->setDefaultValueCallback('Drupal\opencase_entities\Entity\OCActivity::currentDateTime')
->setDisplayOptions('view', [
'label' => 'above',
'type' => 'datetime_default',