Issue #2551091: Show map on /locations
This commit is contained in:
parent
1b2ce0b075
commit
dc00956117
|
@ -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: { }
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
|
@ -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',
|
||||
|
|
Loading…
Reference in New Issue