Skip to content

Commit

Permalink
Add new experiment plan file fields
Browse files Browse the repository at this point in the history
  • Loading branch information
paul121 committed Jan 6, 2025
1 parent 80c31db commit 2e7a46d
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,10 @@ function farm_rothamsted_experiment_farm_ui_theme_field_group_items(string $enti
return [
'location' => 'locations',
'asset' => 'locations',
'columns_file' => 'file',
'column_levels_file' => 'file',
'plot_attributes_file' => 'file',
'plot_geometry_file' => 'file',
'experiment_plan_link' => 'file',
'experiment_file_link' => 'file',
'other_links' => 'file',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -945,3 +945,45 @@ function farm_rothamsted_experiment_post_update_2_19_remove_field_group(&$sandbo
}

}

function farm_rothamsted_experiment_post_update_2_24_add_file_fields(&$sandbox = NULL) {

$fields['columns_file'] = BundleFieldDefinition::create('file')
->setRevisionable(TRUE)
->setCardinality(1)
->setSettings([
'description_field' => FALSE,
'file_extensions' => 'csv',
]);
$fields['column_levels_file'] = BundleFieldDefinition::create('file')
->setRevisionable(TRUE)
->setCardinality(1)
->setSettings([
'description_field' => FALSE,
'file_extensions' => 'csv',
]);
$fields['plot_attributes_file'] = BundleFieldDefinition::create('file')
->setRevisionable(TRUE)
->setCardinality(1)
->setSettings([
'description_field' => FALSE,
'file_extensions' => 'csv',
]);
$fields['plot_geometry_file'] = BundleFieldDefinition::create('file')
->setRevisionable(TRUE)
->setCardinality(1)
->setSettings([
'description_field' => FALSE,
'file_extensions' => 'geojson',
]);

// Install each field definition.
foreach ($fields as $field_name => $field_definition) {
\Drupal::entityDefinitionUpdateManager()->installFieldStorageDefinition(
$field_name,
'plan',
'farm_rothamsted_experiment',
$field_definition,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,59 @@ public function buildFieldDefinitions() {
'description_field' => TRUE,
'file_extensions' => 'csv doc docx gz geojson gpx kml kmz logz mp3 odp ods odt ogg pdf ppt pptx tar tif tiff txt wav xls xlsx zip',
];
$fields['columns_file'] = BundleFieldDefinition::create('file')
->setLabel($this->t('Columns'))
->setRevisionable(TRUE)
->setCardinality(1)
->setSettings([
'description_field' => FALSE,
'file_extensions' => 'csv',
])
->setDisplayConfigurable('form', TRUE)
->setDisplayOptions('form', [
'region' => 'hidden',
])
->setDisplayConfigurable('view', TRUE);
$fields['column_levels_file'] = BundleFieldDefinition::create('file')
->setLabel($this->t('Column levels'))
->setRevisionable(TRUE)
->setCardinality(1)
->setSettings([
'description_field' => FALSE,
'file_extensions' => 'csv',
])
->setDisplayConfigurable('form', TRUE)
->setDisplayOptions('form', [
'region' => 'hidden',
])
->setDisplayConfigurable('view', TRUE);
$fields['plot_attributes_file'] = BundleFieldDefinition::create('file')
->setLabel($this->t('Plot attributes'))
->setRevisionable(TRUE)
->setCardinality(1)
->setSettings([
'description_field' => FALSE,
'file_extensions' => 'csv',
])
->setDisplayConfigurable('form', TRUE)
->setDisplayOptions('form', [
'region' => 'hidden',
])
->setDisplayConfigurable('view', TRUE);
$fields['plot_geometry_file'] = BundleFieldDefinition::create('file')
->setLabel($this->t('Plot geometries'))
->setRevisionable(TRUE)
->setCardinality(1)
->setSettings([
'description_field' => FALSE,
'file_extensions' => 'geojson',
])
->setDisplayConfigurable('form', TRUE)
->setDisplayOptions('form', [
'region' => 'hidden',
])
->setDisplayConfigurable('view', TRUE);

$fields['agreed_quote'] = BundleFieldDefinition::create('file')
->setLabel($this->t('Agreed Quote'))
->setDescription($this->t('The final agreed quotation for the work proposed.'))
Expand Down

0 comments on commit 2e7a46d

Please sign in to comment.