mirror of
https://github.com/haexhub/haex-hub.git
synced 2025-12-16 22:20:51 +01:00
fix submit handler
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="breadcrumbs">
|
<div class="breadcrumbs sticky top-0">
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<NuxtLinkLocale :to="{ name: 'passwordGroupItems' }">
|
<NuxtLinkLocale :to="{ name: 'passwordGroupItems' }">
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
:title="mode === 'create' ? t('title.create') : t('title.edit')"
|
:title="mode === 'create' ? t('title.create') : t('title.edit')"
|
||||||
icon="mdi:folder-plus-outline"
|
icon="mdi:folder-plus-outline"
|
||||||
@close="$emit('close')"
|
@close="$emit('close')"
|
||||||
|
body-class="px-0"
|
||||||
>
|
>
|
||||||
<form
|
<form
|
||||||
class="flex flex-col gap-4 w-full p-4"
|
class="flex flex-col gap-4 w-full p-4"
|
||||||
@ -17,6 +18,7 @@
|
|||||||
autofocus
|
autofocus
|
||||||
v-model="group.name"
|
v-model="group.name"
|
||||||
ref="nameRef"
|
ref="nameRef"
|
||||||
|
@keyup.enter="$emit('submit')"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<UiInput
|
<UiInput
|
||||||
@ -24,9 +26,10 @@
|
|||||||
:check-input="check"
|
:check-input="check"
|
||||||
:label="t('description')"
|
:label="t('description')"
|
||||||
:placeholder="t('description')"
|
:placeholder="t('description')"
|
||||||
|
@keyup.enter="$emit('submit')"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div class="flex gap-4">
|
<div class="flex flex-wrap gap-4">
|
||||||
<UiSelectIcon
|
<UiSelectIcon
|
||||||
v-model="group.icon"
|
v-model="group.icon"
|
||||||
default-icon="mdi:folder-outline"
|
default-icon="mdi:folder-outline"
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="h-full overflow-scroll">
|
<div class="h-full overflow-scroll">
|
||||||
<div class="flex flex-col gap-4 w-full p-4">
|
<form
|
||||||
|
class="flex flex-col gap-4 w-full p-4"
|
||||||
|
@submit.prevent="$emit('submit')"
|
||||||
|
>
|
||||||
<UiInput
|
<UiInput
|
||||||
v-show="!read_only || itemDetails.title"
|
v-show="!read_only || itemDetails.title"
|
||||||
:check-input="check"
|
:check-input="check"
|
||||||
@ -11,6 +14,7 @@
|
|||||||
autofocus
|
autofocus
|
||||||
ref="titleRef"
|
ref="titleRef"
|
||||||
v-model.trim="itemDetails.title"
|
v-model.trim="itemDetails.title"
|
||||||
|
@keyup.enter="$emit('submit')"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<UiInput
|
<UiInput
|
||||||
@ -66,7 +70,7 @@
|
|||||||
@keyup.enter.stop
|
@keyup.enter.stop
|
||||||
class="h-52"
|
class="h-52"
|
||||||
/>
|
/>
|
||||||
</div>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -79,6 +83,7 @@ defineProps<{
|
|||||||
withCopyButton?: boolean
|
withCopyButton?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
defineEmits(['submit'])
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
|
||||||
const itemDetails = defineModel<SelectHaexPasswordsItemDetails>({
|
const itemDetails = defineModel<SelectHaexPasswordsItemDetails>({
|
||||||
@ -89,10 +94,10 @@ const preventClose = defineModel<boolean>('preventClose')
|
|||||||
|
|
||||||
const check = defineModel<boolean>('check-input', { default: false })
|
const check = defineModel<boolean>('check-input', { default: false })
|
||||||
|
|
||||||
onKeyStroke('escape', (e) => {
|
/* onKeyStroke('escape', (e) => {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
e.stopImmediatePropagation()
|
e.stopImmediatePropagation()
|
||||||
})
|
}) */
|
||||||
|
|
||||||
const titleRef = useTemplateRef('titleRef')
|
const titleRef = useTemplateRef('titleRef')
|
||||||
onStartTyping(() => {
|
onStartTyping(() => {
|
||||||
|
|||||||
@ -78,6 +78,7 @@
|
|||||||
:read_only
|
:read_only
|
||||||
:defaultIcon
|
:defaultIcon
|
||||||
v-model:prevent-close="preventClose"
|
v-model:prevent-close="preventClose"
|
||||||
|
@submit="$emit('submit')"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -127,6 +128,7 @@ const emit = defineEmits<{
|
|||||||
close: [void]
|
close: [void]
|
||||||
addKeyValue: [void]
|
addKeyValue: [void]
|
||||||
removeKeyValue: [string]
|
removeKeyValue: [string]
|
||||||
|
submit: [void]
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const read_only = defineModel<boolean>('read_only', { default: false })
|
const read_only = defineModel<boolean>('read_only', { default: false })
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="card">
|
<div class="card min-w-56">
|
||||||
<slot name="image" />
|
<slot name="image" />
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
|||||||
@ -22,9 +22,10 @@
|
|||||||
:placeholder="placeholder || label"
|
:placeholder="placeholder || label"
|
||||||
:readonly="read_only"
|
:readonly="read_only"
|
||||||
:type
|
:type
|
||||||
class="ps-3"
|
class="ps-2"
|
||||||
ref="inputRef"
|
ref="inputRef"
|
||||||
v-model="input"
|
v-model="input"
|
||||||
|
@keyup="(e) => $emit('keyup', e)"
|
||||||
/>
|
/>
|
||||||
<label
|
<label
|
||||||
:for="id"
|
:for="id"
|
||||||
@ -80,6 +81,11 @@ const input = defineModel<string | number | undefined | null>({
|
|||||||
const inputRef = useTemplateRef('inputRef')
|
const inputRef = useTemplateRef('inputRef')
|
||||||
defineExpose({ inputRef })
|
defineExpose({ inputRef })
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
error: [string[]]
|
||||||
|
keyup: [KeyboardEvent]
|
||||||
|
}>()
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
placeholder: {
|
placeholder: {
|
||||||
type: String,
|
type: String,
|
||||||
@ -148,8 +154,6 @@ watch(
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
const emit = defineEmits(['error'])
|
|
||||||
|
|
||||||
const checkInput = () => {
|
const checkInput = () => {
|
||||||
if (props.rules) {
|
if (props.rules) {
|
||||||
const result = props.rules.safeParse(input.value)
|
const result = props.rules.safeParse(input.value)
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex items-center gap-4 relative">
|
<div class="flex flex-wrap items-center gap-4 relative">
|
||||||
<UiButton
|
<UiButton
|
||||||
:style="{ 'background-color': model }"
|
:style="{ 'background-color': model }"
|
||||||
:class="[textColorClass]"
|
:class="[textColorClass]"
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="p-2 h-full">
|
<div class="p-2 min-h-full">
|
||||||
<NuxtPage />
|
<NuxtPage />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
|
currentGroup{{ currentGroup }}
|
||||||
<HaexPassGroup
|
<HaexPassGroup
|
||||||
v-model="group"
|
v-model="group"
|
||||||
mode="edit"
|
mode="edit"
|
||||||
@ -26,8 +27,8 @@ const group = ref<SelectHaexPasswordsGroups>()
|
|||||||
|
|
||||||
watch(
|
watch(
|
||||||
currentGroup,
|
currentGroup,
|
||||||
(newGroup) => {
|
() => {
|
||||||
group.value = JSON.parse(JSON.stringify(newGroup))
|
group.value = JSON.parse(JSON.stringify(currentGroup.value))
|
||||||
},
|
},
|
||||||
{ immediate: true },
|
{ immediate: true },
|
||||||
)
|
)
|
||||||
@ -43,7 +44,7 @@ const onClose = () => {
|
|||||||
|
|
||||||
const { add } = useSnackbar()
|
const { add } = useSnackbar()
|
||||||
|
|
||||||
const { updateAsync } = usePasswordGroupStore()
|
const { updateAsync, syncGroupItemsAsync } = usePasswordGroupStore()
|
||||||
|
|
||||||
const onSaveAsync = async () => {
|
const onSaveAsync = async () => {
|
||||||
try {
|
try {
|
||||||
@ -53,7 +54,7 @@ const onSaveAsync = async () => {
|
|||||||
if (errors.value.name.length || errors.value.description.length) return
|
if (errors.value.name.length || errors.value.description.length) return
|
||||||
|
|
||||||
await updateAsync(group.value)
|
await updateAsync(group.value)
|
||||||
|
syncGroupItemsAsync()
|
||||||
add({ type: 'success', text: t('change.success') })
|
add({ type: 'success', text: t('change.success') })
|
||||||
onClose()
|
onClose()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@ -1,13 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="relative h-full">
|
<div class="h-full relative">
|
||||||
<div class="h-full">
|
<div class="h-full">
|
||||||
|
<HaexPassGroupBreadcrumbs
|
||||||
|
:items="breadCrumbs"
|
||||||
|
class="px-2 z-10 bg-base-200"
|
||||||
|
v-show="breadCrumbs.length"
|
||||||
|
/>
|
||||||
<div class="h-full overflow-auto flex flex-col">
|
<div class="h-full overflow-auto flex flex-col">
|
||||||
<HaexPassGroupBreadcrumbs
|
|
||||||
:items="breadCrumbs"
|
|
||||||
class="px-2"
|
|
||||||
v-show="breadCrumbs.length"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<HaexPassMobileMenu
|
<HaexPassMobileMenu
|
||||||
:menu-items="groupItems"
|
:menu-items="groupItems"
|
||||||
ref="listRef"
|
ref="listRef"
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
:history="item.history"
|
:history="item.history"
|
||||||
:read_only
|
:read_only
|
||||||
@close="onClose"
|
@close="onClose"
|
||||||
|
@submit="onUpdateAsync"
|
||||||
v-model:details="item.details"
|
v-model:details="item.details"
|
||||||
v-model:key-values-add="item.keyValuesAdd"
|
v-model:key-values-add="item.keyValuesAdd"
|
||||||
v-model:key-values-delete="item.keyValuesDelete"
|
v-model:key-values-delete="item.keyValuesDelete"
|
||||||
@ -14,7 +15,7 @@
|
|||||||
class="fixed bottom-4 flex justify-between transition-all pointer-events-none right-0 sm:items-center items-end"
|
class="fixed bottom-4 flex justify-between transition-all pointer-events-none right-0 sm:items-center items-end"
|
||||||
:class="[isVisible ? 'left-15 ' : 'left-0']"
|
:class="[isVisible ? 'left-15 ' : 'left-0']"
|
||||||
>
|
>
|
||||||
<div class="flex items-center justify-center w-full">
|
<div class="flex items-center justify-center flex-1">
|
||||||
<UiTooltip :tooltip="t('abort')">
|
<UiTooltip :tooltip="t('abort')">
|
||||||
<UiButton
|
<UiButton
|
||||||
class="btn-accent btn-square"
|
class="btn-accent btn-square"
|
||||||
@ -71,7 +72,7 @@
|
|||||||
</UiButton>
|
</UiButton>
|
||||||
</UiTooltip>
|
</UiTooltip>
|
||||||
|
|
||||||
<div class="flex items-center justify-center w-full">
|
<div class="flex items-center justify-center flex-1">
|
||||||
<UiTooltip :tooltip="t('delete')">
|
<UiTooltip :tooltip="t('delete')">
|
||||||
<UiButton
|
<UiButton
|
||||||
class="btn-square btn-error"
|
class="btn-square btn-error"
|
||||||
|
|||||||
@ -4,15 +4,16 @@
|
|||||||
:default-icon="currentGroup?.icon"
|
:default-icon="currentGroup?.icon"
|
||||||
:history="item.history"
|
:history="item.history"
|
||||||
@close="onClose"
|
@close="onClose"
|
||||||
|
@submit="onCreateAsync"
|
||||||
v-model:details="item.details"
|
v-model:details="item.details"
|
||||||
v-model:key-values-add="item.keyValuesAdd"
|
v-model:key-values-add="item.keyValuesAdd"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="fixed bottom-4 flex justify-between transition-all pointer-events-none right-15 sm:items-center items-end"
|
class="fixed bottom-4 flex justify-between transition-all pointer-events-none right-0 sm:items-center items-end"
|
||||||
:class="[isVisible ? 'left-15 ' : 'left-0']"
|
:class="[isVisible ? 'left-15 ' : 'left-0']"
|
||||||
>
|
>
|
||||||
<div class="flex items-center justify-center w-full">
|
<div class="flex items-center justify-center flex-1">
|
||||||
<UiTooltip :tooltip="t('abort')">
|
<UiTooltip :tooltip="t('abort')">
|
||||||
<UiButton
|
<UiButton
|
||||||
class="btn-error btn-square"
|
class="btn-error btn-square"
|
||||||
@ -33,7 +34,7 @@
|
|||||||
/>
|
/>
|
||||||
</UiButton>
|
</UiButton>
|
||||||
</UiTooltip>
|
</UiTooltip>
|
||||||
<div class="flex items-center justify-center w-full"></div>
|
<div class="flex items-center justify-center flex-1"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@ -128,7 +128,7 @@ const addGroupAsync = async (group: Partial<InsertHaexPasswordsGroups>) => {
|
|||||||
name: group.name,
|
name: group.name,
|
||||||
order: group.order,
|
order: group.order,
|
||||||
}
|
}
|
||||||
await currentVault.drizzle.insert(haexPasswordsGroups).values(newGroup)
|
await currentVault.drizzle?.insert(haexPasswordsGroups).values(newGroup)
|
||||||
await syncGroupItemsAsync()
|
await syncGroupItemsAsync()
|
||||||
return newGroup
|
return newGroup
|
||||||
}
|
}
|
||||||
@ -138,7 +138,7 @@ const readGroupAsync = async (groupId: string) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
await currentVault.drizzle
|
await currentVault.drizzle
|
||||||
.select()
|
?.select()
|
||||||
.from(haexPasswordsGroups)
|
.from(haexPasswordsGroups)
|
||||||
.where(eq(haexPasswordsGroups.id, groupId))
|
.where(eq(haexPasswordsGroups.id, groupId))
|
||||||
).at(0)
|
).at(0)
|
||||||
@ -166,12 +166,12 @@ const readGroupItemsAsync = async (
|
|||||||
|
|
||||||
if (groupId) {
|
if (groupId) {
|
||||||
return currentVault.drizzle
|
return currentVault.drizzle
|
||||||
.select()
|
?.select()
|
||||||
.from(haexPasswordsGroupItems)
|
.from(haexPasswordsGroupItems)
|
||||||
.where(eq(haexPasswordsGroupItems.groupId, groupId))
|
.where(eq(haexPasswordsGroupItems.groupId, groupId))
|
||||||
} else {
|
} else {
|
||||||
return currentVault.drizzle
|
return currentVault.drizzle
|
||||||
.select()
|
?.select()
|
||||||
.from(haexPasswordsGroupItems)
|
.from(haexPasswordsGroupItems)
|
||||||
.where(isNull(haexPasswordsGroupItems.groupId))
|
.where(isNull(haexPasswordsGroupItems.groupId))
|
||||||
}
|
}
|
||||||
@ -198,7 +198,7 @@ const getByParentIdAsync = async (
|
|||||||
console.log('getByParentIdAsync', parentId)
|
console.log('getByParentIdAsync', parentId)
|
||||||
if (parentId) {
|
if (parentId) {
|
||||||
const groups = await currentVault.drizzle
|
const groups = await currentVault.drizzle
|
||||||
.select()
|
?.select()
|
||||||
.from(haexPasswordsGroups)
|
.from(haexPasswordsGroups)
|
||||||
.where(eq(haexPasswordsGroups.parentId, parentId))
|
.where(eq(haexPasswordsGroups.parentId, parentId))
|
||||||
.orderBy(sql`${haexPasswordsGroups.order} nulls last`)
|
.orderBy(sql`${haexPasswordsGroups.order} nulls last`)
|
||||||
@ -206,7 +206,7 @@ const getByParentIdAsync = async (
|
|||||||
return groups
|
return groups
|
||||||
} else {
|
} else {
|
||||||
const groups = await currentVault.drizzle
|
const groups = await currentVault.drizzle
|
||||||
.select()
|
?.select()
|
||||||
.from(haexPasswordsGroups)
|
.from(haexPasswordsGroups)
|
||||||
.where(isNull(haexPasswordsGroups.parentId))
|
.where(isNull(haexPasswordsGroups.parentId))
|
||||||
.orderBy(sql`${haexPasswordsGroups.order} nulls last`)
|
.orderBy(sql`${haexPasswordsGroups.order} nulls last`)
|
||||||
@ -238,10 +238,20 @@ const updateAsync = async (group: InsertHaexPasswordsGroups) => {
|
|||||||
const { currentVault } = storeToRefs(useVaultStore())
|
const { currentVault } = storeToRefs(useVaultStore())
|
||||||
if (!group.id) return
|
if (!group.id) return
|
||||||
|
|
||||||
|
const newGroup: InsertHaexPasswordsGroups = {
|
||||||
|
id: group.id,
|
||||||
|
color: group.color,
|
||||||
|
description: group.description,
|
||||||
|
icon: group.icon,
|
||||||
|
name: group.name,
|
||||||
|
order: group.order,
|
||||||
|
parentId: group.parentId,
|
||||||
|
}
|
||||||
|
|
||||||
return currentVault.value.drizzle
|
return currentVault.value.drizzle
|
||||||
.update(haexPasswordsGroups)
|
.update(haexPasswordsGroups)
|
||||||
.set(group)
|
.set(newGroup)
|
||||||
.where(eq(haexPasswordsGroups.id, group.id))
|
.where(eq(haexPasswordsGroups.id, newGroup.id))
|
||||||
}
|
}
|
||||||
|
|
||||||
const navigateToGroupItemsAsync = (groupId: string) => {
|
const navigateToGroupItemsAsync = (groupId: string) => {
|
||||||
|
|||||||
@ -15,7 +15,7 @@ const getAsync = async (itemId: string | null) => {
|
|||||||
const { currentVault } = useVaultStore()
|
const { currentVault } = useVaultStore()
|
||||||
|
|
||||||
const history = await currentVault.drizzle
|
const history = await currentVault.drizzle
|
||||||
.select()
|
?.select()
|
||||||
.from(haexPasswordsItemHistory)
|
.from(haexPasswordsItemHistory)
|
||||||
.where(eq(haexPasswordsItemHistory.itemId, itemId))
|
.where(eq(haexPasswordsItemHistory.itemId, itemId))
|
||||||
|
|
||||||
|
|||||||
@ -121,12 +121,14 @@ export const useVaultSettingsStore = defineStore('vaultSettingsStore', () => {
|
|||||||
const readDeviceNameAsync = async (id: string) => {
|
const readDeviceNameAsync = async (id: string) => {
|
||||||
const { currentVault } = useVaultStore()
|
const { currentVault } = useVaultStore()
|
||||||
|
|
||||||
const deviceName = await currentVault.drizzle.query.haexSettings.findFirst({
|
const deviceName = await currentVault.drizzle?.query.haexSettings.findFirst(
|
||||||
where: and(
|
{
|
||||||
eq(schema.haexSettings.type, VaultSettingsTypeEnum.deviceName),
|
where: and(
|
||||||
eq(schema.haexSettings.key, id),
|
eq(schema.haexSettings.type, VaultSettingsTypeEnum.deviceName),
|
||||||
),
|
eq(schema.haexSettings.key, id),
|
||||||
})
|
),
|
||||||
|
},
|
||||||
|
)
|
||||||
console.log('readDeviceNameAsync', deviceName)
|
console.log('readDeviceNameAsync', deviceName)
|
||||||
return deviceName
|
return deviceName
|
||||||
}
|
}
|
||||||
@ -146,7 +148,7 @@ export const useVaultSettingsStore = defineStore('vaultSettingsStore', () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
return currentVault.drizzle.insert(schema.haexSettings).values({
|
return currentVault.drizzle?.insert(schema.haexSettings).values({
|
||||||
id: crypto.randomUUID(),
|
id: crypto.randomUUID(),
|
||||||
type: VaultSettingsTypeEnum.deviceName,
|
type: VaultSettingsTypeEnum.deviceName,
|
||||||
key: deviceId,
|
key: deviceId,
|
||||||
@ -167,7 +169,7 @@ export const useVaultSettingsStore = defineStore('vaultSettingsStore', () => {
|
|||||||
if (!isNameOk.success) return
|
if (!isNameOk.success) return
|
||||||
|
|
||||||
return currentVault.drizzle
|
return currentVault.drizzle
|
||||||
.update(schema.haexSettings)
|
?.update(schema.haexSettings)
|
||||||
.set({
|
.set({
|
||||||
value: deviceName,
|
value: deviceName,
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user