reset form

This commit is contained in:
Egor Aristov 2025-02-21 19:38:22 +03:00
parent 3648b08e4b
commit c00e196be0
Signed by: egor3f
GPG Key ID: 40482A264AAEC85F
2 changed files with 8 additions and 3 deletions

View File

@ -46,6 +46,7 @@ function screenshot() {
<Btn :active="store.formValid" @click="generateLink">Generate link</Btn>
<Btn :active="store.formValid" @click="screenshot">Screenshot</Btn>
<Btn @click="editModalVisible = true">Edit existing task</Btn>
<Btn @click="store.reset">Reset Form</Btn>
<Copyable v-if="link" :contents="link" class="link-view"></Copyable>
<EditUrlModal :visible="editModalVisible" @close="editModalVisible = false"
v-model="existingLink"></EditUrlModal>

View File

@ -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};
});