From 3cefbc921fdf79bfe02266b0899a3a7163b03c4f Mon Sep 17 00:00:00 2001 From: Ramesh Mane <101566080+rameshmane7218@users.noreply.github.com> Date: Tue, 26 Nov 2024 05:46:55 +0000 Subject: [PATCH] fix: survey mode toggle api fail issue --- .../nc-gui/components/smartsheet/Form.vue | 4 +- packages/nocodb/src/services/views.service.ts | 52 ++++++++++--------- 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/Form.vue b/packages/nc-gui/components/smartsheet/Form.vue index 35b0d0a77f..753c0dde34 100644 --- a/packages/nc-gui/components/smartsheet/Form.vue +++ b/packages/nc-gui/components/smartsheet/Form.vue @@ -730,8 +730,8 @@ watch(submitted, (v) => { } }) -watch(view, (nextView) => { - if (nextView?.type === ViewTypes.FORM) { +watch(view, (nextView, oldView) => { + if (nextView?.type === ViewTypes.FORM && nextView?.id !== oldView?.id) { reloadEventHook.trigger() } }) diff --git a/packages/nocodb/src/services/views.service.ts b/packages/nocodb/src/services/views.service.ts index 92e4157dd1..ef3958b2af 100644 --- a/packages/nocodb/src/services/views.service.ts +++ b/packages/nocodb/src/services/views.service.ts @@ -278,34 +278,38 @@ export class ViewsService { NcError.viewNotFound(param.viewId); } - let customUrl: CustomUrl | undefined = await CustomUrl.get({ - view_id: view.id, - id: view.fk_custom_url_id, - }); + let customUrl: CustomUrl | undefined; + + if (param.sharedView.custom_url_path !== undefined) { + customUrl = await CustomUrl.get({ + view_id: view.id, + id: view.fk_custom_url_id, + }); - if (customUrl?.id) { - if (param.sharedView.custom_url_path) { - await CustomUrl.update(view.fk_custom_url_id, { + if (customUrl?.id) { + if (param.sharedView.custom_url_path) { + await CustomUrl.update(view.fk_custom_url_id, { + custom_path: param.sharedView.custom_url_path, + ...(customUrl.original_path !== param.sharedView.original_url + ? { + original_path: param.sharedView.original_url, + } + : {}), + }); + } else { + await CustomUrl.delete({ id: view.fk_custom_url_id as string }); + customUrl = undefined; + } + } else if (param.sharedView.custom_url_path) { + customUrl = await CustomUrl.insert({ + fk_workspace_id: view.fk_workspace_id, + base_id: view.base_id, + fk_model_id: view.fk_model_id, + view_id: view.id, + original_path: param.sharedView.original_url, custom_path: param.sharedView.custom_url_path, - ...(customUrl.original_path !== param.sharedView.original_url - ? { - original_path: param.sharedView.original_url, - } - : {}), }); - } else { - await CustomUrl.delete({ id: view.fk_custom_url_id as string }); - customUrl = undefined; } - } else { - customUrl = await CustomUrl.insert({ - fk_workspace_id: view.fk_workspace_id, - base_id: view.base_id, - fk_model_id: view.fk_model_id, - view_id: view.id, - original_path: param.sharedView.original_url, - custom_path: param.sharedView.custom_url_path, - }); } const result = await View.update(context, param.viewId, {