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

UHF-8835: Reverted the alter for paragraph button. #700

Merged
merged 1 commit into from
Feb 27, 2024
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
35 changes: 0 additions & 35 deletions modules/hdbt_admin_tools/hdbt_admin_tools.module
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ 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 @@ -895,40 +894,6 @@ 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.
$paragraph_add_more_buttons = [
'accordion_item_add_more',
];

foreach ($paragraph_add_more_buttons as $button) {
if (
!isset($variables['element']['#name']) ||
!str_contains($variables['element']['#name'], $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
Loading