strapi-relation-names 1.2.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,10 +2,13 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const designSystem = require("@strapi/design-system");
5
+ const styled = require("styled-components");
5
6
  const react = require("react");
6
7
  const reactIntl = require("react-intl");
7
8
  const admin = require("@strapi/strapi/admin");
8
- const index = require("./index-DFr0KRky.js");
9
+ const index = require("./index-DfSAe961.js");
10
+ const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
11
+ const styled__default = /* @__PURE__ */ _interopDefault(styled);
9
12
  const FIELD_TYPES = /* @__PURE__ */ new Set([
10
13
  "string",
11
14
  "text",
@@ -120,6 +123,21 @@ const getAvailableFields = (schema, schemas, prefix = "", ancestors = /* @__PURE
120
123
  return [...systemFields, ...fields.filter((field) => !systemFields.includes(field))];
121
124
  };
122
125
  const PLUGIN_SETTINGS_PATH = "/strapi-relation-names/settings";
126
+ const AvailableField = styled__default.default(designSystem.Typography)`
127
+ display: inline-block;
128
+ padding: 1px 4px;
129
+ border: 1px solid transparent;
130
+ border-radius: 4px;
131
+ background: transparent;
132
+ color: inherit;
133
+ cursor: pointer;
134
+ font: inherit;
135
+
136
+ &:hover,
137
+ &[aria-pressed='true'] {
138
+ border-color: currentColor;
139
+ }
140
+ `;
123
141
  const getRelationTarget = (attribute) => attribute.targetModel ?? attribute.target;
124
142
  const SettingsPage = () => {
125
143
  const { formatMessage } = reactIntl.useIntl();
@@ -201,7 +219,24 @@ const SettingsPage = () => {
201
219
  };
202
220
  return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Main, { "aria-labelledby": "relation-names-title", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { padding: 8, children: [
203
221
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", tag: "h1", id: "relation-names-title", children: formatMessage({ id: index.getTranslation("settings.title") }) }),
204
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 2, paddingBottom: 6, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", children: formatMessage({ id: index.getTranslation("settings.description") }) }) }),
222
+ /* @__PURE__ */ jsxRuntime.jsxs(
223
+ designSystem.Flex,
224
+ {
225
+ gap: 2,
226
+ width: "100%",
227
+ paddingBottom: 6,
228
+ style: {
229
+ "justify-content": "space-between",
230
+ position: "sticky",
231
+ top: ".5rem",
232
+ zIndex: 1
233
+ },
234
+ children: [
235
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", children: formatMessage({ id: index.getTranslation("settings.description") }) }),
236
+ !isLoading && rows.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { loading: isSaving, disabled: isSaving, onClick: () => void save(), children: formatMessage({ id: index.getTranslation("settings.save") }) }) : null
237
+ ]
238
+ }
239
+ ),
205
240
  isLoading ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatMessage({ id: index.getTranslation("settings.loading") }) }) : null,
206
241
  error ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger600", tag: "p", children: error }) : null,
207
242
  !isLoading && rows.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatMessage({ id: index.getTranslation("settings.noRelations") }) }) : null,
@@ -209,6 +244,12 @@ const SettingsPage = () => {
209
244
  const targetAttributes = target?.attributes ?? {};
210
245
  const template = settings.relations[source.uid]?.[fieldName] ?? "";
211
246
  const validationError = template ? validateTemplate(template, targetAttributes, schemaMap) : null;
247
+ const availableFields = getAvailableFields(target, schemaMap);
248
+ const toggleField = (field) => {
249
+ const placeholder = `{${field}}`;
250
+ const nextTemplate = template.includes(placeholder) ? template.replaceAll(placeholder, "").replace(/\s{2,}/g, " ").trim() : `${template.trim()}${template.trim() ? " " : ""}${placeholder}`;
251
+ updateTemplate(source.uid, fieldName, nextTemplate);
252
+ };
212
253
  return /* @__PURE__ */ jsxRuntime.jsxs(
213
254
  designSystem.Box,
214
255
  {
@@ -233,7 +274,9 @@ const SettingsPage = () => {
233
274
  error: validationError ?? void 0,
234
275
  name: `${source.uid}.${fieldName}`,
235
276
  children: [
236
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({ id: index.getTranslation("settings.template") }) }),
277
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({
278
+ id: index.getTranslation("settings.template")
279
+ }) }),
237
280
  /* @__PURE__ */ jsxRuntime.jsx(
238
281
  designSystem.TextInput,
239
282
  {
@@ -247,18 +290,34 @@ const SettingsPage = () => {
247
290
  ]
248
291
  }
249
292
  ),
250
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 2, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: [
251
- formatMessage({ id: index.getTranslation("settings.availableFields") }),
252
- ":",
253
- " ",
254
- getAvailableFields(target, schemaMap).join(", ")
255
- ] }) })
293
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 2, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Root, { collapsible: true, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Item, { value: "available-fields", children: [
294
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Trigger, { children: formatMessage({
295
+ id: index.getTranslation("settings.availableFields")
296
+ }) }) }),
297
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: availableFields.map((field, index2) => {
298
+ const placeholder = `{${field}}`;
299
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [
300
+ index2 > 0 ? ", " : null,
301
+ /* @__PURE__ */ jsxRuntime.jsx(
302
+ AvailableField,
303
+ {
304
+ as: "button",
305
+ type: "button",
306
+ variant: "pi",
307
+ textColor: "neutral600",
308
+ "aria-pressed": template.includes(placeholder),
309
+ onClick: () => toggleField(field),
310
+ children: field
311
+ }
312
+ )
313
+ ] }, field);
314
+ }) }) })
315
+ ] }) }) })
256
316
  ]
