From e5da8b1b731ecc4d8d512d333ab74872f6e7eb94 Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Thu, 14 Apr 2022 14:07:49 +0200 Subject: [PATCH] DashboardsController: Perform a full reload when the drop action couldn't be performed successfully --- application/controllers/DashboardsController.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/application/controllers/DashboardsController.php b/application/controllers/DashboardsController.php index df6f27630..e172758e0 100644 --- a/application/controllers/DashboardsController.php +++ b/application/controllers/DashboardsController.php @@ -298,6 +298,7 @@ class DashboardsController extends CompatController } } + $duplicatedError = false; foreach ($dashboards as $home => $value) { if (! $this->dashboard->hasEntry($home)) { Notification::error(sprintf(t('Dashboard home "%s" not found'), $home)); @@ -329,6 +330,8 @@ class DashboardsController extends CompatController $pane->getTitle(), $home->getTitle() )); + + $duplicatedError = true; break; } @@ -359,6 +362,8 @@ class DashboardsController extends CompatController $dashlet, $pane->getTitle() )); + + $duplicatedError = true; break; } @@ -374,6 +379,12 @@ class DashboardsController extends CompatController } } + if ($duplicatedError) { + // Even though the drop action couldn't be performed successfully from our server, Sortable JS has + // already dropped the draggable element though, so we need to redirect here to undo it. + $this->redirectNow(Dashboard::BASE_ROUTE . '/settings'); + } + $this->createTabs(); $this->dashboard->activate('dashboard_settings'); $this->sendMultipartUpdate(); @@ -426,6 +437,8 @@ class DashboardsController extends CompatController )); $this->content->getAttributes()->add('class', 'dashboard-manager'); + $this->controls->getAttributes()->add('class', 'dashboard-manager-controls'); + $this->addContent(new Settings($this->dashboard)); }