DashboardsController: Perform a full reload when the drop action couldn't be performed successfully

This commit is contained in:
Yonas Habteab 2022-04-14 14:07:49 +02:00
parent b39f6ad48e
commit d95c754f85

View File

@ -298,6 +298,7 @@ class DashboardsController extends CompatController
} }
} }
$duplicatedError = false;
foreach ($dashboards as $home => $value) { foreach ($dashboards as $home => $value) {
if (! $this->dashboard->hasEntry($home)) { if (! $this->dashboard->hasEntry($home)) {
Notification::error(sprintf(t('Dashboard home "%s" not found'), $home)); Notification::error(sprintf(t('Dashboard home "%s" not found'), $home));
@ -329,6 +330,8 @@ class DashboardsController extends CompatController
$pane->getTitle(), $pane->getTitle(),
$home->getTitle() $home->getTitle()
)); ));
$duplicatedError = true;
break; break;
} }
@ -359,6 +362,8 @@ class DashboardsController extends CompatController
$dashlet, $dashlet,
$pane->getTitle() $pane->getTitle()
)); ));
$duplicatedError = true;
break; 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->createTabs();
$this->dashboard->activate('dashboard_settings'); $this->dashboard->activate('dashboard_settings');
$this->sendMultipartUpdate(); $this->sendMultipartUpdate();
@ -426,6 +437,8 @@ class DashboardsController extends CompatController
)); ));
$this->content->getAttributes()->add('class', 'dashboard-manager'); $this->content->getAttributes()->add('class', 'dashboard-manager');
$this->controls->getAttributes()->add('class', 'dashboard-manager-controls');
$this->addContent(new Settings($this->dashboard)); $this->addContent(new Settings($this->dashboard));
} }