From c258ba6b9e1a330c1a954e88cdfd50dec2759d6d Mon Sep 17 00:00:00 2001 From: rijkvanzanten Date: Fri, 27 Nov 2020 17:59:37 -0500 Subject: [PATCH] Fix interfaces/displays sometimes showing up in the wrong category Squashed commit of the following: commit 2e07fdc946c985a32db2c78a54f61527bb7671ea Author: rijkvanzanten Date: Fri Nov 27 17:59:20 2020 -0500 Properly scope interfaces to local app group commit 3d593a4b1c8493db29f934f3a336654ac11e0ea4 Author: rijkvanzanten Date: Fri Nov 27 17:47:30 2020 -0500 Rename localTypes to groups commit 5b2e882c8f3e700925d54f18bb54cdac98320f55 Author: rijkvanzanten Date: Fri Nov 27 17:46:55 2020 -0500 Check tighter for local group --- app/src/displays/related-values/index.ts | 2 +- app/src/displays/types.ts | 2 +- .../_system/interface/interface.vue | 2 +- app/src/interfaces/divider/index.ts | 1 + app/src/interfaces/file/index.ts | 4 ++-- app/src/interfaces/files/index.ts | 4 ++-- app/src/interfaces/image/index.ts | 4 ++-- app/src/interfaces/m2a-builder/index.ts | 4 ++-- app/src/interfaces/many-to-many/index.ts | 4 ++-- app/src/interfaces/many-to-one/index.ts | 4 ++-- app/src/interfaces/notice/index.ts | 1 + app/src/interfaces/one-to-many/index.ts | 4 ++-- app/src/interfaces/translations/index.ts | 2 +- app/src/interfaces/types.ts | 4 ++-- app/src/interfaces/user/index.ts | 2 +- .../routes/data-model/field-detail/store.ts | 19 +++++++++++-------- 16 files changed, 34 insertions(+), 29 deletions(-) diff --git a/app/src/displays/related-values/index.ts b/app/src/displays/related-values/index.ts index 0f7a74a589..99c24dfa7e 100644 --- a/app/src/displays/related-values/index.ts +++ b/app/src/displays/related-values/index.ts @@ -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)); diff --git a/app/src/displays/types.ts b/app/src/displays/types.ts index d40cfa44b1..e660339b70 100644 --- a/app/src/displays/types.ts +++ b/app/src/displays/types.ts @@ -30,7 +30,7 @@ export type DisplayConfig = { handler: DisplayHandlerFunction | Component; options: null | DeepPartial[] | Component; types: readonly typeof types[number][]; - localTypes?: readonly typeof localTypes[number][]; + groups?: readonly typeof localTypes[number][]; fields?: string[] | DisplayFieldsFunction; }; diff --git a/app/src/interfaces/_system/interface/interface.vue b/app/src/interfaces/_system/interface/interface.vue index e49e9a4ee3..907f1d84b5 100644 --- a/app/src/interfaces/_system/interface/interface.vue +++ b/app/src/interfaces/_system/interface/interface.vue @@ -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 { diff --git a/app/src/interfaces/divider/index.ts b/app/src/interfaces/divider/index.ts index c1e0bc4fed..661c81c6ec 100644 --- a/app/src/interfaces/divider/index.ts +++ b/app/src/interfaces/divider/index.ts @@ -10,6 +10,7 @@ export default defineInterface(({ i18n }) => ({ hideLabel: true, hideLoader: true, types: ['alias'], + groups: ['presentation'], options: [ { field: 'color', diff --git a/app/src/interfaces/file/index.ts b/app/src/interfaces/file/index.ts index 3940bbbdad..73f3bdfe42 100644 --- a/app/src/interfaces/file/index.ts +++ b/app/src/interfaces/file/index.ts @@ -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'], })); diff --git a/app/src/interfaces/files/index.ts b/app/src/interfaces/files/index.ts index f6d16ccde4..786c5699a5 100644 --- a/app/src/interfaces/files/index.ts +++ b/app/src/interfaces/files/index.ts @@ -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'], })); diff --git a/app/src/interfaces/image/index.ts b/app/src/interfaces/image/index.ts index 08e80f9335..40e152251c 100644 --- a/app/src/interfaces/image/index.ts +++ b/app/src/interfaces/image/index.ts @@ -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'], })); diff --git a/app/src/interfaces/m2a-builder/index.ts b/app/src/interfaces/m2a-builder/index.ts index 1531786895..d13f11c96b 100644 --- a/app/src/interfaces/m2a-builder/index.ts +++ b/app/src/interfaces/m2a-builder/index.ts @@ -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: [], })); diff --git a/app/src/interfaces/many-to-many/index.ts b/app/src/interfaces/many-to-many/index.ts index 62ff560397..04c225b08d 100644 --- a/app/src/interfaces/many-to-many/index.ts +++ b/app/src/interfaces/many-to-many/index.ts @@ -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'], })); diff --git a/app/src/interfaces/many-to-one/index.ts b/app/src/interfaces/many-to-one/index.ts index abab1d4154..b40c30b18b 100644 --- a/app/src/interfaces/many-to-one/index.ts +++ b/app/src/interfaces/many-to-one/index.ts @@ -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'], })); diff --git a/app/src/interfaces/notice/index.ts b/app/src/interfaces/notice/index.ts index 51563635e7..78c33dd4f9 100644 --- a/app/src/interfaces/notice/index.ts +++ b/app/src/interfaces/notice/index.ts @@ -10,6 +10,7 @@ export default defineInterface(({ i18n }) => ({ hideLabel: true, hideLoader: true, types: ['alias'], + groups: ['presentation'], options: [ { field: 'color', diff --git a/app/src/interfaces/one-to-many/index.ts b/app/src/interfaces/one-to-many/index.ts index 27c9e175fc..722a942dce 100644 --- a/app/src/interfaces/one-to-many/index.ts +++ b/app/src/interfaces/one-to-many/index.ts @@ -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'], })); diff --git a/app/src/interfaces/translations/index.ts b/app/src/interfaces/translations/index.ts index 1059d0b5e7..82ed184758 100644 --- a/app/src/interfaces/translations/index.ts +++ b/app/src/interfaces/translations/index.ts @@ -7,7 +7,7 @@ export default defineInterface(({ i18n }) => ({ name: i18n.t('translations'), icon: 'replay', types: ['alias'], - relationship: 'translations', + relational: true, component: InterfaceTranslations, options: TranslationsOptions, })); diff --git a/app/src/interfaces/types.ts b/app/src/interfaces/types.ts index b591fe02cb..c9b579874d 100644 --- a/app/src/interfaces/types.ts +++ b/app/src/interfaces/types.ts @@ -10,8 +10,8 @@ export type InterfaceConfig = { component: Component; options: DeepPartial[] | 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; diff --git a/app/src/interfaces/user/index.ts b/app/src/interfaces/user/index.ts index 93a7c06095..4d5c72eb76 100644 --- a/app/src/interfaces/user/index.ts +++ b/app/src/interfaces/user/index.ts @@ -8,7 +8,7 @@ export default defineInterface(({ i18n }) => ({ icon: 'person', component: InterfaceUser, types: ['uuid'], - relationship: 'm2o', + relational: true, options: [ { field: 'selectMode', diff --git a/app/src/modules/settings/routes/data-model/field-detail/store.ts b/app/src/modules/settings/routes/data-model/field-detail/store.ts index 202f9620da..cfaa67ea50 100644 --- a/app/src/modules/settings/routes/data-model/field-detail/store.ts +++ b/app/src/modules/settings/routes/data-model/field-detail/store.ts @@ -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 !== '+';