Skip to content

Commit

Permalink
Fix invalid collection for Interface Display Template for M2M relatio…
Browse files Browse the repository at this point in the history
…nships (directus#9420)

* Fix invalid collection for Interface Display Template (directus#9419)

* use o2m ollection on m2m interface

* apply same fix on files

Co-authored-by: Jose Varela <joselcvarela@gmail.com>
  • Loading branch information
2 people authored and Armen Danielyan committed Nov 9, 2021
1 parent c8aaace commit 604c485
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 47 deletions.
94 changes: 48 additions & 46 deletions app/src/interfaces/files/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,59 +13,61 @@ export default defineInterface({
types: ['alias'],
localTypes: ['files'],
group: 'relational',
options: ({ relations }: ExtensionsOptionsContext) => [
{
field: 'folder',
name: '$t:interfaces.system-folder.folder',
type: 'uuid',
meta: {
width: 'full',
interface: 'system-folder',
note: '$t:interfaces.system-folder.field_hint',
},
schema: {
default_value: undefined,
},
},
{
field: 'template',
name: '$t:display_template',
meta: {
interface: 'system-display-template',
options: {
collectionName: relations.m2o?.related_collection ?? null,
options: ({ relations }: ExtensionsOptionsContext) => {
return [
{
field: 'folder',
name: '$t:interfaces.system-folder.folder',
type: 'uuid',
meta: {
width: 'full',
interface: 'system-folder',
note: '$t:interfaces.system-folder.field_hint',
},
schema: {
default_value: undefined,
},
},
},
{
field: 'enableCreate',
name: '$t:creating_items',
schema: {
default_value: true,
},
meta: {
interface: 'boolean',
options: {
label: '$t:enable_create_button',
{
field: 'template',
name: '$t:display_template',
meta: {
interface: 'system-display-template',
options: {
collectionName: relations.o2m?.collection,
},
},
width: 'half',
},
},
{
field: 'enableSelect',
name: '$t:selecting_items',
schema: {
default_value: true,
{
field: 'enableCreate',
name: '$t:creating_items',
schema: {
default_value: true,
},
meta: {
interface: 'boolean',
options: {
label: '$t:enable_create_button',
},
width: 'half',
},
},
meta: {
interface: 'boolean',
options: {
label: '$t:enable_select_button',
{
field: 'enableSelect',
name: '$t:selecting_items',
schema: {
default_value: true,
},
meta: {
interface: 'boolean',
options: {
label: '$t:enable_select_button',
},
width: 'half',
},
width: 'half',
},
},
],
];
},
recommendedDisplays: ['related-values'],
preview: PreviewSVG,
});
2 changes: 1 addition & 1 deletion app/src/interfaces/list-m2m/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default defineInterface({
meta: {
interface: 'system-display-template',
options: {
collectionName: relations.m2o?.related_collection ?? null,
collectionName: relations.o2m?.collection,
},
},
},
Expand Down

0 comments on commit 604c485

Please sign in to comment.