257
317
  },
258
318
  `${source.uid}.${fieldName}`
259
319
  );
260
- }) : null,
261
- !isLoading && rows.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "flex-end", paddingTop: 4, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { loading: isSaving, disabled: isSaving, onClick: () => void save(), children: formatMessage({ id: index.getTranslation("settings.save") }) }) }) : null
320
+ }) : null
262
321
  ] }) });
263
322
  };
264
323
  exports.SettingsPage = SettingsPage;
@@ -1,9 +1,10 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { Main, Box, Typography, Field, TextInput, Flex, Button } from "@strapi/design-system";
3
- import { useState, useCallback, useEffect, useMemo } from "react";
2
+ import { Main, Box, Typography, Flex, Button, Field, TextInput, Accordion } from "@strapi/design-system";
3
+ import styled from "styled-components";
4
+ import { useState, useCallback, useEffect, useMemo, Fragment } from "react";
4
5
  import { useIntl } from "react-intl";
5
6
  import { useFetchClient } from "@strapi/strapi/admin";
6
- import { g as getTranslation } from "./index-DdvdGn6T.mjs";
7
+ import { g as getTranslation } from "./index-CiS6cuI9.mjs";
7
8
  const FIELD_TYPES = /* @__PURE__ */ new Set([
8
9
  "string",
9
10
  "text",
@@ -118,6 +119,21 @@ const getAvailableFields = (schema, schemas, prefix = "", ancestors = /* @__PURE
118
119
  return [...systemFields, ...fields.filter((field) => !systemFields.includes(field))];
119
120
  };
120
121
  const PLUGIN_SETTINGS_PATH = "/strapi-relation-names/settings";
122
+ const AvailableField = styled(Typography)`
123
+ display: inline-block;
124
+ padding: 1px 4px;
125
+ border: 1px solid transparent;
126
+ border-radius: 4px;
127
+ background: transparent;
128
+ color: inherit;
129
+ cursor: pointer;
130
+ font: inherit;
131
+
132
+ &:hover,
133
+ &[aria-pressed='true'] {
134
+ border-color: currentColor;
135
+ }
136
+ `;
121
137
  const getRelationTarget = (attribute) => attribute.targetModel ?? attribute.target;
122
138
  const SettingsPage = () => {
123
139
  const { formatMessage } = useIntl();
@@ -199,7 +215,24 @@ const SettingsPage = () => {
199
215
  };
200
216
  return /* @__PURE__ */ jsx(Main, { "aria-labelledby": "relation-names-title", children: /* @__PURE__ */ jsxs(Box, { padding: 8, children: [
201
217
  /* @__PURE__ */ jsx(Typography, { variant: "alpha", tag: "h1", id: "relation-names-title", children: formatMessage({ id: getTranslation("settings.title") }) }),
202
- /* @__PURE__ */ jsx(Box, { paddingTop: 2, paddingBottom: 6, children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", children: formatMessage({ id: getTranslation("settings.description") }) }) }),
218
+ /* @__PURE__ */ jsxs(
219
+ Flex,
220
+ {
221
+ gap: 2,
222
+ width: "100%",
223
+ paddingBottom: 6,
224
+ style: {
225
+ "justify-content": "space-between",
226
+ position: "sticky",
227
+ top: ".5rem",
228
+ zIndex: 1
229
+ },
230
+ children: [
231
+ /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", children: formatMessage({ id: getTranslation("settings.description") }) }),
232
+ !isLoading && rows.length > 0 ? /* @__PURE__ */ jsx(Button, { loading: isSaving, disabled: isSaving, onClick: () => void save(), children: formatMessage({ id: getTranslation("settings.save") }) }) : null
233
+ ]
234
+ }
235
+ ),
203
236
  isLoading ? /* @__PURE__ */ jsx(Typography, { children: formatMessage({ id: getTranslation("settings.loading") }) }) : null,
204
237
  error ? /* @__PURE__ */ jsx(Typography, { textColor: "danger600", tag: "p", children: error }) : null,
205
238
  !isLoading && rows.length === 0 ? /* @__PURE__ */ jsx(Typography, { children: formatMessage({ id: getTranslation("settings.noRelations") }) }) : null,
@@ -207,6 +240,12 @@ const SettingsPage = () => {
207
240
  const targetAttributes = target?.attributes ?? {};
208
241
  const template = settings.relations[source.uid]?.[fieldName] ?? "";
209
242
  const validationError = template ? validateTemplate(template, targetAttributes, schemaMap) : null;
243
+ const availableFields = getAvailableFields(target, schemaMap);
244
+ const toggleField = (field) => {
245
+ const placeholder = `{${field}}`;
246
+ const nextTemplate = template.includes(placeholder) ? template.replaceAll(placeholder, "").replace(/\s{2,}/g, " ").trim() : `${template.trim()}${template.trim() ? " " : ""}${placeholder}`;
247
+ updateTemplate(source.uid, fieldName, nextTemplate);
248
+ };
210
249
  return /* @__PURE__ */ jsxs(
211
250
  Box,
212
251
  {
@@ -231,7 +270,9 @@ const SettingsPage = () => {
231
270
  error: validationError ?? void 0,
232
271
  name: `${source.uid}.${fieldName}`,
233
272
  children: [
234
- /* @__PURE__ */ jsx(Field.Label, { children: formatMessage({ id: getTranslation("settings.template") }) }),
273
+ /* @__PURE__ */ jsx(Field.Label, { children: formatMessage({
274
+ id: getTranslation("settings.template")
275
+ }) }),
235
276
  /* @__PURE__ */ jsx(
236
277
  TextInput,
237
278
  {
@@ -245,18 +286,34 @@ const SettingsPage = () => {
245
286
  ]
246
287
  }
247
288
  ),
248
- /* @__PURE__ */ jsx(Box, { paddingTop: 2, children: /* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral600", children: [
249
- formatMessage({ id: getTranslation("settings.availableFields") }),
250
- ":",
251
- " ",
252
- getAvailableFields(target, schemaMap).join(", ")
253
- ] }) })
289
+ /* @__PURE__ */ jsx(Box, { paddingTop: 2, children: /* @__PURE__ */ jsx(Accordion.Root, { collapsible: true, children: /* @__PURE__ */ jsxs(Accordion.Item, { value: "available-fields", children: [
290
+ /* @__PURE__ */ jsx(Accordion.Header, { children: /* @__PURE__ */ jsx(Accordion.Trigger, { children: formatMessage({
291
+ id: getTranslation("settings.availableFields")
292
+ }) }) }),
293
+ /* @__PURE__ */ jsx(Accordion.Content, { children: /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: availableFields.map((field, index) => {
294
+ const placeholder = `{${field}}`;
295
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
296
+ index > 0 ? ", " : null,
297
+ /* @__PURE__ */ jsx(
298
+ AvailableField,
299
+ {
300
+ as: "button",
301
+ type: "button",
302
+ variant: "pi",
303
+ textColor: "neutral600",
304
+ "aria-pressed": template.includes(placeholder),
305
+ onClick: () => toggleField(field),
306
+ children: field
307
+ }
308
+ )
309
+ ] }, field);
310
+ }) }) })
311
+ ] }) }) })
254
312
  ]
255
313
  },
256
314
  `${source.uid}.${fieldName}`
257
315
  );
258
- }) : null,
259
- !isLoading && rows.length > 0 ? /* @__PURE__ */ jsx(Flex, { justifyContent: "flex-end", paddingTop: 4, children: /* @__PURE__ */ jsx(Button, { loading: isSaving, disabled: isSaving, onClick: () => void save(), children: formatMessage({ id: getTranslation("settings.save") }) }) }) : null
316
+ }) : null
260
317
  ] }) });
