From 61a8f56d131af9a4bab117443574082c96890350 Mon Sep 17 00:00:00 2001 From: Lightling Date: Sun, 2 Mar 2025 18:14:27 -0500 Subject: [PATCH] file saving & exiting --- src-tauri/capabilities/default.json | 3 +- src/App.vue | 5 ++ src/main.ts | 3 +- src/store.ts | 8 +-- src/views/Editor/DataEditor.vue | 25 ++++++--- src/views/Editor/Editor.vue | 83 +++++++++++++++++++++++++++-- src/views/Editor/FieldEditor.vue | 46 ++++++++++++++-- src/views/Home/Home.vue | 2 +- 8 files changed, 151 insertions(+), 24 deletions(-) diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index 4f7c3b1..3a2c28d 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -9,6 +9,7 @@ "core:default", "opener:default", "dialog:default", + "fs:allow-write-text-file", "fs:default" ] -} \ No newline at end of file +} diff --git a/src/App.vue b/src/App.vue index 656184c..4018b86 100644 --- a/src/App.vue +++ b/src/App.vue @@ -36,4 +36,9 @@ main diff --git a/src/main.ts b/src/main.ts index 8bc77e7..e28cd7b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -4,6 +4,7 @@ import { definePreset } from '@primeuix/themes' import Aura from '@primeuix/themes/aura' import PrimeVue from 'primevue/config' import ToastService from 'primevue/toastservice' +import Tooltip from 'primevue/tooltip' import 'primeicons/primeicons.css' import { router } from './router' @@ -12,7 +13,6 @@ import App from './App.vue' const pinia = createPinia() const app = createApp(App) - const themePreset = definePreset(Aura, { semantic: { primary: { @@ -44,4 +44,5 @@ app }, }) .use(ToastService) + .directive('tooltip', Tooltip) .mount('#app') diff --git a/src/store.ts b/src/store.ts index f7f90f1..90754ad 100644 --- a/src/store.ts +++ b/src/store.ts @@ -17,12 +17,14 @@ export const useAppStore = defineStore('appStore', { } as InventoryState, }), getters: { - fileTree: (state) => fileTree(state.currentInventory), - fileDirectory: (state) => { + fileTree(state) { + return fileTree(state.currentInventory) + }, + fileDirectory(state) { const split = fileTree(state.currentInventory) return state.currentInventory.filePath.replace(split[split.length - 1], '') }, - fileName: (state) => { + fileName(state) { const split = fileTree(state.currentInventory) return split[split.length - 1] }, diff --git a/src/views/Editor/DataEditor.vue b/src/views/Editor/DataEditor.vue index 1d46202..c80eb51 100644 --- a/src/views/Editor/DataEditor.vue +++ b/src/views/Editor/DataEditor.vue @@ -15,35 +15,40 @@ import { const props = defineProps<{ columns: DataColumn[], }>() -const model = defineModel() +const emits = defineEmits<{ + (e: 'dirty'): void +}>() +const model = defineModel({ required: true }) const editingRows = ref([]) const onRowEditSave = (event: { newData: any, index: number }) => { let { newData, index } = event - model.value![index] = newData + model.value[index] = newData + emits('dirty') } const onAddRow = (event: Event) => { event.preventDefault() - model.value!.push({ _id: uuidv7() }) - console.log(model.value) + model.value.push({ _id: uuidv7() }) + emits('dirty') requestAnimationFrame(() => { - (document.querySelector('tr:last-of-type button.edit') as HTMLButtonElement).click() + (document.querySelector('.data-editor tr:last-of-type button.edit') as HTMLButtonElement).click() requestAnimationFrame(() => { - (document.querySelector('tr:last-of-type input') as HTMLInputElement | undefined)?.focus() + (document.querySelector('.data-editor tr:last-of-type input') as HTMLInputElement | undefined)?.select() }) }) } const onDeleteRow = (event: Event, slotProps: { index: number }) => { event.preventDefault() - model.value!.splice(slotProps.index, 1) + model.value.splice(slotProps.index, 1) + emits('dirty') }