Compare commits

...

4 Commits
1.6.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
f47ded38fa v1.7 - adding datetime field with correct datepicker type & default datetime 2020-02-24 10:57:06 +00:00
6 changed files with 37 additions and 11 deletions

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> <p>To create a case, use the sidebar menu to the right</p>" content: "<p>Either there are no cases involving this person, or you do not have access to them.</p>\n"
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 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" 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"
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

@ -1,14 +1,19 @@
<?php <?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. * Add 'activity_date_time' field to 'oc_activity' entities.
*/ */
function opencase_entities_update_8003() { function opencase_entities_update_8003() {
$storage_definition = \Drupal\Core\Field\BaseFieldDefinition::create('datetime') $storage_definition = \Drupal\Core\Field\BaseFieldDefinition::create('datetime')
->setLabel(t('Date and time')) ->setLabel(t('Date and time'))
->setDescription(t('When the activity started.'))
->setRevisionable(TRUE) ->setRevisionable(TRUE)
->setDefaultValueCallback('Drupal\opencase_entities\Entity\OCActivity::currentDateTime') ->setDefaultValueCallback('\Drupal\opencase_entities\Entity\OCActivity::currentDateTime')
->setDisplayOptions('view', [ ->setDisplayOptions('view', [
'type' => 'datetime_default', 'type' => 'datetime_default',
'settings' => [ 'settings' => [

View File

@ -86,7 +86,6 @@ class OCActivity extends RevisionableContentEntityBase implements OCActivityInte
public static function currentDateTime() { public static function currentDateTime() {
$current_time = DrupalDateTime::createFromTimestamp(time()); $current_time = DrupalDateTime::createFromTimestamp(time());
$formatted = $current_time->format(DateTimeItem::DATETIME_STORAGE_FORMAT); $formatted = $current_time->format(DateTimeItem::DATETIME_STORAGE_FORMAT);
\Drupal::logger("nr_debug")->notice($formatted);
return $formatted; return $formatted;
} }
/** /**
@ -220,10 +219,9 @@ 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('')
->setRevisionable(TRUE) ->setRevisionable(TRUE)
->setRequired(TRUE) ->setRequired(TRUE)
->setDefaultValueCallback('Drupal\opencase_entities\Entity\OCActivity::currentDateTime') ->setDefaultValueCallback('\Drupal\opencase_entities\Entity\OCActivity::currentDateTime')
->setDisplayOptions('view', [ ->setDisplayOptions('view', [
'label' => 'above', 'label' => 'above',
'type' => 'datetime_default', 'type' => 'datetime_default',

View File

@ -2,7 +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 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