v1.7 - Removed seconds from date and time field
Also altered activities view to show this field instead of created date.
This commit is contained in:
parent
7f88d409f0
commit
b83f0b44b4
@ -4,6 +4,7 @@ dependencies:
|
||||
config:
|
||||
- user.role.authenticated
|
||||
module:
|
||||
- datetime
|
||||
- opencase_entities
|
||||
- user
|
||||
id: activities
|
||||
@ -69,6 +70,72 @@ display:
|
||||
row:
|
||||
type: 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:
|
||||
id: name
|
||||
table: oc_activity_field_data
|
||||
@ -263,73 +330,6 @@ display:
|
||||
entity_type: oc_activity
|
||||
entity_field: description
|
||||
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:
|
||||
id: view_oc_activity
|
||||
table: oc_activity
|
||||
|
@ -1,5 +1,11 @@
|
||||
<?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.
|
||||
*/
|
||||
|
@ -9,6 +9,29 @@ use Drupal\Core\Routing\RouteMatchInterface;
|
||||
use Drupal\Core\Access\AccessResult;
|
||||
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
|
||||
|
Reference in New Issue
Block a user