mirror of
https://github.com/Spythere/station-manager-2.0.git
synced 2026-05-03 21:48:14 +00:00
Przywrócono zmianę nazwy scenerii i usuwanie
This commit is contained in:
+36
-22
@@ -1,5 +1,6 @@
|
||||
import { defineComponent } from 'vue';
|
||||
import { useStore } from '../store';
|
||||
import { SceneryRowItem } from '../types/types';
|
||||
|
||||
export default defineComponent({
|
||||
setup() {
|
||||
@@ -9,41 +10,54 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
methods: {
|
||||
addChange(stationName: string, propName: string, oldValue: any, newValue: any) {
|
||||
addChange(sceneryData: SceneryRowItem, propName: string, oldValue: any, newValue: any) {
|
||||
if (oldValue === newValue) return;
|
||||
|
||||
if (this.store.changeList[stationName] === null || !(stationName in this.store.changeList))
|
||||
this.store.changeList[stationName] = {};
|
||||
const sceneryId = sceneryData.id;
|
||||
|
||||
if (propName === 'name') {
|
||||
const station = this.store.stationList[this.store.stationList.findIndex((v) => v.name == newValue)];
|
||||
console.log(oldValue, newValue, station);
|
||||
if (this.store.changeList[sceneryId] === null || !(sceneryId in this.store.changeList))
|
||||
this.store.changeList[sceneryId] = {};
|
||||
|
||||
this.store.changeBackupList[oldValue] = { ...station, name: oldValue };
|
||||
this.store.changeBackupList[newValue] = null;
|
||||
// if (propName === 'name') {
|
||||
// const rowStationData = this.store.stationList[this.store.stationList.findIndex((v) => v.id == sceneryId)];
|
||||
|
||||
this.store.changeList[oldValue] = null;
|
||||
this.store.changeList[newValue] = { ...station };
|
||||
} else {
|
||||
this.store.changeList[stationName][propName] = newValue;
|
||||
// this.store.changeList[sceneryId][propName] = newValue;
|
||||
// this.store.changeBackupList[sceneryId] = { ...rowStationData, name: oldValue };
|
||||
// } else {
|
||||
this.store.changeList[sceneryId][propName] = newValue;
|
||||
|
||||
if (!this.store.changeBackupList[stationName]) this.store.changeBackupList[stationName] = {};
|
||||
if (!this.store.changeBackupList[sceneryId]) this.store.changeBackupList[sceneryId] = {};
|
||||
|
||||
if (this.store.changeBackupList[stationName][propName] === undefined)
|
||||
this.store.changeBackupList[stationName][propName] = oldValue;
|
||||
}
|
||||
if (this.store.changeBackupList[sceneryId][propName] === undefined)
|
||||
this.store.changeBackupList[sceneryId][propName] = oldValue;
|
||||
// }
|
||||
|
||||
if (this.store.changeList[stationName][propName] == this.store.changeBackupList[stationName][propName]) {
|
||||
delete this.store.changeList[stationName][propName];
|
||||
delete this.store.changeBackupList[stationName][propName];
|
||||
if (this.store.changeList[sceneryId][propName] == this.store.changeBackupList[sceneryId][propName]) {
|
||||
delete this.store.changeList[sceneryId][propName];
|
||||
delete this.store.changeBackupList[sceneryId][propName];
|
||||
|
||||
if (Object.keys(this.store.changeList[stationName]).length == 0) delete this.store.changeList[stationName];
|
||||
if (Object.keys(this.store.changeList[sceneryId]).length == 0) delete this.store.changeList[sceneryId];
|
||||
|
||||
if (Object.keys(this.store.changeBackupList[stationName]).length == 0)
|
||||
delete this.store.changeBackupList[stationName];
|
||||
if (Object.keys(this.store.changeBackupList[sceneryId]).length == 0)
|
||||
delete this.store.changeBackupList[sceneryId];
|
||||
}
|
||||
|
||||
this.store.unsavedChanges = Object.keys(this.store.changeList).length != 0;
|
||||
},
|
||||
|
||||
addRemovalChange(sceneryData: SceneryRowItem) {
|
||||
const sceneryId = sceneryData.id;
|
||||
|
||||
this.store.changeBackupList[sceneryId] = { ...sceneryData };
|
||||
|
||||
this.store.changeList[sceneryId] = {
|
||||
name: sceneryData.name,
|
||||
toRemove: true,
|
||||
};
|
||||
|
||||
this.store.unsavedChanges = Object.keys(this.store.changeList).length != 0;
|
||||
|
||||
console.log(this.store.changeList);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user