Skip to content

Commit 1705f12

Browse files
committed
feat
1 parent b2a24de commit 1705f12

File tree

4 files changed

+39
-8
lines changed

4 files changed

+39
-8
lines changed

src/components/BrowserFilter/FilterRow.react.js

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,33 @@ function compareValue(
2828
onKeyDown,
2929
active,
3030
parentContentId,
31-
setFocus
31+
setFocus,
32+
currentConstraint
3233
) {
34+
if (currentConstraint === 'containedIn') {
35+
return (
36+
<input
37+
type="text"
38+
value={Array.isArray(value) ? JSON.stringify(value) : value || ''}
39+
placeholder="[1, 2, 3]"
40+
onChange={e => {
41+
try {
42+
const parsed = JSON.parse(e.target.value);
43+
if (Array.isArray(parsed)) {
44+
onChangeCompareTo(parsed);
45+
} else {
46+
onChangeCompareTo(e.target.value);
47+
}
48+
} catch {
49+
onChangeCompareTo(e.target.value);
50+
}
51+
}}
52+
onKeyDown={onKeyDown}
53+
ref={setFocus}
54+
/>
55+
);
56+
}
57+
3358
switch (info.type) {
3459
case null:
3560
return null;
@@ -223,7 +248,8 @@ const FilterRow = ({
223248
onKeyDown,
224249
active,
225250
parentContentId,
226-
setFocus
251+
setFocus,
252+
currentConstraint
227253
)}
228254
<button type="button" className={styles.remove} onClick={onDeleteRow}>
229255
<Icon name="minus-solid" width={14} height={14} fill="rgba(0,0,0,0.4)" />

src/components/PushAudiencesSelector/PushAudiencesSelector.react.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const PushAudiencesOptions = ({ current, onChange, onEditAudience, schema, audie
2424
fromJS({
2525
field: 'deviceType',
2626
constraint: 'containedIn',
27-
array: query.deviceType['$in'],
27+
compareTo: query.deviceType['$in'],
2828
})
2929
)
3030
: query;

src/lib/Filters.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,20 +175,25 @@ export const Constraints = {
175175
field: null,
176176
comparable: false,
177177
},
178+
containedIn: {
179+
name: 'contained in',
180+
comparable: true,
181+
},
178182
};
179183

180184
export const FieldConstraints = {
181-
Pointer: ['exists', 'dne', 'eq', 'neq', 'starts', 'unique'],
182-
Boolean: ['exists', 'dne', 'eq', 'neq', 'unique'],
183-
Number: ['exists', 'dne', 'eq', 'neq', 'lt', 'lte', 'gt', 'gte', 'unique'],
184-
String: ['exists', 'dne', 'eq', 'neq', 'starts', 'ends', 'stringContainsString', 'unique'],
185+
Pointer: ['exists', 'dne', 'eq', 'neq', 'starts', 'containedIn', 'unique'],
186+
Boolean: ['exists', 'dne', 'eq', 'neq', 'containedIn', 'unique'],
187+
Number: ['exists', 'dne', 'eq', 'neq', 'lt', 'lte', 'gt', 'gte', 'containedIn', 'unique'],
188+
String: ['exists', 'dne', 'eq', 'neq', 'starts', 'ends', 'stringContainsString', 'containedIn', 'unique'],
185189
Date: [
186190
'exists',
187191
'dne',
188192
'before',
189193
'onOrBefore',
190194
'after',
191195
'onOrAfter',
196+
'containedIn',
192197
'unique',
193198
],
194199
Object: [

src/lib/queryFromFilters.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ function addConstraint(query, filter) {
166166
query.notEqualTo(filter.get('field'), filter.get('compareTo'));
167167
break;
168168
case 'containedIn':
169-
query.containedIn(filter.get('field'), filter.get('array'));
169+
query.containedIn(filter.get('field'), filter.get('compareTo'));
170170
break;
171171
case 'stringContainsString':
172172
query.matches(filter.get('field'), filter.get('compareTo'), 'i');

0 commit comments

Comments
 (0)