Skip to content

Commit a334f6d

Browse files
committed
Handled "mail" display
1 parent ff515e3 commit a334f6d

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ 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'],
7777

7878
] + parent::defineDefaultProperties();
@@ -358,6 +358,7 @@ public function form(array $form, FormStateInterface $form_state) {
358358
'#type' => 'checkboxes',
359359
'#title' => $this->t('Display image on'),
360360
'#options' => [
361+
'email' => $this->t('Email'),
361362
'html' => $this->t('HTML'),
362363
'pdf' => $this->t('PDF'),
363364
],
@@ -367,6 +368,7 @@ public function form(array $form, FormStateInterface $form_state) {
367368
'#type' => 'checkboxes',
368369
'#title' => $this->t('Display GeoJSON on'),
369370
'#options' => [
371+
'email' => $this->t('Email'),
370372
'html' => $this->t('HTML'),
371373
'pdf' => $this->t('PDF'),
372374
'text' => $this->t('Text'),
@@ -387,11 +389,14 @@ protected function formatHtmlItem(array $element, WebformSubmissionInterface $we
387389

388390
$build = [];
389391

390-
$viewMode = $options['view_mode'] ?? 'overview';
392+
$viewMode = $options['view_mode'] ?? 'results';
391393
if ('table' === $viewMode) {
392394
$viewMode = 'html';
393395
}
394-
if ('html' === $viewMode && $options['pdf']) {
396+
elseif ($options['email'] ?? FALSE) {
397+
$viewMode = 'email';
398+
}
399+
elseif ($options['pdf'] ?? FALSE) {
395400
$viewMode = 'pdf';
396401
}
397402

@@ -411,12 +416,16 @@ protected function formatHtmlItem(array $element, WebformSubmissionInterface $we
411416
'id' => $imageId,
412417
'src' => $value['image'],
413418
],
419+
'#prefix' => '<div class="os2forms-webform-maps-image">',
420+
'#suffix' => '</div>',
414421
];
415422
}
416423

417424
if ($includeGeoJson) {
418425
$build['geojson'] = [
419426
'#markup' => $value['geojson'],
427+
'#prefix' => '<div class="os2forms-webform-maps-geojson">',
428+
'#suffix' => '</div>',
420429
];
421430
}
422431

0 commit comments

Comments
 (0)