3
0
Fork 0
mirror of https://github.com/farmOS/farmOS.git synced 2024-02-23 11:37:38 +01:00

Add "Date received" and "Date processed" fields to lab test logs #602

This commit is contained in:
Michael Stenta 2022-06-06 16:29:02 -04:00
parent c100569bf7
commit fbd754e867
3 changed files with 63 additions and 0 deletions

View file

@ -25,6 +25,7 @@ If you would like to skip the automatic fix, add the following line to your
- [Add action to bulk categorize logs #590](https://github.com/farmOS/farmOS/pull/590)
- [Add action for bulk assigning asset parent #588](https://github.com/farmOS/farmOS/pull/588)
- [Show "Add log" action links on /asset/[id]/logs/[type] #596](https://github.com/farmOS/farmOS/pull/596)
- [Add "Date received" and "Date processed" fields to lab test logs](https://github.com/farmOS/farmOS/pull/602)
### Changed

View file

@ -0,0 +1,38 @@
<?php
/**
* @file
* Post update hooks for the farm_lab_test module.
*/
/**
* Add "Date received" and "Date processed" fields to lab test logs.
*/
function farm_lab_test_post_update_add_received_processed_date_fields(&$sandbox) {
// Date received.
$options = [
'type' => 'timestamp',
'label' => t('Date received'),
'description' => t('The date when the sample was received by the lab.'),
'weight' => [
'form' => -35,
'view' => -35,
],
];
$field_definition = \Drupal::service('farm_field.factory')->bundleFieldDefinition($options);
\Drupal::entityDefinitionUpdateManager()->installFieldStorageDefinition('lab_received_date', 'log', 'farm_lab_test', $field_definition);
// Date processed.
$options = [
'type' => 'timestamp',
'label' => t('Date processed'),
'description' => t('The date when the sample was processed by the lab.'),
'weight' => [
'form' => -34,
'view' => -34,
],
];
$field_definition = \Drupal::service('farm_field.factory')->bundleFieldDefinition($options);
\Drupal::entityDefinitionUpdateManager()->installFieldStorageDefinition('lab_processed_date', 'log', 'farm_lab_test', $field_definition);
}

View file

@ -44,6 +44,30 @@ class LabTest extends FarmLogType {
];
$fields['lab'] = $this->farmFieldFactory->bundleFieldDefinition($options);
// Date received.
$options = [
'type' => 'timestamp',
'label' => $this->t('Date received'),
'description' => $this->t('The date when the sample was received by the lab.'),
'weight' => [
'form' => -35,
'view' => -35,
],
];
$fields['lab_received_date'] = $this->farmFieldFactory->bundleFieldDefinition($options);
// Date processed.
$options = [
'type' => 'timestamp',
'label' => $this->t('Date processed'),
'description' => $this->t('The date when the sample was processed by the lab.'),
'weight' => [
'form' => -34,
'view' => -34,
],
];
$fields['lab_processed_date'] = $this->farmFieldFactory->bundleFieldDefinition($options);
return $fields;
}