mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Fix M2A filter scope on select existing (#14530)
* Fix list animation in m2a * Add missing collection scope to m2a selection filter Fixes #13598
This commit is contained in:
@@ -111,7 +111,7 @@
|
||||
</div>
|
||||
|
||||
<drawer-collection
|
||||
v-if="!disabled && !!selectingFrom"
|
||||
v-if="!disabled"
|
||||
multiple
|
||||
:active="!!selectingFrom"
|
||||
:collection="selectingFrom"
|
||||
@@ -136,18 +136,18 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useRelationM2A, useRelationMultiple, RelationQueryMultiple, DisplayItem } from '@/composables/use-relation';
|
||||
import { Filter } from '@directus/shared/types';
|
||||
import { getFieldsFromTemplate } from '@directus/shared/utils';
|
||||
import { computed, ref, toRefs } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import DrawerItem from '@/views/private/components/drawer-item';
|
||||
import DrawerCollection from '@/views/private/components/drawer-collection';
|
||||
import Draggable from 'vuedraggable';
|
||||
import adjustFieldsForDisplays from '@/utils/adjust-fields-for-displays';
|
||||
import { get, clamp } from 'lodash';
|
||||
import { hideDragImage } from '@/utils/hide-drag-image';
|
||||
import { DisplayItem, RelationQueryMultiple, useRelationM2A, useRelationMultiple } from '@/composables/use-relation';
|
||||
import { addRelatedPrimaryKeyToFields } from '@/utils/add-related-primary-key-to-fields';
|
||||
import adjustFieldsForDisplays from '@/utils/adjust-fields-for-displays';
|
||||
import { hideDragImage } from '@/utils/hide-drag-image';
|
||||
import DrawerCollection from '@/views/private/components/drawer-collection';
|
||||
import DrawerItem from '@/views/private/components/drawer-item';
|
||||
import { Filter, FieldFilter } from '@directus/shared/types';
|
||||
import { getFieldsFromTemplate } from '@directus/shared/utils';
|
||||
import { clamp, get } from 'lodash';
|
||||
import { computed, ref, toRefs, unref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import Draggable from 'vuedraggable';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
@@ -328,20 +328,29 @@ function getCollectionName(item: DisplayItem) {
|
||||
const customFilter = computed(() => {
|
||||
const info = relationInfo.value;
|
||||
|
||||
if (!info || !selectingFrom.value) return {};
|
||||
|
||||
const filter: Filter = {
|
||||
_and: [],
|
||||
};
|
||||
|
||||
if (!info || !selectingFrom.value) return filter;
|
||||
|
||||
const reverseRelation = `$FOLLOW(${info.junctionCollection.collection},${info.junctionField.field},${info.collectionField.field})`;
|
||||
|
||||
const selectFilter: Filter = {
|
||||
[reverseRelation]: {
|
||||
_none: {
|
||||
[relationInfo.value.reverseJunctionField.field]: {
|
||||
_eq: props.primaryKey,
|
||||
},
|
||||
_and: [
|
||||
{
|
||||
[relationInfo.value.reverseJunctionField.field]: {
|
||||
_eq: props.primaryKey,
|
||||
},
|
||||
},
|
||||
{
|
||||
[info.collectionField.field]: {
|
||||
_eq: unref(selectingFrom),
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user