Skip to content

Commit

Permalink
Merge pull request #118 from esmero/ISSUE-98
Browse files Browse the repository at this point in the history
ISSUE-98:Fixes missing URL value in Hotspot info
  • Loading branch information
DiegoPino authored Apr 20, 2021
2 parents 57a6c43 + 5a3ac71 commit a849989
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/Element/WebformPanoramaTour.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Drupal\webform_strawberryfield\Element;

use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element\FormElement;
use Drupal\webform\Element\WebformCompositeBase;
Expand Down Expand Up @@ -837,8 +838,17 @@ public static function addHotspotSubmit(
$newid = Uuid::uuid4();
$hotspot->id = $element_name . '_' . $current_scene . '_' . $newid->toString();
if ($hotspot->type == 'url') {
$hotspot->URL = $hotspot->url;
$hotspot->type = 'info';
$externalURL = $form_state->getValue(
[$element_name, 'hotspots_temp', 'url']
);
if (UrlHelper::isValid(trim($externalURL), TRUE)) {
$hotspot->URL = $externalURL;
$hotspot->type = 'info';
}
else {
$form_state->setRebuild(TRUE);
return;
}
}
if ($hotspot->type == 'ado') {
$nodeid = $form_state->getValue(
Expand Down Expand Up @@ -880,7 +890,6 @@ public static function addHotspotSubmit(
$hotspot->text = $hotspot->text;
$hotspot->type = 'info';
}

$existing_objects[] = (array) $hotspot;

// @TODO make sure people don't add twice the same coordinates!
Expand All @@ -891,7 +900,6 @@ public static function addHotspotSubmit(
$form_state->set($all_scenes_key, $allscenes);
$form_state->setValue([$element_name, 'allscenes'], json_encode($allscenes));


} else {
// Do we alert the user? Form needs to be restarted
static::messenger()->addError(t('Something bad happened with the Tour builder, sadly you will have you restart your session.'));
Expand Down Expand Up @@ -1013,7 +1021,7 @@ public static function deleteHotSpot(array &$form, FormStateInterface $form_stat
}

$form_state->set($all_scenes_key, $allscenes);
$form_state->setValue([$element_name, 'allscenes'],json_encode($allscenes));
$form_state->setValue([$element_name, 'allscenes'], json_encode($allscenes));


} else {
Expand Down

0 comments on commit a849989

Please sign in to comment.