3
0
Fork 0
mirror of https://github.com/farmOS/farmOS.git synced 2024-02-23 11:37:38 +01:00

Remove logic for adding separate land/structure type layers.

This needs to be refactored/moved to the land/structure modules.
This commit is contained in:
Michael Stenta 2021-04-08 08:03:37 -04:00
parent 165f4728da
commit 33c47849b8

View file

@ -82,52 +82,17 @@ function farm_ui_map_views_pre_render(ViewExecutable $view) {
// @todo Color each asset type cluster differently.
];
// Create individual layers for land types and structure types.
// @todo Abstract this to detect types other than land/structure?
if (in_array($bundle, ['land', 'structure'])) {
// Get fields for the bundle.
$entity_manager = \Drupal::service('entity_field.manager');
$fields = $entity_manager->getFieldStorageDefinitions('asset', $bundle);
$type_field_name = $bundle . '_type';
// Create a group for the asset bundle.
$bundle_group = t('@bundle assets', ['@bundle' => $bundle_info['label']]);
// Get valid options for the bundle_type field.
$options = options_allowed_values($fields[$type_field_name]);
foreach ($options as $option => $label) {
// Add an exposed filter for the bundle_type field.
$exposed_filters[$type_field_name . '[]'] = $option;
// Add layer for the bundle type.
$asset_layers['full'][$bundle . '_' . $option] = [
'group' => $bundle_group,
'label' => $label,
'asset_type' => $bundle,
'filters' => $exposed_filters,
// @todo Color each asset type differently.
// This was previously provided with hook_farm_area_type_info.
'color' => 'orange',
'zoom' => TRUE,
];
}
}
else {
// Add full geometry layers for the other asset types.
$asset_layers['full']['full_' . $bundle] = [
'group' => $layer_group,
'label' => $bundle_info['label'],
'asset_type' => $bundle,
'filters' => $exposed_filters,
// @todo Color each asset type differently.
// This was previously provided with hook_farm_area_type_info.
'color' => 'orange',
'zoom' => TRUE,
];
}
// Add full geometry layers for the other asset types.
$asset_layers['full']['full_' . $bundle] = [
'group' => $layer_group,
'label' => $bundle_info['label'],
'asset_type' => $bundle,
'filters' => $exposed_filters,
// @todo Color each asset type differently.
// This was previously provided with hook_farm_area_type_info.
'color' => 'orange',
'zoom' => TRUE,
];
}
// Build the map render array.