Skip to content

Commit

Permalink
Merge 6c52d50 into 8f829b6
Browse files Browse the repository at this point in the history
  • Loading branch information
khalima authored Feb 26, 2024
2 parents 8f829b6 + 6c52d50 commit 4e13d9c
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 12 deletions.
33 changes: 33 additions & 0 deletions modules/hdbt_admin_tools/hdbt_admin_tools.module
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use Drupal\hdbt_admin_tools\Plugin\Field\FieldType\SelectIcon;
use Drupal\helfi_api_base\Link\UrlHelper;
use Drupal\helfi_tpr\Entity\Service;
use Drupal\node\NodeInterface;
use Drupal\paragraphs\Entity\ParagraphsType;
use Drupal\user\UserInterface;

/**
Expand Down Expand Up @@ -894,6 +895,38 @@ function hdbt_admin_tools_preprocess_links__dropbutton__operations__paragraphs(&
}
}

/**
* Implements hook_preprocess_HOOK().
*/
function hdbt_admin_tools_preprocess_input__submit__paragraph_action(array &$variables): void {

// According to UX team it's better to show the "Add @type" buttons without
// the Add word. Fix the texts from these buttons.
$add_paragraph_button = [
'field_content_0_subform_field_accordion_items_accordion_item_add_more',
];

if (
!isset($variables['element']['#name']) ||
!in_array($variables['element']['#name'], $add_paragraph_button)
) {
return;
}

// Get the label from the paragraph type and change the button label to
// match the label of the paragraph type.
$paragraph_storage = \Drupal::entityTypeManager()->getStorage('paragraphs_type');
$paragraph_type = $paragraph_storage->load($variables['element']['#bundle_machine_name']);

if (!$paragraph_type instanceof ParagraphsType) {
return;
}

$variables['attributes']['value'] = t('@type', [
'@type' => $paragraph_type->get('label'),
]);
}

/**
* Implements hook_form_alter().
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ id: paragraph.accordion.field_accordion_heading_level
field_name: field_accordion_heading_level
entity_type: paragraph
bundle: accordion
label: 'Items heading level'
description: 'Select the heading level of the accordion so that they are semantically correct with the rest of the content.'
label: 'Accordion item title level'
description: "If the accordion has a title, the level for accordion item titles should be one level lower. If the accordion doesn't have a title, the level of the accordion title will be used for accordion item titles."
required: true
translatable: false
default_value:
-
value: '2'
value: '3'
default_value_callback: ''
settings: { }
field_type: list_string
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ id: paragraph.accordion.field_accordion_title
field_name: field_accordion_title
entity_type: paragraph
bundle: accordion
label: Title
label: 'Accordion title'
description: ''
required: false
translatable: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ field_name: field_accordion_title_level
entity_type: paragraph
bundle: accordion
label: 'Accordion title level'
description: 'Select the title level of the accordion so that they are semantically correct with the rest of the content.'
description: 'Choose the appropriate level for the accordion title in the page title hierarchy. Typically, the accordion title level is H2.'
required: true
translatable: false
default_value:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
label: 'Sisällön pääotsikoiden taso'
description: 'Valitse sisällön pääotsikoiden taso siten että ne ovat semanttisesti oikealla tasolla muun sisällön suhteen.'
label: 'Haitarikohtien otsikkojen taso'
description: 'Jos haitarilla on otsikko, pitää haitarikohtien otsikkojen tason olla yhtä tasoa alempana. Jos haitarilla ei ole otsikkoa, käyttää Drupal haitarikohtien otsikkotasona haitarin otsikon tasoa.'
Original file line number Diff line number Diff line change
@@ -1 +1 @@
label: Otsikko
label: 'Haitarin otsikko'
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
label: 'Haitarin otsikon taso'
description: 'Valitse haitarin otsikon taso niin, että se on semanttisesti oikein muun sisällön kanssa.'
description: 'Valitse haitarin otsikolle sivun otsikkohierarkiaan sopiva taso. Yleensä haitarin otsikon taso on H2.'
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
label: 'Haitarin sisältökohta'
label: Haitarikohta
description: 'Yksittäinen haitarin sisältökohta, jossa on otsikko ja sisältö.'
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
declare(strict_types=1);

/**
* UHF-8135 Update accordion paragraph translations.
* UHF-8835 Update accordion paragraph translations.
*/
function helfi_paragraphs_accordion_update_9001(): void {
function helfi_paragraphs_accordion_update_9002(): void {
\Drupal::service('helfi_platform_config.config_update_helper')
->update('helfi_paragraphs_accordion');
}

0 comments on commit 4e13d9c

Please sign in to comment.