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:
parent
c100569bf7
commit
fbd754e867
3 changed files with 63 additions and 0 deletions
|
@ -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 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)
|
- [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)
|
- [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
|
### Changed
|
||||||
|
|
||||||
|
|
38
modules/log/lab_test/farm_lab_test.post_update.php
Normal file
38
modules/log/lab_test/farm_lab_test.post_update.php
Normal 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);
|
||||||
|
}
|
|
@ -44,6 +44,30 @@ class LabTest extends FarmLogType {
|
||||||
];
|
];
|
||||||
$fields['lab'] = $this->farmFieldFactory->bundleFieldDefinition($options);
|
$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;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue