mirror of
https://github.com/directus/directus.git
synced 2026-01-24 16:28:10 -05:00
Add localType to interfaces
This commit is contained in:
@@ -8,6 +8,7 @@ export default defineInterface(({ i18n }) => ({
|
||||
icon: 'note_add',
|
||||
component: InterfaceFile,
|
||||
types: ['uuid'],
|
||||
localTypes: ['file'],
|
||||
relationship: 'm2o',
|
||||
options: [],
|
||||
recommendedDisplays: ['file'],
|
||||
|
||||
@@ -8,6 +8,7 @@ export default defineInterface(({ i18n }) => ({
|
||||
icon: 'note_add',
|
||||
component: InterfaceFiles,
|
||||
types: ['alias'],
|
||||
localTypes: ['files'],
|
||||
relationship: 'm2m',
|
||||
options: [],
|
||||
recommendedDisplays: ['files'],
|
||||
|
||||
@@ -8,6 +8,7 @@ export default defineInterface(({ i18n }) => ({
|
||||
icon: 'insert_photo',
|
||||
component: InterfaceImage,
|
||||
types: ['uuid'],
|
||||
localTypes: ['file'],
|
||||
relationship: 'm2o',
|
||||
options: [],
|
||||
recommendedDisplays: ['image'],
|
||||
|
||||
@@ -10,6 +10,7 @@ export default defineInterface(({ i18n }) => ({
|
||||
component: InterfaceManyToMany,
|
||||
relationship: 'm2m',
|
||||
types: ['alias'],
|
||||
localTypes: ['m2m'],
|
||||
options: Options,
|
||||
recommendedDisplays: ['related-values'],
|
||||
}));
|
||||
|
||||
@@ -10,6 +10,7 @@ export default defineInterface(({ i18n }) => ({
|
||||
component: InterfaceManyToOne,
|
||||
types: ['uuid', 'string', 'text', 'integer', 'bigInteger'],
|
||||
relationship: 'm2o',
|
||||
localTypes: ['m2o'],
|
||||
options: Options,
|
||||
recommendedDisplays: ['related-values'],
|
||||
}));
|
||||
|
||||
@@ -9,6 +9,7 @@ export default defineInterface(({ i18n }) => ({
|
||||
icon: 'arrow_right_alt',
|
||||
component: InterfaceOneToMany,
|
||||
types: ['alias'],
|
||||
localTypes: ['o2m'],
|
||||
relationship: 'o2m',
|
||||
options: Options,
|
||||
recommendedDisplays: ['related-values'],
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import VueI18n from 'vue-i18n';
|
||||
import { Component } from 'vue';
|
||||
import { Field, types } from '@/types';
|
||||
import { Field, types, localTypes } from '@/types';
|
||||
|
||||
export type InterfaceConfig = {
|
||||
id: string;
|
||||
@@ -10,6 +10,7 @@ export type InterfaceConfig = {
|
||||
component: Component;
|
||||
options: DeepPartial<Field>[] | Component;
|
||||
types: typeof types[number][];
|
||||
localTypes?: readonly typeof localTypes[number][];
|
||||
relationship?: null | 'm2o' | 'o2m' | 'm2m' | 'translations';
|
||||
hideLabel?: boolean;
|
||||
hideLoader?: boolean;
|
||||
|
||||
@@ -67,6 +67,7 @@ function initLocalStore(collection: string, field: string, type: typeof localTyp
|
||||
if (inter.system === true) return false;
|
||||
|
||||
const matchesType = inter.types.includes(state.fieldData?.type || 'alias');
|
||||
const matchesLocalType = inter.localTypes?.includes(type);
|
||||
let matchesRelation = false;
|
||||
|
||||
if (type === 'standard' || type === 'presentation') {
|
||||
@@ -81,7 +82,7 @@ function initLocalStore(collection: string, field: string, type: typeof localTyp
|
||||
matchesRelation = inter.relationship === type;
|
||||
}
|
||||
|
||||
return matchesType && matchesRelation;
|
||||
return matchesType && matchesRelation && (matchesLocalType === undefined || matchesLocalType);
|
||||
})
|
||||
.sort((a, b) => (a.name > b.name ? 1 : -1));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user