Files
directus/app/src/interfaces/list-m2m/index.ts
Azri Kahar 5789a391bd Add notice for display templates when creating M2M field (#10698)
* add notice for display templates when creating m2m

* Apply suggestions from code review

Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
2021-12-27 10:43:56 -05:00

91 lines
1.8 KiB
TypeScript

import { defineInterface } from '@directus/shared/utils';
import InterfaceListM2M from './list-m2m.vue';
import PreviewSVG from './preview.svg?raw';
export default defineInterface({
id: 'list-m2m',
name: '$t:interfaces.list-m2m.many-to-many',
description: '$t:interfaces.list-m2m.description',
icon: 'note_add',
component: InterfaceListM2M,
relational: true,
types: ['alias'],
localTypes: ['m2m'],
group: 'relational',
options: ({ editing, relations }) => {
const displayTemplateMeta =
editing === '+'
? {
interface: 'presentation-notice',
options: {
text: '$t:interfaces.list-m2m.display_template_configure_notice',
},
}
: {
interface: 'system-display-template',
options: {
collectionName: relations.o2m?.collection,
},
};
return [
{
field: 'template',
name: '$t:display_template',
meta: displayTemplateMeta,
},
{
field: 'enableCreate',
name: '$t:creating_items',
schema: {
default_value: true,
},
meta: {
interface: 'boolean',
options: {
label: '$t:enable_create_button',
},
width: 'half',
},
},
{
field: 'enableSelect',
name: '$t:selecting_items',
schema: {
default_value: true,
},
meta: {
interface: 'boolean',
options: {
label: '$t:enable_select_button',
},
width: 'half',
},
},
{
field: 'filter',
name: '$t:filter',
type: 'json',
meta: {
interface: 'system-filter',
options: {
collectionName: relations.m2o?.related_collection ?? null,
},
conditions: [
{
rule: {
enableSelect: {
_eq: false,
},
},
hidden: true,
},
],
},
},
];
},
recommendedDisplays: ['related-values'],
preview: PreviewSVG,
});