Skip to content
Snippets Groups Projects

ISTWCMS-4866: moving the heading selector for ec outside the individual ec...

1 file
+ 21
20
Compare changes
  • Side-by-side
  • Inline
@@ -97,7 +97,6 @@ class UwCblExpandCollapse extends BlockBase implements ContainerFactoryPluginInt
// Set the variables to be used in the template.
$exp_col['items'][] = [
'groups' => $render,
'heading_selector' => $ec['heading_selector'],
'heading_text' => $node->label(),
];
}
@@ -115,6 +114,9 @@ class UwCblExpandCollapse extends BlockBase implements ContainerFactoryPluginInt
// Set the uuid so that we can handle multiple E/C.
$exp_col['uuid'] = uniqid();
// Get the heading selector from the black configuration.
$exp_col['heading_selector'] = $this->configuration['heading_selector'];
return [
'#theme' => 'uw_block_expand_collapse',
'#exp_col' => $exp_col,
@@ -189,13 +191,27 @@ class UwCblExpandCollapse extends BlockBase implements ContainerFactoryPluginInt
'#suffix' => '</div>',
];
// The heading selector element.
$form['items_fieldset']['heading_selector'] = [
'#title' => $this->t('Heading selector'),
'#type' => 'select',
'#options' => [
'h2' => $this->t('h2'),
'h3' => $this->t('h3'),
'h4' => $this->t('h4'),
'h5' => $this->t('h5'),
'h6' => $this->t('h6'),
],
'#default_value' => $ecs['heading_selector'] ?? '',
'#required' => TRUE,
];
// Build the table.
$form['items_fieldset']['items'] = [
'#type' => 'table',
'#header' => [
'',
$this->t('Group'),
$this->t('Heading selector'),
'',
$this->t('Weight'),
],
@@ -299,23 +315,6 @@ class UwCblExpandCollapse extends BlockBase implements ContainerFactoryPluginInt
'#markup' => $links,
];
// The heading selector element.
$settings['heading_selector'] = [
'#type' => 'select',
'#options' => [
'h2' => $this->t('h2'),
'h3' => $this->t('h3'),
'h4' => $this->t('h4'),
'h5' => $this->t('h5'),
'h6' => $this->t('h5'),
],
'#default_value' => $ecs[$i]['heading_selector'] ?? '',
'#title' => '',
'#required' => TRUE,
'#prefix' => '<div class="uw-exp-col__heading-selector">',
'#suffix' => '</div>',
];
// The add expand/collapse remove group button.
$settings['button'] = [
'#type' => 'submit',
@@ -502,6 +501,9 @@ class UwCblExpandCollapse extends BlockBase implements ContainerFactoryPluginInt
// Get the items from the form_state.
$items = $values['items_fieldset']['items'];
// Set the heading selector.
$this->configuration['heading_selector'] = $values['items_fieldset']['heading_selector'];
// Setup ecs array, we need to default to null in case
// nothing is submitted in the form.
$ecs = [];
@@ -510,7 +512,6 @@ class UwCblExpandCollapse extends BlockBase implements ContainerFactoryPluginInt
// in the ecs block config.
foreach ($items as $item) {
$ecs[] = [
'heading_selector' => $item['heading_selector'],
'group' => $item['group_info']['group'][0]['target_id'],
];
}
Loading