Przywrócono zmianę nazwy scenerii i usuwanie

This commit is contained in:
2022-08-18 12:08:11 +02:00
parent c799b47698
commit 64eca66fd8
6 changed files with 83 additions and 64 deletions
+1 -1
View File
@@ -226,7 +226,7 @@ export default defineComponent({
this.store.stationList[index]['routes'] = routeString;
this.currentRoutes = routeString;
this.addChange(this.store.currentStation!.name, 'routes', this.routeBackup, routeString);
this.addChange(this.store.currentStation!, 'routes', this.routeBackup, routeString);
},
},
});
+14 -6
View File
@@ -108,11 +108,16 @@ export default defineComponent({
async updateListToDb() {
try {
const mappedChangeList = Object.entries(this.store.changeList).map(([k, v]) => {
return { name: k, ...v };
const mappedChangeList = Object.entries(this.store.changeList).map(([id, v]) => {
if (/^#/.test(id)) {
delete v.id;
return { ...v };
}
return { id: id, ...v };
});
await axios.post(
const response = await axios.post(
`${this.API_URL}/manager/updateSceneryList`,
{
changeList: mappedChangeList,
@@ -127,10 +132,12 @@ export default defineComponent({
}
);
console.log(response.data);
alert('Zapisano do bazy!');
this.loadData();
} catch (error) {
this.store.alertMessage = 'Ups! Wystąpił błąd podczas zapisywania danych!';
this.store.alertMessage = 'Ups! Wystąpił błąd podczas zapisywania danych!';
}
},
@@ -162,10 +169,11 @@ export default defineComponent({
checkpoints: '',
authors: '',
availability: 'default',
id: `#${Math.random().toString(32).substring(2)}`,
};
this.store.changeList[name] = { ...newSt };
this.store.changeBackupList[name] = null;
this.store.changeList[newSt.id] = { ...newSt };
this.store.changeBackupList[newSt.id] = null;
this.store.searchedSceneryName = name;
this.store.unsavedChanges = true;