diff --git a/modules/core/ui/location/config/install/farm_map.map_type.locations.yml b/modules/core/ui/location/config/install/farm_map.map_type.locations.yml new file mode 100644 index 000000000..63423b105 --- /dev/null +++ b/modules/core/ui/location/config/install/farm_map.map_type.locations.yml @@ -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: { } diff --git a/modules/core/ui/location/farm_ui_location.info.yml b/modules/core/ui/location/farm_ui_location.info.yml index 53a49d4b9..6651ae946 100644 --- a/modules/core/ui/location/farm_ui_location.info.yml +++ b/modules/core/ui/location/farm_ui_location.info.yml @@ -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 diff --git a/modules/core/ui/location/farm_ui_location.post_update.php b/modules/core/ui/location/farm_ui_location.post_update.php new file mode 100644 index 000000000..24b765927 --- /dev/null +++ b/modules/core/ui/location/farm_ui_location.post_update.php @@ -0,0 +1,33 @@ + 'locations', + 'label' => 'Locations', + 'description' => 'The farmOS locations map.', + 'behaviors' => [ + 'location', + ], + 'options' => [], + 'dependencies' => [ + 'enforced' => [ + 'module' => [ + 'farm_ui_location', + ], + ], + ], + ]); + $map_type->save(); +} diff --git a/modules/core/ui/location/src/Form/LocationHierarchyForm.php b/modules/core/ui/location/src/Form/LocationHierarchyForm.php index 4cbe3b1ce..c32760aef 100644 --- a/modules/core/ui/location/src/Form/LocationHierarchyForm.php +++ b/modules/core/ui/location/src/Form/LocationHierarchyForm.php @@ -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',