clean install

This commit is contained in:
matze committed 2024-12-10 15:08:16 +01:00
commit e14eb2d8fd
31193 files changed
+3555714

No files matched your search

@@ -0,0 +1,34 @@
(function () {
farmOS.map.behaviors.quick_movement = {
attach: function (instance) {
// Create a layer for the current asset location.
var opts = {
title: 'Current Location',
color: 'blue',
};
instance.currentLocationLayer = instance.addLayer('vector', opts);
// If an asset geometry was pre-populated, add it to the layer.
if (instance.farmMapSettings.behaviors.quick_movement.asset_geometry) {
this.updateAssetGeometry(instance, instance.farmMapSettings.behaviors.quick_movement.asset_geometry)
}
},
// When updating asset geometry, update the current location layer.
updateAssetGeometry: function (instance, wkt) {
// Clear features from the layer.
instance.currentLocationLayer.getSource().clear();
// If WKT is not empty, add features to the layer and zoom.
if (wkt) {
instance.currentLocationLayer.getSource().addFeatures(instance.readFeatures('wkt', wkt));
instance.zoomToLayer(instance.currentLocationLayer);
}
},
// Make sure this runs after farmOS.map.behaviors.wkt.
weight: 101,
};
}());
@@ -0,0 +1,32 @@
(function (Drupal) {
Drupal.behaviors.quick_movement = {
attach: function (context, settings) {
// Only run this when the asset geometry or location geometry wrappers
// are loaded/reloaded.
if (!context.dataset || !(context.dataset.movementGeometry === 'asset-geometry' || context.dataset.movementGeometry === 'location-geometry')) {
return;
}
// Get WKT from the hidden input field.
var wkt = context.querySelector('input').value;
// Get the farmOS-map element and instance.
var element = context.parentElement.querySelector('[data-drupal-selector="edit-geometry-map"]');
var instance = farmOS.map.instances[farmOS.map.targetIndex(element)];
// If this is asset geometry, refresh the map asset geometry.
if (context.dataset.movementGeometry === 'asset-geometry') {
farmOS.map.behaviors.quick_movement.updateAssetGeometry(instance, wkt);
}
// If this is location geometry, copy WKT into the map's value field and
// dispatch the input event so that the input behavior refreshes the map.
if (context.dataset.movementGeometry === 'location-geometry') {
var input = context.parentElement.querySelector('[data-drupal-selector="edit-geometry-value"]');
input.value = wkt;
input.dispatchEvent(new Event('input'));
}
}
};
}(Drupal));