Skip to content

Commit 3c9dffb

Browse files
committed
Handled "mail" display
1 parent ff515e3 commit 3c9dffb

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

modules/os2forms_webform_maps/src/Plugin/WebformElement/WebformLeafletMapField.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,8 @@ public function defineDefaultProperties(): array {
7272
'rectangle_color' => '#3388FF',
7373

7474
// Display settings.
75-
'display_image_on' => ['html', 'pdf'],
75+
'display_image_on' => ['email', 'html', 'pdf'],
7676
'display_geojson_on' => ['text', 'html'],
77-
7877
] + parent::defineDefaultProperties();
7978
}
8079

@@ -358,6 +357,7 @@ public function form(array $form, FormStateInterface $form_state) {
358357
'#type' => 'checkboxes',
359358
'#title' => $this->t('Display image on'),
360359
'#options' => [
360+
'email' => $this->t('Email'),
361361
'html' => $this->t('HTML'),
362362
'pdf' => $this->t('PDF'),
363363
],
@@ -367,6 +367,7 @@ public function form(array $form, FormStateInterface $form_state) {
367367
'#type' => 'checkboxes',
368368
'#title' => $this->t('Display GeoJSON on'),
369369
'#options' => [
370+
'email' => $this->t('Email'),
370371
'html' => $this->t('HTML'),
371372
'pdf' => $this->t('PDF'),
372373
'text' => $this->t('Text'),
@@ -387,11 +388,14 @@ protected function formatHtmlItem(array $element, WebformSubmissionInterface $we
387388

388389
$build = [];
389390

390-
$viewMode = $options['view_mode'] ?? 'overview';
391+
$viewMode = $options['view_mode'] ?? 'results';
391392
if ('table' === $viewMode) {
392393
$viewMode = 'html';
393394
}
394-
if ('html' === $viewMode && $options['pdf']) {
395+
elseif ($options['email'] ?? FALSE) {
396+
$viewMode = 'email';
397+
}
398+
elseif ($options['pdf'] ?? FALSE) {
395399
$viewMode = 'pdf';
396400
}
397401

@@ -411,12 +415,16 @@ protected function formatHtmlItem(array $element, WebformSubmissionInterface $we
411415
'id' => $imageId,
412416
'src' => $value['image'],
413417
],
418+
'#prefix' => '<div class="os2forms-webform-maps-image">',
419+
'#suffix' => '</div>',
414420
];
415421
}
416422

417423
if ($includeGeoJson) {
418424
$build['geojson'] = [
419425
'#markup' => $value['geojson'],
426+
'#prefix' => '<div class="os2forms-webform-maps-geojson">',
427+
'#suffix' => '</div>',
420428
];
421429
}
422430

0 commit comments

Comments
 (0)