Fix interfaces/displays sometimes showing up in the wrong category

Squashed commit of the following:

commit 2e07fdc946c985a32db2c78a54f61527bb7671ea
Author: rijkvanzanten <rijkvanzanten@me.com>
Date:   Fri Nov 27 17:59:20 2020 -0500

    Properly scope interfaces to local app group

commit 3d593a4b1c8493db29f934f3a336654ac11e0ea4
Author: rijkvanzanten <rijkvanzanten@me.com>
Date:   Fri Nov 27 17:47:30 2020 -0500

    Rename localTypes to groups

commit 5b2e882c8f3e700925d54f18bb54cdac98320f55
Author: rijkvanzanten <rijkvanzanten@me.com>
Date:   Fri Nov 27 17:46:55 2020 -0500

    Check tighter for local group
This commit is contained in:
rijkvanzanten
2020-11-27 17:59:37 -05:00
parent 2d8922ffdb
commit c258ba6b9e
16 changed files with 34 additions and 29 deletions

View File

@@ -19,7 +19,7 @@ export default defineDisplay(({ i18n }) => ({
handler: DisplayRelatedValues,
options: options,
types: ['alias', 'string', 'uuid', 'integer', 'bigInteger', 'json'],
localTypes: ['m2m', 'm2o', 'o2m'],
groups: ['m2m', 'm2o', 'o2m'],
fields: (options: Options, { field, collection }) => {
const relatedCollection = getRelatedCollection(collection, field);
const { primaryKeyField } = useCollection(ref(relatedCollection as string));

View File

@@ -30,7 +30,7 @@ export type DisplayConfig = {
handler: DisplayHandlerFunction | Component;
options: null | DeepPartial<Field>[] | Component;
types: readonly typeof types[number][];
localTypes?: readonly typeof localTypes[number][];
groups?: readonly typeof localTypes[number][];
fields?: string[] | DisplayFieldsFunction;
};

View File

@@ -40,7 +40,7 @@ export default defineComponent({
const items = computed(() => {
return interfaces.value
.filter((inter) => inter.relationship === undefined && inter.system !== true)
.filter((inter) => inter.relational !== true && inter.system !== true)
.filter((inter) => selectedType.value === undefined || inter.types.includes(selectedType.value))
.map((inter) => {
return {

View File

@@ -10,6 +10,7 @@ export default defineInterface(({ i18n }) => ({
hideLabel: true,
hideLoader: true,
types: ['alias'],
groups: ['presentation'],
options: [
{
field: 'color',

View File

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

View File

@@ -9,8 +9,8 @@ export default defineInterface(({ i18n }) => ({
icon: 'note_add',
component: InterfaceFiles,
types: ['alias'],
localTypes: ['files'],
relationship: 'm2m',
groups: ['files'],
relational: true,
options: FilesOptions,
recommendedDisplays: ['files'],
}));

View File

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

View File

@@ -6,8 +6,8 @@ export default defineInterface(({ i18n }) => ({
name: i18n.t('m2a_builder'),
icon: 'note_add',
component: InterfaceManyToAny,
relationship: 'm2a',
relational: true,
types: ['alias'],
localTypes: ['m2a'],
groups: ['m2a'],
options: [],
}));

View File

@@ -8,9 +8,9 @@ export default defineInterface(({ i18n }) => ({
description: i18n.t('interfaces.many-to-many.description'),
icon: 'note_add',
component: InterfaceManyToMany,
relationship: 'm2m',
relational: true,
types: ['alias'],
localTypes: ['m2m'],
groups: ['m2m'],
options: Options,
recommendedDisplays: ['related-values'],
}));

View File

@@ -9,8 +9,8 @@ export default defineInterface(({ i18n }) => ({
icon: 'arrow_right_alt',
component: InterfaceManyToOne,
types: ['uuid', 'string', 'text', 'integer', 'bigInteger'],
relationship: 'm2o',
localTypes: ['m2o'],
relational: true,
groups: ['m2o'],
options: Options,
recommendedDisplays: ['related-values'],
}));

View File

@@ -10,6 +10,7 @@ export default defineInterface(({ i18n }) => ({
hideLabel: true,
hideLoader: true,
types: ['alias'],
groups: ['presentation'],
options: [
{
field: 'color',

View File

@@ -9,8 +9,8 @@ export default defineInterface(({ i18n }) => ({
icon: 'arrow_right_alt',
component: InterfaceOneToMany,
types: ['alias'],
localTypes: ['o2m'],
relationship: 'o2m',
groups: ['o2m'],
relational: true,
options: Options,
recommendedDisplays: ['related-values'],
}));

View File

@@ -7,7 +7,7 @@ export default defineInterface(({ i18n }) => ({
name: i18n.t('translations'),
icon: 'replay',
types: ['alias'],
relationship: 'translations',
relational: true,
component: InterfaceTranslations,
options: TranslationsOptions,
}));

View File

@@ -10,8 +10,8 @@ export type InterfaceConfig = {
component: Component;
options: DeepPartial<Field>[] | Component;
types: typeof types[number][];
localTypes?: readonly typeof localTypes[number][];
relationship?: null | 'm2o' | 'o2m' | 'm2m' | 'm2a' | 'translations';
groups?: readonly typeof localTypes[number][];
relational?: boolean;
hideLabel?: boolean;
hideLoader?: boolean;
system?: boolean;

View File

@@ -8,7 +8,7 @@ export default defineInterface(({ i18n }) => ({
icon: 'person',
component: InterfaceUser,
types: ['uuid'],
relationship: 'm2o',
relational: true,
options: [
{
field: 'selectMode',

View File

@@ -67,20 +67,23 @@ 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) || true;
const matchesLocalType = (inter.groups || ['standard']).includes(type);
return matchesType && matchesLocalType;
})
.sort((a, b) => (a.name > b.name ? 1 : -1));
});
availableDisplays = computed(() =>
displays.value.filter((display) => {
const matchesType = display.types.includes(state.fieldData?.type || 'alias');
let matchesLocalType = display.localTypes?.includes(type);
return matchesType && (matchesLocalType === undefined || matchesLocalType);
})
);
availableDisplays = computed(() => {
return displays.value
.filter((inter) => {
const matchesType = inter.types.includes(state.fieldData?.type || 'alias');
const matchesLocalType = (inter.groups || ['standard']).includes(type) || true;
return matchesType && matchesLocalType;
})
.sort((a, b) => (a.name > b.name ? 1 : -1));
});
const isExisting = field !== '+';