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

Add a test quantity type with test method taxonomy #604

This commit is contained in:
Michael Stenta 2022-11-25 12:03:14 -05:00
commit 90e9e2aad7
9 changed files with 97 additions and 0 deletions

View file

@ -26,6 +26,7 @@ If you would like to skip the automatic fix, add the following line to your
- [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)
- [Add a test quantity type with test method taxonomy #604](https://github.com/farmOS/farmOS/pull/604)
### Changed

View file

@ -4,9 +4,15 @@ dependencies:
enforced:
module:
- farm_lab_test
module:
- farm_log_quantity
- farm_quantity_test
id: lab_test
label: 'Lab test'
description: ''
name_pattern: 'Lab test log [log:id]'
workflow: log_default
new_revision: true
third_party_settings:
farm_log_quantity:
default_quantity_type: test

View file

@ -6,4 +6,5 @@ core_version_requirement: ^9
dependencies:
- farm:farm_entity
- farm:farm_lab
- farm:farm_quantity_test
- log:log

View file

@ -148,3 +148,12 @@ function farm_lab_test_post_update_migrate_lab_terms(&$sandbox) {
$sandbox['#finished'] = $sandbox['current_log'] / count($sandbox['log_map']);
return NULL;
}
/**
* Install the test quantity module.
*/
function farm_lab_test_post_update_enable_farm_quantity_test(&$sandbox) {
if (!\Drupal::service('module_handler')->moduleExists('farm_quantity_test')) {
\Drupal::service('module_installer')->install(['farm_quantity_test']);
}
}

View file

@ -0,0 +1,11 @@
langcode: en
status: true
dependencies:
enforced:
module:
- farm_quantity_test
id: test
label: Test
default_measure: ''
description: 'Test measurement quantity type.'
new_revision: true

View file

@ -0,0 +1,9 @@
name: Test quantity
description: Provides a quantity type for test measurements.
type: module
package: farmOS Quantities
core_version_requirement: ^9
dependencies:
- farm:farm_entity
- farm:farm_test_method
- farm:quantity

View file

@ -0,0 +1,43 @@
<?php
namespace Drupal\farm_quantity_test\Plugin\Quantity\QuantityType;
use Drupal\farm_entity\Plugin\Quantity\QuantityType\FarmQuantityType;
/**
* Provides the test quantity type.
*
* @QuantityType(
* id = "test",
* label = @Translation("Test measurement"),
* )
*/
class Test extends FarmQuantityType {
/**
* {@inheritdoc}
*/
public function buildFieldDefinitions() {
// Inherit default quantity fields.
$fields = parent::buildFieldDefinitions();
// Test method.
$options = [
'type' => 'entity_reference',
'label' => $this->t('Test method'),
'description' => $this->t('What testing method was used to obtain this measurement?'),
'target_type' => 'taxonomy_term',
'target_bundle' => 'test_method',
'auto_create' => TRUE,
'weight' => [
'form' => 25,
'view' => 25,
],
];
$fields['test_method'] = $this->farmFieldFactory->bundleFieldDefinition($options);
return $fields;
}
}

View file

@ -0,0 +1,10 @@
langcode: en
status: true
dependencies:
enforced:
module:
- farm_test_method
name: Test methods
vid: test_method
description: 'A list of test methods.'
weight: 0

View file

@ -0,0 +1,7 @@
name: Test method vocabulary
description: Provides a Test method vocabulary.
type: module
package: farmOS Taxonomies
core_version_requirement: ^9
dependencies:
- drupal:taxonomy