Compare commits

...

13 Commits
1.5.3 ... 1.7

Author SHA1 Message Date
b83f0b44b4 v1.7 - Removed seconds from date and time field
Also altered activities view to show this field instead of created date.
2020-03-01 09:45:10 +00:00
7f88d409f0 1.6.5 more git mixup 2020-02-24 17:17:53 +00:00
8841fd4d25 v1.6.4 - more git mixup 2020-02-24 17:09:57 +00:00
87241c1f87 v1.6.3 due to git mixup 2020-02-24 16:59:43 +00:00
2a1607c6d9 Merge branch 'master' of github.com:hoegrammer/opencase 2020-02-24 16:27:37 +00:00
d8fd12a7b9 v1.6.2 2020-02-24 16:27:18 +00:00
e4a04a254d v1.6.1 2020-02-24 16:26:04 +00:00
88b5ce3d2e Merge branch 'master' of github.com:hoegrammer/opencase 2020-02-24 13:01:15 +00:00
ae3976c7b8 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)
2020-02-24 12:54:39 +00:00
f47ded38fa v1.7 - adding datetime field with correct datepicker type & default datetime 2020-02-24 10:57:06 +00:00
c63cae6b71 Added callback to default to current date
But it isn't displaying, possibly because of having the wrong kind of widget
2020-02-23 17:36:48 +00:00
a7a96ab03c v1.6 Added activity date time field 2020-02-22 15:31:10 +00:00
a6db6615df No longer trimming activity text in views 2020-01-23 10:04:50 +00:00
10 changed files with 155 additions and 70 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
@ -13,7 +14,6 @@ description: ''
tag: '' tag: ''
base_table: oc_activity_field_data base_table: oc_activity_field_data
base_field: id base_field: id
core: 8.x
display: display:
default: default:
display_plugin: default display_plugin: default
@ -70,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
@ -233,7 +299,7 @@ display:
more_link_text: '' more_link_text: ''
more_link_path: '' more_link_path: ''
strip_tags: false strip_tags: false
trim: true trim: false
preserve_tags: '' preserve_tags: ''
html: false html: false
element_type: '' element_type: ''
@ -264,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

@ -41,3 +41,8 @@ body {
.block-superfish .menu ul li a:hover { .block-superfish .menu ul li a:hover {
color: black; color: black;
} }
/* In views, display label at top of field. Ths is because full descriptions are displayed in the activity view so having the label in the middle means it disappears down the page. */
td.views-field {
vertical-align: top;
}

View File

@ -0,0 +1,33 @@
<?php
function opencase_entities_update_8016() {
$update_manager = \Drupal::entityDefinitionUpdateManager();
$definition = $update_manager->getFieldStorageDefinition('activity_date_time', 'oc_activity');
$update_manager->updateFieldStorageDefinition($definition);
}
/**
* 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'))
->setRevisionable(TRUE)
->setDefaultValueCallback('\Drupal\opencase_entities\Entity\OCActivity::currentDateTime')
->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

@ -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,11 @@ 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);
return $formatted;
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@ -210,6 +217,24 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type); $fields = parent::baseFieldDefinitions($entity_type);
$fields['activity_date_time'] = BaseFieldDefinition::create('datetime')
->setLabel(t('Date and time'))
->setRevisionable(TRUE)
->setRequired(TRUE)
->setDefaultValueCallback('\Drupal\opencase_entities\Entity\OCActivity::currentDateTime')
->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 // not currently in use. Will set view and form settings when ready
$fields['status'] = BaseFieldDefinition::create('boolean') $fields['status'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Publishing status')) ->setLabel(t('Publishing status'))

View File

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

View File

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

View File

@ -9,6 +9,29 @@ use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Access\AccessResult; use Drupal\Core\Access\AccessResult;
use Drupal\opencase\EntityTypeRelationsWidget; use Drupal\opencase\EntityTypeRelationsWidget;
/**
* Implements hook_element_info_alter().
*/
function opencase_element_info_alter(array &$types) {
$types['datetime']['#process'][] = 'opencase_process_element';
}
/**
* Element process callback for datetime fields. Removes the seconds part.
*/
function opencase_process_element($element) {
if ($element['#date_time_element'] !== 'none') {
$element['#date_time_format'] = 'H:i';
}
if (!empty($element['time']['#value'])) {
$parts = explode(':', $element['time']['#value']);
$parts = array_splice($parts, 0, 2);
$element['time']['#value'] = implode(':', $parts);
}
// Remove seconds in browsers that support HTML5 type=date.
$element['time']['#attributes']['step'] = 60;
return $element;
}
/** /**
* Implements hook_block_access * Implements hook_block_access