diff --git a/core/lib/Drupal/Core/Entity/EntityListBuilder.php b/core/lib/Drupal/Core/Entity/EntityListBuilder.php index aac3763..1b42788 100644 --- a/core/lib/Drupal/Core/Entity/EntityListBuilder.php +++ b/core/lib/Drupal/Core/Entity/EntityListBuilder.php @@ -7,7 +7,7 @@ namespace Drupal\Core\Entity; -use Drupal\Core\Extension\ModuleHandlerInterface; +use Drupal\Component\Serialization\Json; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Component\Utility\String; @@ -125,6 +125,13 @@ protected function getDefaultOperations(EntityInterface $entity) { $operations['delete'] = array( 'title' => $this->t('Delete'), 'weight' => 100, + 'attributes' => array( + 'class' => array('use-ajax'), + 'data-accepts' => 'application/vnd.drupal-modal', + 'data-dialog-options' => Json::encode(array( + 'width' => 'auto', + )), + ), 'url' => $entity->urlInfo('delete-form'), ); } @@ -176,6 +183,10 @@ public function buildOperations(EntityInterface $entity) { $build = array( '#type' => 'operations', '#links' => $this->getOperations($entity), + // Allow links to use modals. + '#attached' => array( + 'library' => array('core/drupal.ajax'), + ), ); return $build; diff --git a/core/lib/Drupal/Core/Form/ConfirmFormHelper.php b/core/lib/Drupal/Core/Form/ConfirmFormHelper.php index b58078d..e3f8346 100644 --- a/core/lib/Drupal/Core/Form/ConfirmFormHelper.php +++ b/core/lib/Drupal/Core/Form/ConfirmFormHelper.php @@ -46,6 +46,9 @@ public static function buildCancelLink(ConfirmFormInterface $form, Request $requ return [ '#type' => 'link', '#title' => $form->getCancelText(), + '#attributes' => [ + 'class' => ['dialog-cancel'], + ], '#url' => $url, ]; } diff --git a/core/modules/config/src/Tests/ConfigEntityListTest.php b/core/modules/config/src/Tests/ConfigEntityListTest.php index c578ff2..68d9f3b 100644 --- a/core/modules/config/src/Tests/ConfigEntityListTest.php +++ b/core/modules/config/src/Tests/ConfigEntityListTest.php @@ -7,6 +7,7 @@ namespace Drupal\config\Tests; +use Drupal\Component\Serialization\Json; use Drupal\simpletest\WebTestBase; use Drupal\config_test\Entity\ConfigTest; use Drupal\Core\Entity\EntityStorageInterface; @@ -58,6 +59,13 @@ function testList() { 'delete' => array ( 'title' => t('Delete'), 'weight' => 100, + 'attributes' => array( + 'class' => array('use-ajax'), + 'data-accepts' => 'application/vnd.drupal-modal', + 'data-dialog-options' => Json::encode(array( + 'width' => 'auto', + )), + ), 'url' => $entity->urlInfo('delete-form'), ), ); @@ -128,6 +136,13 @@ function testList() { 'delete' => array( 'title' => t('Delete'), 'weight' => 100, + 'attributes' => array( + 'class' => array('use-ajax'), + 'data-accepts' => 'application/vnd.drupal-modal', + 'data-dialog-options' => Json::encode(array( + 'width' => 'auto', + )), + ), 'url' => $entity->urlInfo('delete-form'), ), );