From 0289d9bdfd33278bf7349d826fb19160f9745e24 Mon Sep 17 00:00:00 2001 From: Chareice Date: Thu, 24 Oct 2024 15:26:53 +0800 Subject: [PATCH] chore: displayInAssociation --- .../src/server/server.ts | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/packages/plugins/@nocobase/plugin-data-source-main/src/server/server.ts b/packages/plugins/@nocobase/plugin-data-source-main/src/server/server.ts index bcd7320ab2..0f7c8d9b3a 100644 --- a/packages/plugins/@nocobase/plugin-data-source-main/src/server/server.ts +++ b/packages/plugins/@nocobase/plugin-data-source-main/src/server/server.ts @@ -432,6 +432,21 @@ export class PluginDataSourceMainServer extends Plugin { } }); + // set final options + field.set('options', newOptions); + } else { + const collectionField = this.app.db.getCollection(field.get('collectionName'))?.getField(field.get('name')); + const newOptions: any = {}; + // merge with current field options + lodash.mergeWith(newOptions, field.get(), (objValue, srcValue) => { + if (srcValue === null) { + return objValue; + } + }); + + if (collectionField.options.displayInAssociation !== undefined) { + newOptions.displayInAssociation = collectionField.options.displayInAssociation; + } // set final options field.set('options', newOptions); } @@ -448,10 +463,8 @@ export class PluginDataSourceMainServer extends Plugin { ctx.action.params?.paginate == 'false' ) { for (const collection of ctx.body) { - if (collection.get('view')) { - const fields = collection.fields; - handleFieldSource(fields); - } + const fields = collection.fields; + handleFieldSource(fields); } }