From 8cee684a58e4aaa6448f878bf1b5f272b95f2aff Mon Sep 17 00:00:00 2001 From: Tako Date: Tue, 6 Jun 2023 14:39:32 +0000 Subject: [PATCH] use edit-value for config actions --- .../ftbot/PairlistConfigActions.vue | 77 ++++++------------- src/stores/pairlistConfig.ts | 31 ++++---- 2 files changed, 40 insertions(+), 68 deletions(-) diff --git a/src/components/ftbot/PairlistConfigActions.vue b/src/components/ftbot/PairlistConfigActions.vue index 3b908177..d641afe3 100644 --- a/src/components/ftbot/PairlistConfigActions.vue +++ b/src/components/ftbot/PairlistConfigActions.vue @@ -1,51 +1,33 @@ diff --git a/src/stores/pairlistConfig.ts b/src/stores/pairlistConfig.ts index d9935bc2..d7ff9624 100644 --- a/src/stores/pairlistConfig.ts +++ b/src/stores/pairlistConfig.ts @@ -73,9 +73,9 @@ export const usePairlistConfigStore = defineStore( config.value.pairlists.splice(index, 1); } - function saveConfig(name: string) { + function renameOrSaveConfig(oldName: string, newName: string) { const i = savedConfigs.value.findIndex((c) => c.name === config.value.name); - config.value.name = name; + config.value.name = newName; if (i > -1) { savedConfigs.value[i] = config.value; @@ -84,11 +84,19 @@ export const usePairlistConfigStore = defineStore( } } - function cloneConfig() { - config.value = { - name: '', + function newConfig(name: string) { + const c = { name: name, pairlists: [] }; + savedConfigs.value.push(c); + config.value = c; + } + + function duplicateConfig(oldName: string, newName: string) { + const c = { + name: newName, pairlists: structuredClone(toRaw(config.value.pairlists)), }; + savedConfigs.value.push(c); + config.value = c; } function deleteConfig() { @@ -99,14 +107,6 @@ export const usePairlistConfigStore = defineStore( } } - function newConfig() { - config.value = { name: '', pairlists: [] }; - } - - function selectConfig(selected: PairlistConfig) { - config.value = structuredClone(toRaw(selected)); - } - function addToBlacklist() { blacklist.value.push(''); } @@ -198,10 +198,9 @@ export const usePairlistConfigStore = defineStore( startPairlistEvaluation, addToConfig, removeFromConfig, - saveConfig, - cloneConfig, + renameOrSaveConfig, + duplicateConfig, deleteConfig, - selectConfig, newConfig, addToBlacklist, removeFromBlacklist,