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

@ -4,6 +4,7 @@ dependencies:
config: config:
- user.role.authenticated - user.role.authenticated
module: module:
- datetime
- opencase_entities - opencase_entities
- user - user
id: activities id: activities
@ -69,6 +70,72 @@ display:
row: row:
type: fields type: fields
fields: fields:
activity_date_time:
id: activity_date_time
table: oc_activity_field_data
field: activity_date_time
relationship: none
group_type: group
admin_label: ''
label: 'Date and time'
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: datetime_custom
settings:
timezone_override: ''
date_format: 'd/m/Y - H:i'
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
entity_type: oc_activity
entity_field: activity_date_time
plugin_id: field
name: name:
id: name id: name
table: oc_activity_field_data table: oc_activity_field_data
@ -263,73 +330,6 @@ display:
entity_type: oc_activity entity_type: oc_activity
entity_field: description entity_field: description
plugin_id: field plugin_id: field
created:
id: created
table: oc_activity_field_data
field: created
relationship: none
group_type: group
admin_label: ''
label: Created
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: timestamp
settings:
date_format: short
custom_date_format: ''
timezone: ''
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
entity_type: oc_activity
entity_field: created
plugin_id: field
view_oc_activity: view_oc_activity:
id: view_oc_activity id: view_oc_activity
table: oc_activity table: oc_activity

View File

@ -477,7 +477,7 @@ display:
admin_label: '' admin_label: ''
empty: true empty: true
tokenize: false tokenize: false
content: "<p>Either there are no cases involving this person, or you do not have access to them.</p>\n" content: "<p>Either there are no cases involving this person, or you do not have access to them.</p> <p>To create a case, use the sidebar menu to the right</p>"
plugin_id: text_custom plugin_id: text_custom
relationships: { } relationships: { }
arguments: arguments:
@ -584,7 +584,7 @@ display:
admin_label: '' admin_label: ''
empty: true empty: true
tokenize: false tokenize: false
content: "<h1>No cases found</h1>\n<p>You do not have access to any existing cases.</p>\n<p>To <b>add a new case</b>, first search for the person you want to add a case to. If they are not on the system yet you can add them using the <b>Add actors</b> menu in the left sidebar.</p>\n" content: "<h1>No cases found</h1>\n<p>You do not have access to any existing cases.</p>\n<p>To <b>add a new case</b>, first search for the person you want to create a case for, using the search bar at the top right of the screen. If they are not on the system yet, add them using the <b>Add People</b> tab.</p>\n"
plugin_id: text_custom plugin_id: text_custom
cache_metadata: cache_metadata:
max-age: -1 max-age: -1

View File

@ -2,9 +2,9 @@
function opencase_default_reporting_uninstall() { function opencase_default_reporting_uninstall() {
$configs = [ $configs = [
// 'search_api.index.opencase_reporting_cases', 'search_api.index.opencase_reporting_cases',
// 'search_api.index.opencase_reporting_clients', 'search_api.index.opencase_reporting_clients',
// 'search_api.index.opencase_reporting_volunteers', 'search_api.index.opencase_reporting_volunteers',
'block.block.facet_asylum_status', 'block.block.facet_asylum_status',
'block.block.facet_created', 'block.block.facet_created',
'block.block.facet_disability', 'block.block.facet_disability',

View File

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

View File

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

View File

@ -6,4 +6,3 @@ package: 'OpenCase'
dependencies: dependencies:
- search_api - search_api
- search_api_db - search_api_db
- opencase