X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Flayout_builder%2Fsrc%2FController%2FLayoutBuilderController.php;h=00bb40261911761f30bc0a22dcf0082578ce97e8;hb=1c1cb0980bfa6caf0c24cce671b6bb541dc87583;hp=c01fea544b2bf3320b5f871d71738cdf7d541b7d;hpb=0bf8d09d2542548982e81a441b1f16e75873a04f;p=yaffs-website diff --git a/web/core/modules/layout_builder/src/Controller/LayoutBuilderController.php b/web/core/modules/layout_builder/src/Controller/LayoutBuilderController.php index c01fea544..00bb40261 100644 --- a/web/core/modules/layout_builder/src/Controller/LayoutBuilderController.php +++ b/web/core/modules/layout_builder/src/Controller/LayoutBuilderController.php @@ -2,6 +2,7 @@ namespace Drupal\layout_builder\Controller; +use Drupal\Core\Ajax\AjaxHelperTrait; use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Drupal\Core\Messenger\MessengerInterface; use Drupal\Core\Plugin\PluginFormInterface; @@ -24,6 +25,7 @@ class LayoutBuilderController implements ContainerInjectionInterface { use LayoutBuilderContextTrait; use StringTranslationTrait; + use AjaxHelperTrait; /** * The layout tempstore repository. @@ -90,6 +92,11 @@ class LayoutBuilderController implements ContainerInjectionInterface { $this->prepareLayout($section_storage, $is_rebuilding); $output = []; + if ($this->isAjax()) { + $output['status_messages'] = [ + '#type' => 'status_messages', + ]; + } $count = 0; for ($i = 0; $i < $section_storage->count(); $i++) { $output[] = $this->buildAddSectionLink($section_storage, $count); @@ -114,6 +121,11 @@ class LayoutBuilderController implements ContainerInjectionInterface { * Indicates if the layout is rebuilding. */ protected function prepareLayout(SectionStorageInterface $section_storage, $is_rebuilding) { + // If the layout has pending changes, add a warning. + if ($this->layoutTempstoreRepository->has($section_storage)) { + $this->messenger->addWarning($this->t('You have unsaved changes.')); + } + // Only add sections if the layout is new and empty. if (!$is_rebuilding && $section_storage->count() === 0) { $sections = []; @@ -269,7 +281,7 @@ class LayoutBuilderController implements ContainerInjectionInterface { ], 'remove' => [ '#type' => 'link', - '#title' => $this->t('Remove section'), + '#title' => $this->t('Remove section @section', ['@section' => $delta + 1]), '#url' => Url::fromRoute('layout_builder.remove_section', [ 'section_storage_type' => $storage_type, 'section_storage' => $storage_id,