mirror of
https://github.com/directus/directus.git
synced 2026-02-12 08:34:56 -05:00
Add support for Conditional Fields (#6864)
* Add conditions field to directus_fields * Add conditions configuration * Apply conditional overrides * Handle conditions in nested groups * Fix reverse mutating conditions * Start on filter setup interface * Move field types/constants to shared * [WIP] Updated client side filter validation * Support logical operators in client validation step * Use new validation util in conditions check * Add nesting in filter seutp * Add filter rule setup configurator * Fixes that should've been done in the merge * Strip out filter-settings interface TBD in a new PR * Move browser to index
This commit is contained in:
@@ -45,7 +45,7 @@ import { useI18n } from 'vue-i18n';
|
||||
import { defineComponent, PropType, computed } from 'vue';
|
||||
import { Filter } from '@directus/shared/types';
|
||||
import { useFieldsStore } from '@/stores';
|
||||
import getAvailableOperatorsForType from './get-available-operators-for-type';
|
||||
import { getFilterOperatorsForType } from '@directus/shared/utils';
|
||||
import FilterInput from './filter-input.vue';
|
||||
|
||||
export default defineComponent({
|
||||
@@ -94,7 +94,7 @@ export default defineComponent({
|
||||
|
||||
const parsedField = computed(() => {
|
||||
const field = getFieldForKey(props.filter.field);
|
||||
return getAvailableOperatorsForType(field.type);
|
||||
return getFilterOperatorsForType(field.type);
|
||||
});
|
||||
|
||||
return { t, activeOperator, value, name, parsedField };
|
||||
|
||||
@@ -50,7 +50,7 @@ import { nanoid } from 'nanoid';
|
||||
import { debounce } from 'lodash';
|
||||
import FieldListItem from './field-list-item.vue';
|
||||
import { useCollection } from '@/composables/use-collection';
|
||||
import getAvailableOperatorsForType from './get-available-operators-for-type';
|
||||
import { getFilterOperatorsForType } from '@directus/shared/utils';
|
||||
import { useFieldTree } from '@/composables/use-field-tree';
|
||||
|
||||
export default defineComponent({
|
||||
@@ -143,7 +143,7 @@ export default defineComponent({
|
||||
|
||||
function addFilterForField(fieldKey: string) {
|
||||
const field = fieldsStore.getField(props.collection, fieldKey) as Field;
|
||||
const defaultOperator = getAvailableOperatorsForType(field.type).operators[0];
|
||||
const defaultOperator = getFilterOperatorsForType(field.type).operators[0];
|
||||
|
||||
emit('update:modelValue', [
|
||||
...props.modelValue,
|
||||
|
||||
@@ -3,8 +3,3 @@ export type FieldTree = {
|
||||
name: string;
|
||||
children?: FieldTree[];
|
||||
};
|
||||
|
||||
export type OperatorType = {
|
||||
type: string;
|
||||
operators: string[];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user