Add localType to interfaces

This commit is contained in:
Nitwel
2020-10-24 12:47:11 +02:00
parent fc8bdffeee
commit d7f2ab11fd
8 changed files with 10 additions and 2 deletions

View File

@@ -8,6 +8,7 @@ export default defineInterface(({ i18n }) => ({
icon: 'note_add',
component: InterfaceFile,
types: ['uuid'],
localTypes: ['file'],
relationship: 'm2o',
options: [],
recommendedDisplays: ['file'],

View File

@@ -8,6 +8,7 @@ export default defineInterface(({ i18n }) => ({
icon: 'note_add',
component: InterfaceFiles,
types: ['alias'],
localTypes: ['files'],
relationship: 'm2m',
options: [],
recommendedDisplays: ['files'],

View File

@@ -8,6 +8,7 @@ export default defineInterface(({ i18n }) => ({
icon: 'insert_photo',
component: InterfaceImage,
types: ['uuid'],
localTypes: ['file'],
relationship: 'm2o',
options: [],
recommendedDisplays: ['image'],

View File

@@ -10,6 +10,7 @@ export default defineInterface(({ i18n }) => ({
component: InterfaceManyToMany,
relationship: 'm2m',
types: ['alias'],
localTypes: ['m2m'],
options: Options,
recommendedDisplays: ['related-values'],
}));

View File

@@ -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'],
}));

View File

@@ -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'],

View File

@@ -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;

View File

@@ -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));
});