From 890ab08f1ec42b565c99e544454f19ffeb40e860 Mon Sep 17 00:00:00 2001 From: virtualzone Date: Wed, 28 Aug 2024 21:08:13 +0200 Subject: [PATCH] Fix issue #262 --- admin-ui/src/pages/locations/[id].tsx | 15 ++++++++++----- server/res/version.txt | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/admin-ui/src/pages/locations/[id].tsx b/admin-ui/src/pages/locations/[id].tsx index 58e8dabc..44f0f4f1 100644 --- a/admin-ui/src/pages/locations/[id].tsx +++ b/admin-ui/src/pages/locations/[id].tsx @@ -124,19 +124,23 @@ class EditLocation extends React.Component { } saveSpaces = async () => { + // Fetch the latest list of spaces from the server to avoid overwriting let spaces = await Space.list(this.entity.id); + + // For spaces on the "to be deleted"-list, delete them and clear the list afterwards for (let space of spaces) { if (this.state.deleteIds.indexOf(space.id) > -1) { await space.delete(); } } + this.setState({deleteIds: []}); + + // Sync all other spaces to the server for (let item of this.state.spaces) { let space: Space = new Space(); - spaces.forEach((spaceItem) => { - if (item.id === spaceItem.id) { - space = spaceItem - } - }); + if (item.id) { + space.id = item.id; + } space.locationId = this.entity.id; space.name = item.name; space.x = item.x; @@ -145,6 +149,7 @@ class EditLocation extends React.Component { space.height = parseInt(item.height.replace(/^\D+/g, '')); space.rotation = item.rotation; await space.save(); + item.id = space.id; // Store id (if created) } } diff --git a/server/res/version.txt b/server/res/version.txt index c1af674e..7df3a13a 100644 --- a/server/res/version.txt +++ b/server/res/version.txt @@ -1 +1 @@ -1.19.0 \ No newline at end of file +1.19.1 \ No newline at end of file