mirror of
https://github.com/directus/directus.git
synced 2026-02-17 05:21:41 -05:00
* add notice for display templates when creating m2m * Apply suggestions from code review Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
91 lines
1.8 KiB
TypeScript
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,
|
|
});
|