+
-
+
>(new Set())
const { menu } = storeToRefs(usePasswordsActionMenuStore())
+const { syncItemsAsync } = usePasswordItemStore()
+const { syncGroupItemsAsync } = usePasswordGroupStore()
+onMounted(async () => {
+ try {
+ await Promise.allSettled([syncItemsAsync(), syncGroupItemsAsync()])
+ } catch (error) {}
+})
+
const {
breadCrumbs,
currentGroupId,
- currentGroupItems,
inTrashGroup,
selectedGroupItems,
+ groups,
} = storeToRefs(usePasswordGroupStore())
-const { insertGroupItemsAsync } = usePasswordGroupStore()
+
+const { items } = storeToRefs(usePasswordItemStore())
+const { search } = storeToRefs(useSearchStore())
const groupItems = computed(() => {
- const items: IPasswordMenuItem[] = []
+ const menuItems: IPasswordMenuItem[] = []
- items.push(
- ...currentGroupItems.value.groups.map((group) => ({
- color: group.color,
- icon: group.icon,
- id: group.id,
- name: group.name,
- type: 'group',
- })),
+ menuItems.push(
+ ...groups.value
+ .filter((group) => {
+ if (!search.value) return group.parentId == currentGroupId.value
+
+ return (
+ group.name?.includes(search.value) ||
+ group.description?.includes(search.value)
+ )
+ })
+ .map((group) => ({
+ color: group.color,
+ icon: group.icon,
+ id: group.id,
+ name: group.name,
+ type: 'group',
+ })),
)
- items.push(
- ...currentGroupItems.value.items.map((item) => ({
- icon: item.icon,
- id: item.id,
- name: item.title,
- type: 'item',
- })),
+ menuItems.push(
+ ...items.value
+ .filter((item) => {
+ if (!search.value)
+ return item.haex_passwords_group_items.groupId == currentGroupId.value
+
+ return (
+ item.haex_passwords_item_details.title?.includes(search.value) ||
+ item.haex_passwords_item_details.note?.includes(search.value) ||
+ item.haex_passwords_item_details.password?.includes(search.value) ||
+ item.haex_passwords_item_details.tags?.includes(search.value) ||
+ item.haex_passwords_item_details.url?.includes(search.value) ||
+ item.haex_passwords_item_details.username?.includes(search.value)
+ )
+ })
+ .map((item) => ({
+ icon: item.haex_passwords_item_details.icon,
+ id: item.haex_passwords_item_details.id,
+ name: item.haex_passwords_item_details.title,
+ type: 'item',
+ })),
)
- return items
+
+ return menuItems
})
const { isVisible } = storeToRefs(useSidebarStore())
@@ -150,8 +187,7 @@ onKeyStroke('x', (event) => {
}
})
-const { t } = useI18n()
-const { add } = useSnackbar()
+const { insertGroupItemsAsync } = usePasswordGroupStore()
const onPasteAsync = async () => {
if (!selectedGroupItems.value?.length) return
@@ -190,7 +226,8 @@ onKeyStroke('a', (event) => {
})
const { deleteAsync } = usePasswordItemStore()
-const { deleteGroupAsync, syncGroupItemsAsync } = usePasswordGroupStore()
+const { deleteGroupAsync } = usePasswordGroupStore()
+
const onDeleteAsync = async () => {
for (const item of selectedItems.value) {
if (item.type === 'group') {
diff --git a/src/pages/vault/[vaultId]/passwords/[[groupId]]/item/[itemId].vue b/src/pages/vault/[vaultId]/passwords/[[groupId]]/item/[itemId].vue
index 27ea6a3..c77d31f 100644
--- a/src/pages/vault/[vaultId]/passwords/[[groupId]]/item/[itemId].vue
+++ b/src/pages/vault/[vaultId]/passwords/[[groupId]]/item/[itemId].vue
@@ -3,7 +3,7 @@
-
@@ -85,27 +85,35 @@
-
+
-->
-
+
+
+
- {{ t('dialog.delete.question') }}
-
+
-
- {{ t('dialog.unsavedChanges.question') }}
-
+ v-model:open="showUnsavedChangesDialog"
+ />
@@ -126,7 +134,6 @@ defineProps({
withCopyButton: Boolean,
})
-const { isVisible } = storeToRefs(useSidebarStore())
const read_only = ref(true)
const showConfirmDeleteDialog = ref(false)
const { t } = useI18n()
@@ -165,7 +172,6 @@ const { currentItem } = storeToRefs(usePasswordItemStore())
watch(
currentItem,
() => {
- console.log('watch currentItem', currentItem.value)
if (!currentItem.value) return
item.details = JSON.parse(JSON.stringify(currentItem.value?.details))
item.keyValues = JSON.parse(JSON.stringify(currentItem.value?.keyValues))
@@ -174,15 +180,14 @@ watch(
item.keyValuesDelete = []
item.originalDetails = JSON.stringify(currentItem.value?.details)
item.originalKeyValues = JSON.stringify(currentItem.value?.keyValues)
- ignoreChanges.value = false
},
{ immediate: true },
)
const { add } = useSnackbar()
const { deleteAsync, updateAsync } = usePasswordItemStore()
-const { syncGroupItemsAsync, trashId } = usePasswordGroupStore()
-const { currentGroupId } = storeToRefs(usePasswordGroupStore())
+const { syncGroupItemsAsync } = usePasswordGroupStore()
+const { currentGroupId, inTrashGroup } = storeToRefs(usePasswordGroupStore())
const onUpdateAsync = async () => {
try {
@@ -195,31 +200,29 @@ const onUpdateAsync = async () => {
})
if (newId) add({ type: 'success', text: t('success.update') })
syncGroupItemsAsync(currentGroupId.value)
- ignoreChanges.value = true
- onClose()
+ onClose(true)
} catch (error) {
add({ type: 'error', text: t('error.update') })
}
}
-const onClose = () => {
+const onClose = (ignoreChanges?: boolean) => {
if (showConfirmDeleteDialog.value || showUnsavedChangesDialog.value) return
- if (hasChanges.value && !ignoreChanges.value)
+ if (hasChanges.value && !ignoreChanges)
return (showUnsavedChangesDialog.value = true)
- ignoreChanges.value = false
read_only.value = true
useRouter().back()
}
const deleteItemAsync = async () => {
try {
- await deleteAsync(item.details.id, currentGroupId.value === trashId)
+ await deleteAsync(item.details.id, inTrashGroup.value)
showConfirmDeleteDialog.value = false
add({ type: 'success', text: t('success.delete') })
- syncGroupItemsAsync(currentGroupId.value)
- onClose()
+ await syncGroupItemsAsync(currentGroupId.value)
+ onClose(true)
} catch (errro) {
add({
type: 'error',
@@ -239,22 +242,14 @@ const hasChanges = computed(
)
const showUnsavedChangesDialog = ref(false)
-const ignoreChanges = ref(false)
-
const onConfirmIgnoreChanges = () => {
- ignoreChanges.value = true
showUnsavedChangesDialog.value = false
- onClose()
+ onClose(true)
}
de:
- save: Speichern
- abort: Abbrechen
- edit: Bearbeiten
- noEdit: Lesemodus
- delete: Löschen
success:
update: Eintrag erfolgreich aktualisiert
delete: Eintrag wurde gelöscht
@@ -266,21 +261,7 @@ de:
keyValue: Extra
history: Verlauf
- dialog:
- delete:
- title: Eintrag löschen
- question: Soll der Eintrag wirklich gelöscht werden?
- label: Löschen
- unsavedChanges:
- title: Nicht gespeicherte Änderungen
- question: Sollen die Änderungen verworfen werden?
- label: Verwerfen
en:
- save: Save
- abort: Abort
- edit: Edit
- noEdit: Read Mode
- delete: Delete
success:
update: Entry successfully updated
delete: Entry successfully removed
@@ -291,14 +272,4 @@ en:
details: Details
keyValue: Extra
history: History
-
- dialog:
- delete:
- title: Delete Entry
- question: Should the entry really be deleted?
- label: Delete
- unsavedChanges:
- title: Unsaved changes
- question: Should the changes be discarded?
- label: discard
diff --git a/src/pages/vault/[vaultId]/passwords/[[groupId]]/item/create.vue b/src/pages/vault/[vaultId]/passwords/[[groupId]]/item/create.vue
index 11d9b8b..bbad468 100644
--- a/src/pages/vault/[vaultId]/passwords/[[groupId]]/item/create.vue
+++ b/src/pages/vault/[vaultId]/passwords/[[groupId]]/item/create.vue
@@ -9,7 +9,15 @@
v-model:key-values-add="item.keyValuesAdd"
/>
-
+
+
+
diff --git a/src/stores/passwords/items.ts b/src/stores/passwords/items.ts
index ba3e6e3..c9d6d78 100644
--- a/src/stores/passwords/items.ts
+++ b/src/stores/passwords/items.ts
@@ -6,6 +6,7 @@ import {
haexPasswordsItemKeyValues,
type InsertHaexPasswordsItemDetails,
type InserthaexPasswordsItemKeyValues,
+ type SelectHaexPasswordsGroupItems,
type SelectHaexPasswordsGroups,
type SelectHaexPasswordsItemDetails,
type SelectHaexPasswordsItemKeyValues,
@@ -23,6 +24,25 @@ export const usePasswordItemStore = defineStore('passwordItemStore', () => {
const currentItem = computedAsync(() => readAsync(currentItemId.value))
+ const items = ref<
+ {
+ haex_passwords_item_details: SelectHaexPasswordsItemDetails
+ haex_passwords_group_items: SelectHaexPasswordsGroupItems
+ }[]
+ >([])
+
+ const syncItemsAsync = async () => {
+ const { currentVault } = useVaultStore()
+
+ items.value = await currentVault.drizzle
+ .select()
+ .from(haexPasswordsItemDetails)
+ .innerJoin(
+ haexPasswordsGroupItems,
+ eq(haexPasswordsItemDetails.id, haexPasswordsGroupItems.itemId),
+ )
+ }
+
return {
currentItemId,
currentItem,
@@ -31,9 +51,11 @@ export const usePasswordItemStore = defineStore('passwordItemStore', () => {
addKeyValuesAsync,
deleteAsync,
deleteKeyValueAsync,
+ items,
readByGroupIdAsync,
readAsync,
readKeyValuesAsync,
+ syncItemsAsync,
updateAsync,
}
})
diff --git a/src/stores/vault/search.ts b/src/stores/vault/search.ts
new file mode 100644
index 0000000..de8beac
--- /dev/null
+++ b/src/stores/vault/search.ts
@@ -0,0 +1,7 @@
+export const useSearchStore = defineStore('searchStore', () => {
+ const search = ref()
+
+ return {
+ search,
+ }
+})