261
318
  };
262
319
  export {
@@ -1,7 +1,7 @@
1
1
  const de = {
2
2
  "plugin.name": "Relationsnamen",
3
3
  "settings.title": "Relationsnamen",
4
- "settings.description": "Legen Sie fest, wie verknüpfte Einträge im Content Manager angezeigt werden. Verwenden Sie ein oder mehrere skalare Felder des verknüpften Inhaltstyps, zum Beispiel Vor- und Nachname.",
4
+ "settings.description": "Legen Sie fest, wie verknüpfte Einträge beschriftet werden, z. B. mit Vor- und Nachname.",
5
5
  "settings.target": "Verknüpfter Inhalt: {target}",
6
6
  "settings.template": "Bezeichnungsvorlage",
7
7
  "settings.availableFields": "Verfügbare Felder",
@@ -3,7 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const de = {
4
4
  "plugin.name": "Relationsnamen",
5
5
  "settings.title": "Relationsnamen",
6
- "settings.description": "Legen Sie fest, wie verknüpfte Einträge im Content Manager angezeigt werden. Verwenden Sie ein oder mehrere skalare Felder des verknüpften Inhaltstyps, zum Beispiel Vor- und Nachname.",
6
+ "settings.description": "Legen Sie fest, wie verknüpfte Einträge beschriftet werden, z. B. mit Vor- und Nachname.",
7
7
  "settings.target": "Verknüpfter Inhalt: {target}",
8
8
  "settings.template": "Bezeichnungsvorlage",
9
9
  "settings.availableFields": "Verfügbare Felder",
@@ -1,7 +1,7 @@
1
1
  const en = {
2
2
  "plugin.name": "Relation Names",
3
3
  "settings.title": "Relation Names",
4
- "settings.description": "Choose how related entries are displayed in the Content Manager. Use one or more scalar fields from the related content type, such as a first and last name.",
4
+ "settings.description": "Choose how related entries are labeled, using fields such as first and last name.",
5
5
  "settings.target": "Related content: {target}",
6
6
  "settings.template": "Label template",
7
7
  "settings.availableFields": "Available fields",
@@ -3,7 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const en = {
4
4
  "plugin.name": "Relation Names",
5
5
  "settings.title": "Relation Names",
6
- "settings.description": "Choose how related entries are displayed in the Content Manager. Use one or more scalar fields from the related content type, such as a first and last name.",
6
+ "settings.description": "Choose how related entries are labeled, using fields such as first and last name.",
7
7
  "settings.target": "Related content: {target}",
8
8
  "settings.template": "Label template",
9
9
  "settings.availableFields": "Available fields",
@@ -88,7 +88,7 @@ const plugin = {
88
88
  id: `${PLUGIN_ID}.plugin.name`,
89
89
  defaultMessage: "Relation Names"
90
90
  },
91
- Component: () => import("./SettingsPage-Blk-4H_X.mjs").then((module) => ({ default: module.SettingsPage })),
91
+ Component: () => import("./SettingsPage-DFZP5CZs.mjs").then((module) => ({ default: module.SettingsPage })),
92
92
  permissions: []
93
93
  });
94
94
  app.registerPlugin({
@@ -105,7 +105,7 @@ const plugin = {
105
105
  return Promise.all(
106
106
  locales.map(async (locale) => {
107
107
  try {
108
- const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => import("./de-a3KtzZ7N.mjs"), "./translations/en.json": () => import("./en-8w3y1FSw.mjs") }), `./translations/${locale}.json`, 3);
108
+ const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => import("./de-Bc81LkbY.mjs"), "./translations/en.json": () => import("./en-Bk-HIXNd.mjs") }), `./translations/${locale}.json`, 3);
109
109
  const newData = {};
110
110
  const keys = Object.keys(data);
111
111
  for (const key of keys) {
@@ -89,7 +89,7 @@ const plugin = {
89
89
  id: `${PLUGIN_ID}.plugin.name`,
90
90
  defaultMessage: "Relation Names"
91
91
  },
92
- Component: () => Promise.resolve().then(() => require("./SettingsPage-BGsuRnwx.js")).then((module2) => ({ default: module2.SettingsPage })),
92
+ Component: () => Promise.resolve().then(() => require("./SettingsPage-BebR4ghK.js")).then((module2) => ({ default: module2.SettingsPage })),
93
93
  permissions: []
94
94
  });
95
95
  app.registerPlugin({
@@ -106,7 +106,7 @@ const plugin = {
106
106
  return Promise.all(
107
107
  locales.map(async (locale) => {
108
108
  try {
109
- const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => Promise.resolve().then(() => require("./de-BBrO1tf0.js")), "./translations/en.json": () => Promise.resolve().then(() => require("./en-DlY6ZGdo.js")) }), `./translations/${locale}.json`, 3);
109
+ const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => Promise.resolve().then(() => require("./de-CsBvOsWR.js")), "./translations/en.json": () => Promise.resolve().then(() => require("./en-DT4g6X2H.js")) }), `./translations/${locale}.json`, 3);
110
110
  const newData = {};
111
111
  const keys = Object.keys(data);
112
112
  for (const key of keys) {
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const index = require("./index-DFr0KRky.js");
3
+ const index = require("./index-DfSAe961.js");
4
4
  exports.default = index.plugin;
@@ -1,4 +1,4 @@
1
- import { p } from "./index-DdvdGn6T.mjs";
1
+ import { p } from "./index-CiS6cuI9.mjs";
2
2
  export {
3
3
  p as default
4
4
  };
@@ -267,6 +267,11 @@ const matchesRelation = (source, candidate, targetModelType) => {
267
267
  const applyLabel = (value, hydrated, runtime) => {
268
268
  const label = renderTemplate(runtime, hydrated);
269
269
  if (label) {
270
+ const isNestedTemplate = runtime.placeholders.some((placeholder) => placeholder.includes("."));
271
+ const isIdentityField = runtime.displayField === "id" || runtime.displayField === "documentId";
272
+ if (isNestedTemplate && isIdentityField) {
273
+ return { ...value, label };
274
+ }
270
275
  return { ...value, [runtime.displayField]: label };
271
276
  }
272
277
  if (runtime.displayField === runtime.originalMainField) {
@@ -451,7 +456,11 @@ const relationLabels = ({ strapi }) => {
451
456
  }
452
457
  const editMetadata = isRecord$1(metadata.edit) ? metadata.edit : {};
453
458
  const configuredMainField = typeof editMetadata.mainField === "string" ? editMetadata.mainField : "id";
454
- const displayField = compiled.placeholders.some((placeholder) => placeholder.includes(".")) ? configuredMainField : compiled.displayField;
459
+ const isNestedTemplate = compiled.placeholders.some(
460
+ (placeholder) => placeholder.includes(".")
461
+ );
462
+ const isIdentityField = configuredMainField === "id" || configuredMainField === "documentId";
463
+ const displayField = isNestedTemplate && isIdentityField ? "label" : isNestedTemplate ? configuredMainField : compiled.displayField;
455
464
  metadatas[fieldName] = {
456
465
  ...metadata,
457
466
  edit: {
@@ -265,6 +265,11 @@ const matchesRelation = (source, candidate, targetModelType) => {
265
265
  const applyLabel = (value, hydrated, runtime) => {
266
266
  const label = renderTemplate(runtime, hydrated);
267
267
  if (label) {
268
+ const isNestedTemplate = runtime.placeholders.some((placeholder) => placeholder.includes("."));
269
+ const isIdentityField = runtime.displayField === "id" || runtime.displayField === "documentId";
270
+ if (isNestedTemplate && isIdentityField) {
271
+ return { ...value, label };
272
+ }
268
273
  return { ...value, [runtime.displayField]: label };
269
274
  }
270
275
  if (runtime.displayField === runtime.originalMainField) {
@@ -449,7 +454,11 @@ const relationLabels = ({ strapi }) => {
449
454
  }
450
455
  const editMetadata = isRecord$1(metadata.edit) ? metadata.edit : {};
451
456
  const configuredMainField = typeof editMetadata.mainField === "string" ? editMetadata.mainField : "id";
452
- const displayField = compiled.placeholders.some((placeholder) => placeholder.includes(".")) ? configuredMainField : compiled.displayField;
457
+ const isNestedTemplate = compiled.placeholders.some(
458
+ (placeholder) => placeholder.includes(".")
459
+ );
460
+ const isIdentityField = configuredMainField === "id" || configuredMainField === "documentId";
461
+ const displayField = isNestedTemplate && isIdentityField ? "label" : isNestedTemplate ? configuredMainField : compiled.displayField;
453
462
  metadatas[fieldName] = {
454
463
  ...metadata,
455
464
  edit: {
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "author": "Christoph Tupi <christoph.tupi@gmail.com>",
6
6
  "keywords": [],
7
7
  "type": "commonjs",
8
- "version": "1.2.0",
8
+ "version": "1.2.2",
9
9
  "strapi": {
10
10
  "kind": "plugin",
11
11
  "name": "strapi-relation-names",