mirror of
https://github.com/haexhub/haex-hub.git
synced 2025-12-17 06:30:50 +01:00
fixed group reactivity
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div>
|
||||
<HaexPassGroup
|
||||
v-model="currentGroup"
|
||||
v-model="group"
|
||||
mode="edit"
|
||||
@close="onClose"
|
||||
@submit="onSaveAsync"
|
||||
@ -10,6 +10,8 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { SelectHaexPasswordsGroups } from '~~/src-tauri/database/schemas/vault'
|
||||
|
||||
definePageMeta({
|
||||
name: 'passwordGroupEdit',
|
||||
})
|
||||
@ -20,7 +22,15 @@ const check = ref(false)
|
||||
|
||||
const { currentGroup } = storeToRefs(usePasswordGroupStore())
|
||||
|
||||
//const group = computed(() => currentGroup.value)
|
||||
const group = ref<SelectHaexPasswordsGroups>()
|
||||
|
||||
watch(
|
||||
currentGroup,
|
||||
(newGroup) => {
|
||||
group.value = JSON.parse(JSON.stringify(newGroup))
|
||||
},
|
||||
{ immediate: true },
|
||||
)
|
||||
|
||||
const errors = ref({
|
||||
name: [],
|
||||
@ -36,14 +46,14 @@ const { add } = useSnackbar()
|
||||
const onSaveAsync = async () => {
|
||||
try {
|
||||
check.value = true
|
||||
if (!currentGroup.value) return
|
||||
if (!group.value) return
|
||||
|
||||
console.log('onSave', errors.value)
|
||||
if (errors.value.name.length || errors.value.description.length) return
|
||||
|
||||
const { updateAsync } = usePasswordGroupStore()
|
||||
|
||||
await updateAsync(currentGroup.value)
|
||||
await updateAsync(group.value)
|
||||
|
||||
add({ type: 'success', text: t('change.success') })
|
||||
onClose()
|
||||
|
||||
@ -161,16 +161,20 @@ const item = reactive<{
|
||||
|
||||
const { currentItem } = storeToRefs(usePasswordItemStore())
|
||||
|
||||
watch(currentItem, () => {
|
||||
item.details = JSON.parse(JSON.stringify(currentItem.value?.details))
|
||||
item.keyValues = JSON.parse(JSON.stringify(currentItem.value?.keyValues))
|
||||
item.history = JSON.parse(JSON.stringify(currentItem.value?.history))
|
||||
item.keyValuesAdd = []
|
||||
item.keyValuesDelete = []
|
||||
item.originalDetails = JSON.stringify(currentItem.value?.details)
|
||||
item.originalKeyValues = JSON.stringify(currentItem.value?.keyValues)
|
||||
ignoreChanges.value = false
|
||||
})
|
||||
watch(
|
||||
currentItem,
|
||||
(newItem) => {
|
||||
item.details = JSON.parse(JSON.stringify(newItem?.details))
|
||||
item.keyValues = JSON.parse(JSON.stringify(newItem?.keyValues))
|
||||
item.history = JSON.parse(JSON.stringify(newItem?.history))
|
||||
item.keyValuesAdd = []
|
||||
item.keyValuesDelete = []
|
||||
item.originalDetails = JSON.stringify(newItem?.details)
|
||||
item.originalKeyValues = JSON.stringify(newItem?.keyValues)
|
||||
ignoreChanges.value = false
|
||||
},
|
||||
{ immediate: true },
|
||||
)
|
||||
|
||||
const { add } = useSnackbar()
|
||||
const { deleteAsync, updateAsync } = usePasswordItemStore()
|
||||
|
||||
Reference in New Issue
Block a user