mirror of
https://github.com/farmOS/farmOS.git
synced 2024-02-23 11:37:38 +01:00
Issue #3232237 by paul121: Allow the map widget textarea to be hidden
Add display_raw_geometry setting to the map widget.
This commit is contained in:
parent
462f606625
commit
71159d83c3
|
@ -3,7 +3,7 @@
|
|||
attach: function (instance) {
|
||||
instance.editAttached.then(() => {
|
||||
instance.edit.wktOn('featurechange', function(wkt) {
|
||||
instance.map.getTargetElement().parentElement.querySelector('textarea').value = wkt;
|
||||
instance.map.getTargetElement().parentElement.querySelector('[data-map-geometry-field]').value = wkt;
|
||||
});
|
||||
});
|
||||
},
|
||||
|
|
|
@ -102,6 +102,7 @@ class GeofieldWidget extends GeofieldBaseWidget {
|
|||
*/
|
||||
public static function defaultSettings() {
|
||||
return [
|
||||
'display_raw_geometry' => TRUE,
|
||||
'populate_file_field' => FALSE,
|
||||
] + parent::defaultSettings();
|
||||
}
|
||||
|
@ -112,6 +113,12 @@ class GeofieldWidget extends GeofieldBaseWidget {
|
|||
public function settingsForm(array $form, FormStateInterface $form_state) {
|
||||
$elements = parent::settingsForm($form, $form_state);
|
||||
|
||||
$elements['display_raw_geometry'] = [
|
||||
'#type' => 'checkbox',
|
||||
'#title' => $this->t('Display raw geometry'),
|
||||
'#default_value' => $this->getSetting('display_raw_geometry'),
|
||||
];
|
||||
|
||||
$elements['populate_file_field'] = [
|
||||
'#type' => 'textfield',
|
||||
'#title' => $this->t('File field to populate geometry from.'),
|
||||
|
@ -156,10 +163,14 @@ class GeofieldWidget extends GeofieldBaseWidget {
|
|||
];
|
||||
|
||||
// Add a textarea for the WKT value.
|
||||
$display_raw_geometry = $this->getSetting('display_raw_geometry');
|
||||
$element['value'] = [
|
||||
'#type' => 'textarea',
|
||||
'#type' => $display_raw_geometry ? 'textarea' : 'hidden',
|
||||
'#title' => $this->t('Geometry'),
|
||||
'#default_value' => $current_value,
|
||||
'#attributes' => [
|
||||
'data-map-geometry-field' => TRUE,
|
||||
],
|
||||
];
|
||||
|
||||
// Add an option to populate geometry using files field.
|
||||
|
|
Loading…
Reference in a new issue