Skip to content
Snippets Groups Projects
Commit 090d5d13 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2136641 by damiankloip: Remove boolean usage of ajax property in Views...

Issue #2136641 by damiankloip: Remove boolean usage of ajax property in Views UI link operation building.
parent ff4a8e9f
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -1247,6 +1247,7 @@ function theme_links($variables) {
'href' => NULL,
'route_name' => NULL,
'route_parameters' => NULL,
'ajax' => NULL,
);
$class = array();
......@@ -1268,14 +1269,9 @@ function theme_links($variables) {
'#href' => $link['href'],
'#route_name' => $link['route_name'],
'#route_parameters' => $link['route_parameters'],
'#ajax' => $link['ajax'],
);
// @todo Reconcile Views usage of 'ajax' as a boolean with the rest of
// core's usage of it as an array.
if (isset($link['ajax']) && is_array($link['ajax'])) {
$link_element['#ajax'] = $link['ajax'];
}
// Handle links and ensure that the active class is added on the LIs.
if (isset($link['route_name'])) {
$variables = array(
......
......@@ -154,31 +154,17 @@ public function getOperations(EntityInterface $entity) {
// Add AJAX functionality to enable/disable operations.
foreach (array('enable', 'disable') as $op) {
if (isset($operations[$op])) {
$operations[$op]['ajax'] = TRUE;
$operations[$op]['route_name'] = 'views_ui.operation';
$operations[$op]['route_parameters'] = array('view' => $entity->id(), 'op' => $op);
// @todo Remove this when entity links use route_names.
unset($operations[$op]['href']);
}
}
return $operations;
}
/**
* {@inheritdoc}
*/
public function buildOperations(EntityInterface $entity) {
$build = parent::buildOperations($entity);
// Allow operations to specify that they use AJAX.
foreach ($build['#links'] as &$operation) {
if (!empty($operation['ajax'])) {
$operation['attributes']['class'][] = 'use-ajax';
// Enable and disable operations should use AJAX.
$operations[$op]['attributes']['class'][] = 'use-ajax';
}
}
return $build;
return $operations;
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment