From be4d1ce47104478f1e0f82a840fc90b36223de53 Mon Sep 17 00:00:00 2001 From: berliner Date: Tue, 24 Dec 2024 13:44:22 +0100 Subject: [PATCH] HPC-9987: Keep supporting legacy labels --- .../Plugin/ConfigurationContainerItem/AttachmentData.php | 5 +++++ .../src/Plugin/ConfigurationContainerItem/DataPoint.php | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/html/modules/custom/ghi_blocks/src/Plugin/ConfigurationContainerItem/AttachmentData.php b/html/modules/custom/ghi_blocks/src/Plugin/ConfigurationContainerItem/AttachmentData.php index f595367bf..d3707b96f 100644 --- a/html/modules/custom/ghi_blocks/src/Plugin/ConfigurationContainerItem/AttachmentData.php +++ b/html/modules/custom/ghi_blocks/src/Plugin/ConfigurationContainerItem/AttachmentData.php @@ -136,6 +136,11 @@ public function buildForm($element, FormStateInterface $form_state) { $element['label']['#access'] = !$attachment_select_mode; if ($attachment) { + // Move legacy labels into the data point and hide default label for + // configuration items. + if (!empty($element['label']['#default_value'])) { + $data_point['label'] = $element['label']['#default_value']; + } $element['label']['#access'] = FALSE; $element['label']['#default_value'] = ''; $element['label']['#value'] = ''; diff --git a/html/modules/custom/ghi_blocks/src/Plugin/ConfigurationContainerItem/DataPoint.php b/html/modules/custom/ghi_blocks/src/Plugin/ConfigurationContainerItem/DataPoint.php index e17d8dfb4..ce4403d27 100644 --- a/html/modules/custom/ghi_blocks/src/Plugin/ConfigurationContainerItem/DataPoint.php +++ b/html/modules/custom/ghi_blocks/src/Plugin/ConfigurationContainerItem/DataPoint.php @@ -45,6 +45,13 @@ public static function create(ContainerInterface $container, array $configuratio */ public function buildForm($element, FormStateInterface $form_state) { $element = parent::buildForm($element, $form_state); + $data_point = $this->getSubmittedValue($element, $form_state, 'data_point'); + + // Move legacy labels into the data point and hide default label for + // configuration items. + if (!empty($element['label']['#default_value'])) { + $data_point['label'] = $element['label']['#default_value']; + } $element['label']['#access'] = FALSE; $element['label']['#default_value'] = ''; $element['label']['#value'] = ''; @@ -55,8 +62,6 @@ public function buildForm($element, FormStateInterface $form_state) { /** @var \Drupal\ghi_plans\ApiObjects\AttachmentPrototype\AttachmentPrototype $attachment_prototype */ $attachment_prototype = $configuration['attachment_prototype']; - $data_point = $this->getSubmittedValue($element, $form_state, 'data_point'); - $element['data_point'] = [ '#type' => 'data_point', '#element_context' => $this->getContext(),