Issue #2551091: Show map on /locations

This commit is contained in:
Michael Stenta 2024-01-17 16:38:15 -05:00
parent 1b2ce0b075
commit dc00956117
4 changed files with 54 additions and 0 deletions

View File

@ -0,0 +1,12 @@
langcode: en
status: true
dependencies:
enforced:
module:
- farm_ui_location
id: locations
label: Locations
description: 'The farmOS locations map.'
behaviors:
- locations
options: { }

View File

@ -6,5 +6,6 @@ core_version_requirement: ^10
dependencies:
- farm:farm_entity
- farm:farm_location
- farm:farm_ui_map
- farm:farm_ui_menu
- inspire_tree:inspire_tree

View File

@ -0,0 +1,33 @@
<?php
/**
* @file
* Post update functions for farm_ui_location module.
*/
use Drupal\farm_map\Entity\MapType;
/**
* Add farmOS locations map type.
*/
function farm_ui_location_post_update_add_locations_map_type(&$sandbox = NULL) {
// Create locations map type.
$map_type = MapType::create([
'id' => 'locations',
'label' => 'Locations',
'description' => 'The farmOS locations map.',
'behaviors' => [
'location',
],
'options' => [],
'dependencies' => [
'enforced' => [
'module' => [
'farm_ui_location',
],
],
],
]);
$map_type->save();
}

View File

@ -112,6 +112,14 @@ class LocationHierarchyForm extends FormBase {
*/
public function buildForm(array $form, FormStateInterface $form_state, AssetInterface $asset = NULL) {
// If no asset was specified, show a map of all locations.
if (is_null($asset)) {
$form['map'] = [
'#type' => 'farm_map',
'#map_type' => 'locations',
];
}
// Add a DIV for the JavaScript content.
$form['content'] = [
'#type' => 'html_tag',