Rename the geofield map behavior to input.
This commit is contained in:
parent
36cc27bbf1
commit
a5d442ba63
|
@ -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: { }
|
|
@ -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: { }
|
|
@ -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:
|
||||
|
|
|
@ -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();
|
||||
}
|
|
@ -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) {
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue