mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-09-26 03:09:10 +02:00
Update priority order of the widget being moved properly
This commit is contained in:
parent
be973d29e2
commit
a8a4738944
@ -192,7 +192,9 @@ class DashboardHome extends BaseDashboard implements Sortable
|
|||||||
/** @var Pane $pane */
|
/** @var Pane $pane */
|
||||||
foreach ($panes as $pane) {
|
foreach ($panes as $pane) {
|
||||||
$uuid = Dashboard::getSHA1($user->getUsername() . $this->getName() . $pane->getName());
|
$uuid = Dashboard::getSHA1($user->getUsername() . $this->getName() . $pane->getName());
|
||||||
if (! $this->hasEntry($pane->getName()) && (! $origin || ! $origin->hasEntry($pane->getName()))) {
|
$movePane = $origin && $origin->hasEntry($pane->getName());
|
||||||
|
|
||||||
|
if (! $this->hasEntry($pane->getName()) && ! $movePane) {
|
||||||
$conn->insert(Pane::TABLE, [
|
$conn->insert(Pane::TABLE, [
|
||||||
'id' => $uuid,
|
'id' => $uuid,
|
||||||
'home_id' => $this->getUuid(),
|
'home_id' => $this->getUuid(),
|
||||||
@ -200,7 +202,7 @@ class DashboardHome extends BaseDashboard implements Sortable
|
|||||||
'label' => $pane->getTitle(),
|
'label' => $pane->getTitle(),
|
||||||
'priority' => $order++
|
'priority' => $order++
|
||||||
]);
|
]);
|
||||||
} elseif (! $this->hasEntry($pane->getName()) || ! $origin || ! $origin->hasEntry($pane->getName())) {
|
} elseif (! $this->hasEntry($pane->getName()) || ! $movePane) {
|
||||||
$filterCondition = [
|
$filterCondition = [
|
||||||
'id = ?' => $pane->getUuid(),
|
'id = ?' => $pane->getUuid(),
|
||||||
'home_id = ?' => $this->getUuid()
|
'home_id = ?' => $this->getUuid()
|
||||||
@ -217,7 +219,7 @@ class DashboardHome extends BaseDashboard implements Sortable
|
|||||||
'id' => $uuid,
|
'id' => $uuid,
|
||||||
'home_id' => $this->getUuid(),
|
'home_id' => $this->getUuid(),
|
||||||
'label' => $pane->getTitle(),
|
'label' => $pane->getTitle(),
|
||||||
'priority' => $pane->getPriority()
|
'priority' => $movePane ? $order++ : $pane->getPriority()
|
||||||
], $filterCondition);
|
], $filterCondition);
|
||||||
} else {
|
} else {
|
||||||
// Failed to move the pane! Should have been handled already by the caller
|
// Failed to move the pane! Should have been handled already by the caller
|
||||||
|
@ -183,8 +183,9 @@ class Pane extends BaseDashboard implements Sortable
|
|||||||
$url = $dashlet->getUrl();
|
$url = $dashlet->getUrl();
|
||||||
$url = is_string($url) ?: $url->getRelativeUrl();
|
$url = is_string($url) ?: $url->getRelativeUrl();
|
||||||
$uuid = Dashboard::getSHA1($user . $home->getName() . $this->getName() . $dashlet->getName());
|
$uuid = Dashboard::getSHA1($user . $home->getName() . $this->getName() . $dashlet->getName());
|
||||||
|
$moveDashlet = $origin && $origin->hasEntry($dashlet->getName());
|
||||||
|
|
||||||
if (! $this->hasEntry($dashlet->getName()) && (! $origin || ! $origin->hasEntry($dashlet->getName()))) {
|
if (! $this->hasEntry($dashlet->getName()) && ! $moveDashlet) {
|
||||||
$conn->insert(Dashlet::TABLE, [
|
$conn->insert(Dashlet::TABLE, [
|
||||||
'id' => $uuid,
|
'id' => $uuid,
|
||||||
'dashboard_id' => $this->getUuid(),
|
'dashboard_id' => $this->getUuid(),
|
||||||
@ -211,8 +212,7 @@ class Pane extends BaseDashboard implements Sortable
|
|||||||
'module_dashlet_id' => $systemUuid
|
'module_dashlet_id' => $systemUuid
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
} elseif (! $this->hasEntry($dashlet->getName()) || ! $origin
|
} elseif (! $this->hasEntry($dashlet->getName()) || ! $moveDashlet) {
|
||||||
|| ! $origin->hasEntry($dashlet->getName())) {
|
|
||||||
$filterCondition = [
|
$filterCondition = [
|
||||||
'id = ?' => $dashlet->getUuid(),
|
'id = ?' => $dashlet->getUuid(),
|
||||||
'dashboard_id = ?' => $this->getUuid()
|
'dashboard_id = ?' => $this->getUuid()
|
||||||
@ -230,7 +230,7 @@ class Pane extends BaseDashboard implements Sortable
|
|||||||
'dashboard_id' => $this->getUuid(),
|
'dashboard_id' => $this->getUuid(),
|
||||||
'label' => $dashlet->getTitle(),
|
'label' => $dashlet->getTitle(),
|
||||||
'url' => $url,
|
'url' => $url,
|
||||||
'priority' => $dashlet->getPriority(),
|
'priority' => $moveDashlet ? $order++ : $dashlet->getPriority(),
|
||||||
'disabled' => DBUtils::bool2BoolEnum($dashlet->isDisabled())
|
'disabled' => DBUtils::bool2BoolEnum($dashlet->isDisabled())
|
||||||
], $filterCondition);
|
], $filterCondition);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user