diff --git a/src-tauri/database/migrations/0000_bumpy_valkyrie.sql b/src-tauri/database/migrations/0000_secret_ender_wiggin.sql similarity index 78% rename from src-tauri/database/migrations/0000_bumpy_valkyrie.sql rename to src-tauri/database/migrations/0000_secret_ender_wiggin.sql index 05d2675..1762a40 100644 --- a/src-tauri/database/migrations/0000_bumpy_valkyrie.sql +++ b/src-tauri/database/migrations/0000_secret_ender_wiggin.sql @@ -28,11 +28,14 @@ CREATE TABLE `haex_desktop_items` ( `id` text PRIMARY KEY NOT NULL, `workspace_id` text NOT NULL, `item_type` text NOT NULL, - `reference_id` text NOT NULL, + `extension_id` text, + `system_window_id` text, `position_x` integer DEFAULT 0 NOT NULL, `position_y` integer DEFAULT 0 NOT NULL, `haex_timestamp` text, - FOREIGN KEY (`workspace_id`) REFERENCES `haex_workspaces`(`id`) ON UPDATE no action ON DELETE cascade + FOREIGN KEY (`workspace_id`) REFERENCES `haex_workspaces`(`id`) ON UPDATE no action ON DELETE cascade, + FOREIGN KEY (`extension_id`) REFERENCES `haex_extensions`(`id`) ON UPDATE no action ON DELETE cascade, + CONSTRAINT "item_reference" CHECK(("haex_desktop_items"."item_type" = 'extension' AND "haex_desktop_items"."extension_id" IS NOT NULL AND "haex_desktop_items"."system_window_id" IS NULL) OR ("haex_desktop_items"."item_type" = 'system' AND "haex_desktop_items"."system_window_id" IS NOT NULL AND "haex_desktop_items"."extension_id" IS NULL) OR ("haex_desktop_items"."item_type" = 'file' AND "haex_desktop_items"."system_window_id" IS NOT NULL AND "haex_desktop_items"."extension_id" IS NULL) OR ("haex_desktop_items"."item_type" = 'folder' AND "haex_desktop_items"."system_window_id" IS NOT NULL AND "haex_desktop_items"."extension_id" IS NULL)) ); --> statement-breakpoint CREATE TABLE `haex_extension_permissions` ( diff --git a/src-tauri/database/migrations/meta/0000_snapshot.json b/src-tauri/database/migrations/meta/0000_snapshot.json index 92cc2f2..8c74bd2 100644 --- a/src-tauri/database/migrations/meta/0000_snapshot.json +++ b/src-tauri/database/migrations/meta/0000_snapshot.json @@ -1,7 +1,7 @@ { "version": "6", "dialect": "sqlite", - "id": "21ca1268-1057-48c1-8647-29bd7cb67d49", + "id": "bcdd9ad3-a87a-4a43-9eba-673f94b10287", "prevId": "00000000-0000-0000-0000-000000000000", "tables": { "haex_crdt_configs": { @@ -179,11 +179,18 @@ "notNull": true, "autoincrement": false }, - "reference_id": { - "name": "reference_id", + "extension_id": { + "name": "extension_id", "type": "text", "primaryKey": false, - "notNull": true, + "notNull": false, + "autoincrement": false + }, + "system_window_id": { + "name": "system_window_id", + "type": "text", + "primaryKey": false, + "notNull": false, "autoincrement": false }, "position_x": { @@ -224,11 +231,29 @@ ], "onDelete": "cascade", "onUpdate": "no action" + }, + "haex_desktop_items_extension_id_haex_extensions_id_fk": { + "name": "haex_desktop_items_extension_id_haex_extensions_id_fk", + "tableFrom": "haex_desktop_items", + "tableTo": "haex_extensions", + "columnsFrom": [ + "extension_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, - "checkConstraints": {} + "checkConstraints": { + "item_reference": { + "name": "item_reference", + "value": "(\"haex_desktop_items\".\"item_type\" = 'extension' AND \"haex_desktop_items\".\"extension_id\" IS NOT NULL AND \"haex_desktop_items\".\"system_window_id\" IS NULL) OR (\"haex_desktop_items\".\"item_type\" = 'system' AND \"haex_desktop_items\".\"system_window_id\" IS NOT NULL AND \"haex_desktop_items\".\"extension_id\" IS NULL) OR (\"haex_desktop_items\".\"item_type\" = 'file' AND \"haex_desktop_items\".\"system_window_id\" IS NOT NULL AND \"haex_desktop_items\".\"extension_id\" IS NULL) OR (\"haex_desktop_items\".\"item_type\" = 'folder' AND \"haex_desktop_items\".\"system_window_id\" IS NOT NULL AND \"haex_desktop_items\".\"extension_id\" IS NULL)" + } + } }, "haex_extension_permissions": { "name": "haex_extension_permissions", diff --git a/src-tauri/database/migrations/meta/_journal.json b/src-tauri/database/migrations/meta/_journal.json index 82997d5..0942352 100644 --- a/src-tauri/database/migrations/meta/_journal.json +++ b/src-tauri/database/migrations/meta/_journal.json @@ -5,8 +5,8 @@ { "idx": 0, "version": "6", - "when": 1761216357702, - "tag": "0000_bumpy_valkyrie", + "when": 1761430560028, + "tag": "0000_secret_ender_wiggin", "breakpoints": true } ] diff --git a/src-tauri/database/schemas/haex.ts b/src-tauri/database/schemas/haex.ts index 8f86a22..e9cd665 100644 --- a/src-tauri/database/schemas/haex.ts +++ b/src-tauri/database/schemas/haex.ts @@ -1,5 +1,6 @@ import { sql } from 'drizzle-orm' import { + check, integer, sqliteTable, text, @@ -158,9 +159,13 @@ export const haexDesktopItems = sqliteTable( itemType: text(tableNames.haex.desktop_items.columns.itemType, { enum: ['system', 'extension', 'file', 'folder'], }).notNull(), - referenceId: text( - tableNames.haex.desktop_items.columns.referenceId, - ).notNull(), // systemId für system windows, extensionId für extensions, filePath für files/folders + // Für Extensions (wenn itemType = 'extension') + extensionId: text(tableNames.haex.desktop_items.columns.extensionId) + .references((): AnySQLiteColumn => haexExtensions.id, { + onDelete: 'cascade', + }), + // Für System Windows (wenn itemType = 'system') + systemWindowId: text(tableNames.haex.desktop_items.columns.systemWindowId), positionX: integer(tableNames.haex.desktop_items.columns.positionX) .notNull() .default(0), @@ -170,6 +175,12 @@ export const haexDesktopItems = sqliteTable( }, tableNames.haex.desktop_items.columns, ), + (table) => [ + check( + 'item_reference', + sql`(${table.itemType} = 'extension' AND ${table.extensionId} IS NOT NULL AND ${table.systemWindowId} IS NULL) OR (${table.itemType} = 'system' AND ${table.systemWindowId} IS NOT NULL AND ${table.extensionId} IS NULL) OR (${table.itemType} = 'file' AND ${table.systemWindowId} IS NOT NULL AND ${table.extensionId} IS NULL) OR (${table.itemType} = 'folder' AND ${table.systemWindowId} IS NOT NULL AND ${table.extensionId} IS NULL)`, + ), + ], ) export type InsertHaexDesktopItems = typeof haexDesktopItems.$inferInsert export type SelectHaexDesktopItems = typeof haexDesktopItems.$inferSelect diff --git a/src-tauri/database/tableNames.json b/src-tauri/database/tableNames.json index ae8e4b4..7600483 100644 --- a/src-tauri/database/tableNames.json +++ b/src-tauri/database/tableNames.json @@ -80,7 +80,8 @@ "id": "id", "workspaceId": "workspace_id", "itemType": "item_type", - "referenceId": "reference_id", + "extensionId": "extension_id", + "systemWindowId": "system_window_id", "positionX": "position_x", "positionY": "position_y", diff --git a/src-tauri/database/vault.db b/src-tauri/database/vault.db index 4227ac3..ec908f2 100644 Binary files a/src-tauri/database/vault.db and b/src-tauri/database/vault.db differ diff --git a/src/components/haex/desktop/index.vue b/src/components/haex/desktop/index.vue index 46e5a4a..b03b367 100644 --- a/src/components/haex/desktop/index.vue +++ b/src/components/haex/desktop/index.vue @@ -41,18 +41,17 @@ /> - -
- - -
- + +
+ +
+
{ const handleWindowDragEnd = async () => { console.log('[Desktop] handleWindowDragEnd') + + // Check if window should snap to left or right + const draggingWindowId = windowManager.draggingWindowId + + if (draggingWindowId) { + if (showLeftSnapZone.value) { + // Snap to left half + windowManager.updateWindowPosition(draggingWindowId, 0, 0) + windowManager.updateWindowSize( + draggingWindowId, + viewportWidth.value / 2, + viewportHeight.value, + ) + } else if (showRightSnapZone.value) { + // Snap to right half + windowManager.updateWindowPosition( + draggingWindowId, + viewportWidth.value / 2, + 0, + ) + windowManager.updateWindowSize( + draggingWindowId, + viewportWidth.value / 2, + viewportHeight.value, + ) + } + } + isWindowDragging.value = false windowManager.draggingWindowId = null // Clear from store allowSwipe.value = true // Re-enable Swiper after drag diff --git a/src/components/haex/extension/launcher.vue b/src/components/haex/extension/launcher.vue index 1aea498..823e65d 100644 --- a/src/components/haex/extension/launcher.vue +++ b/src/components/haex/extension/launcher.vue @@ -55,9 +55,23 @@ + + +