From 9e9919545b11848fdc482825ad125a14f0a9bca8 Mon Sep 17 00:00:00 2001 From: CodeVoyager Date: Sat, 12 Oct 2024 14:24:08 +0200 Subject: [PATCH] fix: single types selectable for related --- admin/src/pages/SettingsPage/index.tsx | 14 +++++++++----- server/src/services/admin/admin.ts | 8 +++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/admin/src/pages/SettingsPage/index.tsx b/admin/src/pages/SettingsPage/index.tsx index 872ff01a..ab232495 100644 --- a/admin/src/pages/SettingsPage/index.tsx +++ b/admin/src/pages/SettingsPage/index.tsx @@ -94,7 +94,6 @@ const Inner = () => { const handleChange = (eventOrPath: FormChangeEvent, value?: any, nativeOnChange?: (eventOrPath: FormChangeEvent, value?: any) => void) => { if (nativeOnChange) { - let fieldName = eventOrPath; let fieldValue = value; @@ -108,15 +107,20 @@ const Inner = () => { setFormValueItem(fieldName, fieldValue); } - return nativeOnChange(eventOrPath as FormChangeEvent, fieldValue); } }; const setFormValueItem = (path: string, value: any) => { - setFormValue(set({ - ...formValue, - }, path, value)); + setFormValue((current) => + set( + { + ...current, + }, + path, + value + ) + ); }; const renderError = (error: string): string | undefined => { diff --git a/server/src/services/admin/admin.ts b/server/src/services/admin/admin.ts index df5c84cc..19579965 100644 --- a/server/src/services/admin/admin.ts +++ b/server/src/services/admin/admin.ts @@ -161,11 +161,7 @@ const adminService = (context: { strapi: Core.Strapi }) => ({ if (isSingleTypeWithPublishFlow) { const itemsCountOrBypass = isSingleTypeWithPublishFlow - ? await repository.count({ - publishedAt: { - $notNull: true, - }, - }) + ? await repository.count({}, 'published') : true; return returnType(itemsCountOrBypass !== 0); @@ -550,6 +546,8 @@ const adminService = (context: { strapi: Core.Strapi }) => ({ validateAdditionalFields(newConfig.additionalFields); + console.log({ newConfig }); + await pluginStore.set({ key: 'config', value: newConfig }); const removedFields = differenceBy(