Pass field context to interface-options in conditions (#19147)

Fixes #19145
This commit is contained in:
Rijk van Zanten
2023-07-12 15:08:25 +02:00
committed by GitHub
parent fdee208297
commit 9d8eb5bcb5
3 changed files with 42 additions and 31 deletions

View File

@@ -0,0 +1,6 @@
---
'@directus/app': patch
---
Fixed issue that caused interface options within conditions to operate against a different field context, making some
options unavailable

View File

@@ -29,6 +29,7 @@
<script setup lang="ts">
import { useExtension } from '@/composables/use-extension';
import { ExtensionOptionsContext } from '@directus/types';
import { isVueComponent } from '@directus/utils';
import { computed, inject, ref } from 'vue';
import { useI18n } from 'vue-i18n';
@@ -39,6 +40,7 @@ const props = defineProps<{
interface?: string;
collection?: string;
disabled?: boolean;
context?: ExtensionOptionsContext;
}>();
const emit = defineEmits<{
@@ -73,32 +75,34 @@ const optionsFields = computed(() => {
let optionsObjectOrArray;
if (typeof selectedInterface.value.options === 'function') {
optionsObjectOrArray = selectedInterface.value.options({
field: {
type: 'unknown',
},
editing: '+',
collection: props.collection,
relations: {
o2m: undefined,
m2o: undefined,
m2a: undefined,
},
collections: {
related: undefined,
junction: undefined,
},
fields: {
corresponding: undefined,
junctionCurrent: undefined,
junctionRelated: undefined,
sort: undefined,
},
items: {},
localType: 'standard',
autoGenerateJunctionRelation: false,
saving: false,
});
optionsObjectOrArray = selectedInterface.value.options(
props.context ?? {
field: {
type: 'unknown',
},
editing: '+',
collection: props.collection,
relations: {
o2m: undefined,
m2o: undefined,
m2a: undefined,
},
collections: {
related: undefined,
junction: undefined,
},
fields: {
corresponding: undefined,
junctionCurrent: undefined,
junctionRelated: undefined,
sort: undefined,
},
items: {},
localType: 'standard',
autoGenerateJunctionRelation: false,
saving: false,
}
);
} else {
optionsObjectOrArray = selectedInterface.value.options;
}

View File

@@ -5,13 +5,13 @@
</template>
<script setup lang="ts">
import { computed, unref } from 'vue';
import { Field, DeepPartial } from '@directus/types';
import { useI18n } from 'vue-i18n';
import { useFieldDetailStore, syncFieldDetailStoreProperty } from '../store';
import { storeToRefs } from 'pinia';
import { useExtension } from '@/composables/use-extension';
import { DeepPartial, Field } from '@directus/types';
import { isVueComponent } from '@directus/utils';
import { storeToRefs } from 'pinia';
import { computed, unref } from 'vue';
import { useI18n } from 'vue-i18n';
import { syncFieldDetailStoreProperty, useFieldDetailStore } from '../store';
const { t } = useI18n();
@@ -92,6 +92,7 @@ const repeaterFields = computed<DeepPartial<Field>[]>(() => [
interface: 'system-interface-options',
options: {
interface: interfaceId.value,
context: fieldDetailStore,
},
},
},