File tree Expand file tree Collapse file tree 2 files changed +11
-7
lines changed
packages/ui/src/elements/WhereBuilder Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change 11'use client'
2- const boolean = [
2+ const equalsOperators = [
33 {
44 label : 'equals' ,
55 value : 'equals' ,
@@ -10,8 +10,7 @@ const boolean = [
1010 } ,
1111]
1212
13- const base = [
14- ...boolean ,
13+ export const arrayOperators = [
1514 {
1615 label : 'isIn' ,
1716 value : 'in' ,
@@ -26,6 +25,8 @@ const base = [
2625 } ,
2726]
2827
28+ const base = [ ...equalsOperators , ...arrayOperators ]
29+
2930const numeric = [
3031 ...base ,
3132 {
@@ -47,7 +48,7 @@ const numeric = [
4748]
4849
4950const geo = [
50- ...boolean ,
51+ ...equalsOperators ,
5152 {
5253 label : 'exists' ,
5354 value : 'exists' ,
@@ -91,7 +92,7 @@ const fieldTypeConditions: {
9192} = {
9293 checkbox : {
9394 component : 'Text' ,
94- operators : boolean ,
95+ operators : equalsOperators ,
9596 } ,
9697 code : {
9798 component : 'Text' ,
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import type { ReducedField } from './types.js'
1010
1111import { createNestedClientFieldPath } from '../../forms/Form/createNestedClientFieldPath.js'
1212import { combineFieldLabel } from '../../utilities/combineFieldLabel.js'
13- import fieldTypes from './field-types.js'
13+ import fieldTypes , { arrayOperators } from './field-types.js'
1414
1515type ReduceFieldOptionsArgs = {
1616 fields : ClientField [ ]
@@ -170,7 +170,10 @@ export const reduceFields = ({
170170 if ( typeof fieldTypes [ field . type ] === 'object' ) {
171171 const operatorKeys = new Set ( )
172172
173- const operators = fieldTypes [ field . type ] . operators . reduce ( ( acc , operator ) => {
173+ const fieldOperators =
174+ 'hasMany' in field && field . hasMany ? arrayOperators : fieldTypes [ field . type ] . operators
175+
176+ const operators = fieldOperators . reduce ( ( acc , operator ) => {
174177 if ( ! operatorKeys . has ( operator . value ) ) {
175178 operatorKeys . add ( operator . value )
176179 const operatorKey = `operators:${ operator . label } ` as ClientTranslationKeys
You can’t perform that action at this time.
0 commit comments