Merge 8645a4428f
into c13d8fee32
This commit is contained in:
commit
893d7606aa
|
@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- [Add "Days of harvest" field to Plant type terms #794](https://github.com/farmOS/farmOS/pull/794)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- [Set the minimum value of maturity_days and transplant_days to 1 #794](https://github.com/farmOS/farmOS/pull/794)
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- [Check for correct update operation access in location hierarchy form #800](https://github.com/farmOS/farmOS/pull/800)
|
- [Check for correct update operation access in location hierarchy form #800](https://github.com/farmOS/farmOS/pull/800)
|
||||||
|
|
|
@ -88,6 +88,7 @@ Terms in the "Plant type" vocabulary have the following additional attributes:
|
||||||
|
|
||||||
- Days to maturity (Integer)
|
- Days to maturity (Integer)
|
||||||
- Days to transplant (Integer)
|
- Days to transplant (Integer)
|
||||||
|
- Days of harvest (Integer)
|
||||||
|
|
||||||
And the following additional relationships:
|
And the following additional relationships:
|
||||||
|
|
||||||
|
|
|
@ -4,17 +4,18 @@ dependencies:
|
||||||
config:
|
config:
|
||||||
- field.field.taxonomy_term.plant_type.companions
|
- field.field.taxonomy_term.plant_type.companions
|
||||||
- field.field.taxonomy_term.plant_type.crop_family
|
- field.field.taxonomy_term.plant_type.crop_family
|
||||||
|
- field.field.taxonomy_term.plant_type.harvest_days
|
||||||
- field.field.taxonomy_term.plant_type.image
|
- field.field.taxonomy_term.plant_type.image
|
||||||
- field.field.taxonomy_term.plant_type.maturity_days
|
- field.field.taxonomy_term.plant_type.maturity_days
|
||||||
- field.field.taxonomy_term.plant_type.transplant_days
|
- field.field.taxonomy_term.plant_type.transplant_days
|
||||||
- image.style.thumbnail
|
- image.style.thumbnail
|
||||||
- taxonomy.vocabulary.plant_type
|
- taxonomy.vocabulary.plant_type
|
||||||
enforced:
|
|
||||||
module:
|
|
||||||
- farm_plant_type
|
|
||||||
module:
|
module:
|
||||||
- image
|
- image
|
||||||
- text
|
- text
|
||||||
|
enforced:
|
||||||
|
module:
|
||||||
|
- farm_plant_type
|
||||||
id: taxonomy_term.plant_type.default
|
id: taxonomy_term.plant_type.default
|
||||||
targetEntityType: taxonomy_term
|
targetEntityType: taxonomy_term
|
||||||
bundle: plant_type
|
bundle: plant_type
|
||||||
|
@ -22,7 +23,7 @@ mode: default
|
||||||
content:
|
content:
|
||||||
companions:
|
companions:
|
||||||
type: entity_reference_autocomplete
|
type: entity_reference_autocomplete
|
||||||
weight: 5
|
weight: 6
|
||||||
region: content
|
region: content
|
||||||
settings:
|
settings:
|
||||||
match_operator: CONTAINS
|
match_operator: CONTAINS
|
||||||
|
@ -45,12 +46,19 @@ content:
|
||||||
weight: 1
|
weight: 1
|
||||||
region: content
|
region: content
|
||||||
settings:
|
settings:
|
||||||
placeholder: ''
|
|
||||||
rows: 5
|
rows: 5
|
||||||
|
placeholder: ''
|
||||||
|
third_party_settings: { }
|
||||||
|
harvest_days:
|
||||||
|
type: number
|
||||||
|
weight: 5
|
||||||
|
region: content
|
||||||
|
settings:
|
||||||
|
placeholder: ''
|
||||||
third_party_settings: { }
|
third_party_settings: { }
|
||||||
image:
|
image:
|
||||||
type: image_image
|
type: image_image
|
||||||
weight: 6
|
weight: 7
|
||||||
region: content
|
region: content
|
||||||
settings:
|
settings:
|
||||||
progress_indicator: throbber
|
progress_indicator: throbber
|
||||||
|
@ -73,10 +81,10 @@ content:
|
||||||
third_party_settings: { }
|
third_party_settings: { }
|
||||||
status:
|
status:
|
||||||
type: boolean_checkbox
|
type: boolean_checkbox
|
||||||
|
weight: 8
|
||||||
|
region: content
|
||||||
settings:
|
settings:
|
||||||
display_label: true
|
display_label: true
|
||||||
weight: 7
|
|
||||||
region: content
|
|
||||||
third_party_settings: { }
|
third_party_settings: { }
|
||||||
transplant_days:
|
transplant_days:
|
||||||
type: number
|
type: number
|
||||||
|
|
|
@ -4,16 +4,17 @@ dependencies:
|
||||||
config:
|
config:
|
||||||
- field.field.taxonomy_term.plant_type.companions
|
- field.field.taxonomy_term.plant_type.companions
|
||||||
- field.field.taxonomy_term.plant_type.crop_family
|
- field.field.taxonomy_term.plant_type.crop_family
|
||||||
|
- field.field.taxonomy_term.plant_type.harvest_days
|
||||||
- field.field.taxonomy_term.plant_type.image
|
- field.field.taxonomy_term.plant_type.image
|
||||||
- field.field.taxonomy_term.plant_type.maturity_days
|
- field.field.taxonomy_term.plant_type.maturity_days
|
||||||
- field.field.taxonomy_term.plant_type.transplant_days
|
- field.field.taxonomy_term.plant_type.transplant_days
|
||||||
- taxonomy.vocabulary.plant_type
|
- taxonomy.vocabulary.plant_type
|
||||||
enforced:
|
|
||||||
module:
|
|
||||||
- farm_plant_type
|
|
||||||
module:
|
module:
|
||||||
- image
|
- image
|
||||||
- text
|
- text
|
||||||
|
enforced:
|
||||||
|
module:
|
||||||
|
- farm_plant_type
|
||||||
id: taxonomy_term.plant_type.default
|
id: taxonomy_term.plant_type.default
|
||||||
targetEntityType: taxonomy_term
|
targetEntityType: taxonomy_term
|
||||||
bundle: plant_type
|
bundle: plant_type
|
||||||
|
@ -21,52 +22,63 @@ mode: default
|
||||||
content:
|
content:
|
||||||
companions:
|
companions:
|
||||||
type: entity_reference_label
|
type: entity_reference_label
|
||||||
weight: 4
|
|
||||||
region: content
|
|
||||||
label: above
|
label: above
|
||||||
settings:
|
settings:
|
||||||
link: true
|
link: true
|
||||||
third_party_settings: { }
|
third_party_settings: { }
|
||||||
crop_family:
|
|
||||||
type: entity_reference_label
|
|
||||||
weight: 1
|
|
||||||
region: content
|
|
||||||
label: above
|
|
||||||
settings:
|
|
||||||
link: true
|
|
||||||
third_party_settings: { }
|
|
||||||
description:
|
|
||||||
label: hidden
|
|
||||||
type: text_default
|
|
||||||
weight: 0
|
|
||||||
region: content
|
|
||||||
settings: { }
|
|
||||||
third_party_settings: { }
|
|
||||||
image:
|
|
||||||
type: image
|
|
||||||
weight: 5
|
weight: 5
|
||||||
region: content
|
region: content
|
||||||
|
crop_family:
|
||||||
|
type: entity_reference_label
|
||||||
label: above
|
label: above
|
||||||
settings:
|
settings:
|
||||||
image_style: ''
|
link: true
|
||||||
image_link: ''
|
|
||||||
third_party_settings: { }
|
third_party_settings: { }
|
||||||
|
weight: 1
|
||||||
|
region: content
|
||||||
|
description:
|
||||||
|
type: text_default
|
||||||
|
label: hidden
|
||||||
|
settings: { }
|
||||||
|
third_party_settings: { }
|
||||||
|
weight: 0
|
||||||
|
region: content
|
||||||
|
harvest_days:
|
||||||
|
type: number_integer
|
||||||
|
label: above
|
||||||
|
settings:
|
||||||
|
thousand_separator: ''
|
||||||
|
prefix_suffix: true
|
||||||
|
third_party_settings: { }
|
||||||
|
weight: 4
|
||||||
|
region: content
|
||||||
|
image:
|
||||||
|
type: image
|
||||||
|
label: above
|
||||||
|
settings:
|
||||||
|
image_link: ''
|
||||||
|
image_style: ''
|
||||||
|
image_loading:
|
||||||
|
attribute: lazy
|
||||||
|
third_party_settings: { }
|
||||||
|
weight: 6
|
||||||
|
region: content
|
||||||
maturity_days:
|
maturity_days:
|
||||||
type: number_integer
|
type: number_integer
|
||||||
|
label: above
|
||||||
|
settings:
|
||||||
|
thousand_separator: ''
|
||||||
|
prefix_suffix: true
|
||||||
|
third_party_settings: { }
|
||||||
weight: 3
|
weight: 3
|
||||||
region: content
|
region: content
|
||||||
label: above
|
|
||||||
settings:
|
|
||||||
thousand_separator: ''
|
|
||||||
prefix_suffix: true
|
|
||||||
third_party_settings: { }
|
|
||||||
transplant_days:
|
transplant_days:
|
||||||
type: number_integer
|
type: number_integer
|
||||||
weight: 2
|
|
||||||
region: content
|
|
||||||
label: above
|
label: above
|
||||||
settings:
|
settings:
|
||||||
thousand_separator: ''
|
thousand_separator: ''
|
||||||
prefix_suffix: true
|
prefix_suffix: true
|
||||||
third_party_settings: { }
|
third_party_settings: { }
|
||||||
|
weight: 2
|
||||||
|
region: content
|
||||||
hidden: { }
|
hidden: { }
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
langcode: en
|
||||||
|
status: true
|
||||||
|
dependencies:
|
||||||
|
config:
|
||||||
|
- field.storage.taxonomy_term.harvest_days
|
||||||
|
- taxonomy.vocabulary.plant_type
|
||||||
|
enforced:
|
||||||
|
module:
|
||||||
|
- farm_plant_type
|
||||||
|
id: taxonomy_term.plant_type.harvest_days
|
||||||
|
field_name: harvest_days
|
||||||
|
entity_type: taxonomy_term
|
||||||
|
bundle: plant_type
|
||||||
|
label: 'Days of harvest'
|
||||||
|
description: ''
|
||||||
|
required: false
|
||||||
|
translatable: false
|
||||||
|
default_value: { }
|
||||||
|
default_value_callback: ''
|
||||||
|
settings:
|
||||||
|
min: 1
|
||||||
|
max: null
|
||||||
|
prefix: ''
|
||||||
|
suffix: ' day| days'
|
||||||
|
field_type: integer
|
|
@ -18,7 +18,7 @@ translatable: false
|
||||||
default_value: { }
|
default_value: { }
|
||||||
default_value_callback: ''
|
default_value_callback: ''
|
||||||
settings:
|
settings:
|
||||||
min: null
|
min: 1
|
||||||
max: null
|
max: null
|
||||||
prefix: ''
|
prefix: ''
|
||||||
suffix: ' day| days'
|
suffix: ' day| days'
|
||||||
|
|
|
@ -18,7 +18,7 @@ translatable: false
|
||||||
default_value: { }
|
default_value: { }
|
||||||
default_value_callback: ''
|
default_value_callback: ''
|
||||||
settings:
|
settings:
|
||||||
min: null
|
min: 1
|
||||||
max: null
|
max: null
|
||||||
prefix: ''
|
prefix: ''
|
||||||
suffix: ' day| days'
|
suffix: ' day| days'
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
langcode: en
|
||||||
|
status: true
|
||||||
|
dependencies:
|
||||||
|
enforced:
|
||||||
|
module:
|
||||||
|
- farm_plant_type
|
||||||
|
module:
|
||||||
|
- taxonomy
|
||||||
|
id: taxonomy_term.harvest_days
|
||||||
|
field_name: harvest_days
|
||||||
|
entity_type: taxonomy_term
|
||||||
|
type: integer
|
||||||
|
settings:
|
||||||
|
unsigned: true
|
||||||
|
size: normal
|
||||||
|
module: core
|
||||||
|
locked: false
|
||||||
|
cardinality: 1
|
||||||
|
translatable: true
|
||||||
|
indexes: { }
|
||||||
|
persist_with_no_fields: false
|
||||||
|
custom_storage: false
|
|
@ -4,4 +4,5 @@ type: module
|
||||||
package: farmOS Taxonomies
|
package: farmOS Taxonomies
|
||||||
core_version_requirement: ^10
|
core_version_requirement: ^10
|
||||||
dependencies:
|
dependencies:
|
||||||
|
- drupal:image
|
||||||
- drupal:taxonomy
|
- drupal:taxonomy
|
||||||
|
|
|
@ -0,0 +1,101 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Post update hooks for the farm_plant_type module.
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Drupal\field\Entity\FieldConfig;
|
||||||
|
use Drupal\field\Entity\FieldStorageConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the minimum value of maturity_days and transplant_days to 1.
|
||||||
|
*/
|
||||||
|
function farm_plant_type_post_update_min_1_day(&$sandbox) {
|
||||||
|
// Set the min setting of both fields to 1.
|
||||||
|
$field_names = [
|
||||||
|
'maturity_days',
|
||||||
|
'transplant_days',
|
||||||
|
];
|
||||||
|
foreach ($field_names as $field_name) {
|
||||||
|
$field = FieldConfig::load('taxonomy_term.plant_type.' . $field_name);
|
||||||
|
if (!empty($field)) {
|
||||||
|
$field->setSetting('min', 1);
|
||||||
|
$field->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete any zero values from the database.
|
||||||
|
$tables = [
|
||||||
|
'taxonomy_term__maturity_days' => 'maturity_days_value',
|
||||||
|
'taxonomy_term__transplant_days' => 'transplant_days_value',
|
||||||
|
'taxonomy_term_revision__maturity_days' => 'maturity_days_value',
|
||||||
|
'taxonomy_term_revision__transplant_days' => 'transplant_days_value',
|
||||||
|
];
|
||||||
|
foreach ($tables as $table => $column) {
|
||||||
|
\Drupal::database()
|
||||||
|
->query('DELETE FROM {' . $table . '} WHERE ' . $column . ' = 0');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add harvest_days field to plant_type terms.
|
||||||
|
*/
|
||||||
|
function farm_plant_type_post_update_add_harvest_days(&$sandbox) {
|
||||||
|
$field_storage = FieldStorageConfig::create([
|
||||||
|
'id' => 'taxonomy_term.harvest_days',
|
||||||
|
'field_name' => 'harvest_days',
|
||||||
|
'entity_type' => 'taxonomy_term',
|
||||||
|
'type' => 'integer',
|
||||||
|
'settings' => [
|
||||||
|
'unsigned' => TRUE,
|
||||||
|
'size' => 'normal',
|
||||||
|
],
|
||||||
|
'module' => 'core',
|
||||||
|
'locked' => FALSE,
|
||||||
|
'cardinality' => 1,
|
||||||
|
'indexes' => [],
|
||||||
|
'persist_with_no_fields' => FALSE,
|
||||||
|
'custom_storage' => FALSE,
|
||||||
|
'dependencies' => [
|
||||||
|
'enforced' => [
|
||||||
|
'module' => [
|
||||||
|
'farm_plant_type',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'module' => [
|
||||||
|
'taxonomy',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
$field_storage->save();
|
||||||
|
$field = FieldConfig::create([
|
||||||
|
'id' => 'taxonomy_term.plant_type.harvest_days',
|
||||||
|
'field_name' => 'harvest_days',
|
||||||
|
'entity_type' => 'taxonomy_term',
|
||||||
|
'bundle' => 'plant_type',
|
||||||
|
'label' => 'Days of harvest',
|
||||||
|
'description' => '',
|
||||||
|
'required' => FALSE,
|
||||||
|
'default_value' => [],
|
||||||
|
'default_value_callback' => '',
|
||||||
|
'settings' => [
|
||||||
|
'min' => 1,
|
||||||
|
'max' => NULL,
|
||||||
|
'prefix' => '',
|
||||||
|
'suffix' => ' day| days',
|
||||||
|
],
|
||||||
|
'field_type' => 'integer',
|
||||||
|
'dependencies' => [
|
||||||
|
'enforced' => [
|
||||||
|
'module' => [
|
||||||
|
'farm_plant_type',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'module' => [
|
||||||
|
'taxonomy',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
$field->save();
|
||||||
|
}
|
Loading…
Reference in New Issue