Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISSUE-387: always pass viewer_overrides as part of the DrupalSettings to JS #388

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Plugin/Field/FieldFormatter/StrawberryMediaFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,8 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
'#default_value' => $this->getSetting('webannotations_betterpolygon'),
'#states' => [
'visible' => [
[':input[data-formatter-selector="webannotations"]' => ['checked' => TRUE]],
'and',
[':input[data-formatter-selector="webannotations-tool"]' => ['!value' => "rect"]],
':input[data-formatter-selector="webannotations"]' => ['checked' => TRUE],
':input[data-formatter-selector="webannotations-tool"]' => ['!value' => "rect"],
],
],
],
Expand Down Expand Up @@ -463,6 +462,8 @@ protected function generateElementForItem(int $delta, FieldItemListInterface $it
$elements[$delta]['media' . $i]['#attached']['drupalSettings']['format_strawberryfield']['openseadragon'][$uniqueid]['width'] = $max_width_css;
$elements[$delta]['media' . $i]['#attached']['drupalSettings']['format_strawberryfield']['openseadragon'][$uniqueid]['dr:uuid'] = $file->uuid();
$elements[$delta]['media' . $i]['#attached']['drupalSettings']['format_strawberryfield']['openseadragon'][$uniqueid]['icons_prefixurl'] = $icons_prefixurl;
$elements[$delta]['media' . $i]['#attached']['drupalSettings']['format_strawberryfield']['openseadragon'][$uniqueid]['viewer_overrides'] = $viewer_overrides;

// Used to keep annotations around during edit.
// Note: Since View modes are cached, if no change to the NODE
// this will be served from a cache! mmm.
Expand All @@ -473,7 +474,6 @@ protected function generateElementForItem(int $delta, FieldItemListInterface $it
$elements[$delta]['media' . $i]['#attached']['drupalSettings']['format_strawberryfield']['openseadragon'][$uniqueid]['webannotations_opencv'] = (boolean) $webannotations_opencv ?? FALSE;
$elements[$delta]['media' . $i]['#attached']['drupalSettings']['format_strawberryfield']['openseadragon'][$uniqueid]['webannotations_betterpolygon'] = (boolean) $webannotations_betterpolygon ?? FALSE;
$elements[$delta]['media' . $i]['#attached']['drupalSettings']['format_strawberryfield']['openseadragon'][$uniqueid]['webannotations_georeferencewidget'] = (boolean) $webannotations_georeferencewidget ?? FALSE;
$elements[$delta]['media' . $i]['#attached']['drupalSettings']['format_strawberryfield']['openseadragon'][$uniqueid]['viewer_overrides'] = $viewer_overrides;
// This also never runs if cached. So after deletion we better
// call the controller!
if (!empty($jsondata['ap:annotationCollection']) && is_array($jsondata['ap:annotationCollection'])) {
Expand Down