From c00e196be0a773ac35afb009dff6e09597f4bc81 Mon Sep 17 00:00:00 2001 From: Egor Aristov Date: Fri, 21 Feb 2025 19:38:22 +0300 Subject: [PATCH] reset form --- frontend/wizard-vue/src/pages/WizardPage.vue | 1 + frontend/wizard-vue/src/stores/wizard.ts | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/frontend/wizard-vue/src/pages/WizardPage.vue b/frontend/wizard-vue/src/pages/WizardPage.vue index 0f1d89d..54b5572 100644 --- a/frontend/wizard-vue/src/pages/WizardPage.vue +++ b/frontend/wizard-vue/src/pages/WizardPage.vue @@ -46,6 +46,7 @@ function screenshot() { Generate link Screenshot Edit existing task + Reset Form diff --git a/frontend/wizard-vue/src/stores/wizard.ts b/frontend/wizard-vue/src/stores/wizard.ts index 21a90b2..fffc4e0 100644 --- a/frontend/wizard-vue/src/stores/wizard.ts +++ b/frontend/wizard-vue/src/stores/wizard.ts @@ -8,9 +8,9 @@ const LOCAL_STORAGE_KEY = 'rssalchemy_store_wizard'; export const useWizardStore = defineStore('wizard', () => { const locStorageContent = localStorage.getItem(LOCAL_STORAGE_KEY); - const defaultSpecs = locStorageContent ? JSON.parse(locStorageContent) as Specs : emptySpecs; + const initialSpecs = locStorageContent ? JSON.parse(locStorageContent) as Specs : emptySpecs; - const specs = reactive(defaultSpecs); + const specs = reactive(Object.assign({}, initialSpecs)); const formValid = computed(() => { return fields.every(field => ( @@ -30,6 +30,10 @@ export const useWizardStore = defineStore('wizard', () => { Object.assign(specs, newValue); updateLocalStorage(); } + function reset() { + Object.assign(specs, emptySpecs); + updateLocalStorage(); + } - return {specs, formValid, updateSpec, updateSpecs}; + return {specs, formValid, updateSpec, updateSpecs, reset}; });