Rename the geofield map behavior to input.

This commit is contained in:
Michael Stenta 2022-06-16 14:06:47 -04:00
parent 36cc27bbf1
commit a5d442ba63
6 changed files with 51 additions and 16 deletions

View File

@ -1,11 +0,0 @@
langcode: en
status: true
dependencies:
enforced:
module:
- farm_map
id: geofield
label: Geofield
description: 'Copies map layer data into a form textarea.'
library: 'farm_map/behavior_geofield'
settings: { }

View File

@ -0,0 +1,11 @@
langcode: en
status: true
dependencies:
enforced:
module:
- farm_map
id: input
label: Input
description: 'Syncs editable map layer data into a form input.'
library: 'farm_map/behavior_input'
settings: { }

View File

@ -30,9 +30,9 @@ behavior_wkt:
dependencies:
- core/drupalSettings
- farm_map/farm_map
behavior_geofield:
behavior_input:
js:
js/farmOS.map.behaviors.geofield.js: { }
js/farmOS.map.behaviors.input.js: { }
dependencies:
- farm_map/farm_map
behavior_enable_side_panel:

View File

@ -0,0 +1,35 @@
<?php
/**
* @file
* Post update hooks for the farm_map module.
*/
use Drupal\farm_map\Entity\MapBehavior;
/**
* Rename geofield map behavior to input.
*/
function farm_map_post_update_map_input_behavior(&$sandbox) {
// Create the new input behavior.
$input_behavior = MapBehavior::create([
'id' => 'input',
'label' => 'Input',
'description' => 'Syncs editable map layer data into a form input.',
'library' => 'farm_map/behavior_input',
'settings' => [],
'dependencies' => [
'enforced' => [
'module' => [
'farm_map',
],
],
],
]);
$input_behavior->save();
// Delete the geofield behavior.
$geofield_behavior = MapBehavior::load('geofield');
$geofield_behavior->delete();
}

View File

@ -1,5 +1,5 @@
(function () {
farmOS.map.behaviors.geofield = {
farmOS.map.behaviors.input = {
attach: function (instance) {
instance.editAttached.then(() => {
instance.edit.wktOn('featurechange', function(wkt) {

View File

@ -61,10 +61,10 @@ class MapRenderEventSubscriber implements EventSubscriberInterface {
$event->addBehavior('wkt');
}
// Add the wkt and geofield behavior to the geofield_widget map.
// Add the wkt and input behavior to the geofield_widget map.
if (in_array($event->getMapType()->id(), ['geofield_widget'])) {
$event->addBehavior('wkt');
$event->addBehavior('geofield');
$event->addBehavior('input');
}
// Get whether the side panel should be enabled.