Commit 090d5d13 authored by alexpott's avatar alexpott

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
......@@ -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;
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment