From 3f13565cf59d13a8f9aad83c7bb0a9cc526ef7fd Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Thu, 22 Aug 2024 17:17:25 +0900 Subject: [PATCH] Get relationship attribute renaming working --- .../collection-[collection]/attributes/edit.svelte | 4 +--- .../collection-[collection]/attributes/relationship.svelte | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/edit.svelte b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/edit.svelte index 2ecde6f3a..4dbf5da9d 100644 --- a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/edit.svelte +++ b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/edit.svelte @@ -32,11 +32,8 @@ }) as Option; async function submit() { - console.log(originalKey); - try { await option.update(databaseId, collectionId, selectedAttribute, originalKey); - originalKey = selectedAttribute.key; await invalidate(Dependencies.COLLECTION); if (!$page.url.pathname.includes('attributes')) { await goto( @@ -57,6 +54,7 @@ $: if (showEdit) { currentAttr ??= { ...selectedAttribute }; + originalKey = currentAttr.key; error = null; } diff --git a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/relationship.svelte b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/relationship.svelte index 341eb5a8e..337252c1d 100644 --- a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/relationship.svelte +++ b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/relationship.svelte @@ -35,10 +35,11 @@ if (!isValueOfStringEnum(RelationMutate, data.onDelete)) { throw new Error(`Invalid on delete: ${data.onDelete}`); } + await sdk.forProject.databases.updateRelationshipAttribute( databaseId, collectionId, - data.key, + originalKey, data.onDelete, data.key !== originalKey ? data.key : undefined, ); @@ -189,7 +190,6 @@ placeholder="Enter Key" bind:value={data.key} autofocus - readonly={editing} required />