Skip to content

Commit 70515a5

Browse files
authored
Added supprt of !group and $elemMatch (#147)
1 parent 726fdf4 commit 70515a5

32 files changed

+667
-173
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# Changelog
2+
- 1.3.0
3+
- Added support of `!group`
24
- 1.2.0
35
- Added `treeselect` and `treemultiselect` types
46
- Changed format of `listValues` from `{<value>: <title>}` to `[{value, title}]` (old is supported).

CONFIG.adoc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,9 @@ const myConfig = {
151151
[cols="1m,1,1,5a",options="header"]
152152
|===
153153
|key |required |default |meaning
154-
|type |+ | |One of types described in link:#configtypes[config.types] or `!struct` for complex field
155-
|subfields |+ for `!struct` type | |Config for subfields of complex field (multiple nesting is supported)
154+
|type |+ | |One of types described in link:#configtypes[config.types] or `!struct`/`!group` for complex field +
155+
(`!group` can be used with https://docs.mongodb.com/manual/reference/operator/query/elemMatch/[elemMatch] in MongoDb)
156+
|subfields |+ for `!struct`/`!group` type | |Config for subfields of complex field (multiple nesting is supported)
156157
|label |+ | |Label to be displayed in field list +
157158
(If not specified, fields's key will be used instead)
158159
|label2 | | |Can be optionally specified for nested fields. +

css/compact_styles.scss

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
.group {
1717
padding-left: 0px;
1818
}
19+
.rule_group {
20+
padding-left: 5px;
21+
}
1922

2023
.group--children {
2124
@extend %force_nomargin;
@@ -42,24 +45,62 @@
4245
}
4346

4447
.group-or-rule-container {
45-
margin-bottom: 5px;
46-
padding-right: 5px;
48+
margin-top: 5px;
49+
margin-bottom: 5px;
50+
padding-right: 5px;
51+
}
52+
.group--children {
53+
margin-top: 5px !important;
54+
margin-bottom: 5px !important;
55+
}
56+
.group--header,
57+
.group--footer {
58+
margin: {
59+
top: 5px !important;
60+
bottom: 5px !important;
61+
}
4762
}
4863

4964
.rule--operator, .widget--widget, .widget--valuesrc, .widget--sep {
5065
margin-left: 5px;
5166
}
67+
68+
.rule_group {
69+
.group--actions {
70+
margin-left: 5px;
71+
}
72+
.rule_group--children {
73+
padding-left: 10px !important;
74+
&.one--child {
75+
padding-left: 5px !important;
76+
}
77+
78+
& > .group-or-rule-container > .group-or-rule {
79+
&::before, &::after {
80+
left: -7px;
81+
width: 7px;
82+
}
83+
}
84+
}
85+
}
86+
5287
.widget--valuesrc {
5388
margin-right: -3px;
5489
}
5590
.operator--options--sep {
5691
margin-right: 5px;
5792
}
5893
.group--header {
59-
padding: 5px;
60-
padding-left: 0;
94+
padding: {
95+
left: 0;
96+
right: 5px;
97+
}
98+
margin: 0;
6199
}
62100

101+
.group--drag-handler {
102+
margin-left: 5px;
103+
}
63104

64105
.rule--func--arg-value > .rule--widget {
65106
margin-left: -5px;

css/styles.scss

Lines changed: 107 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ body.qb-dragging {
8181
position: relative;
8282
}
8383

84+
.rule_group {
85+
background: rgba(255, 252, 242, 0.5);
86+
border: 1px solid #f9f1dd;
87+
}
88+
8489
.qb-draggable {
8590
@extend %noselect;
8691
pointer-events: none;
@@ -93,11 +98,6 @@ body.qb-dragging {
9398
border: 1px dashed gray;
9499
}
95100

96-
.group-or-rule-container {
97-
margin-bottom: 10px;
98-
padding-right: 10px;
99-
}
100-
101101
/* slider */
102102
.ant-tooltip-inner {
103103
min-height: 18px;
@@ -141,7 +141,7 @@ ul.ant-select-selection__rendered {
141141

142142
&::after {
143143
top: 50%;
144-
border-width: 0 0 0 2px;
144+
border-width: 0 0 0 2px;
145145
}
146146

147147
&::before, &::after {
@@ -159,6 +159,16 @@ ul.ant-select-selection__rendered {
159159
}
160160

161161

162+
&.rule_group--children > .group-or-rule-container:first-child > .group-or-rule {
163+
&::before {
164+
display: none;
165+
}
166+
&::after {
167+
border-radius: 4px 0 0 0;
168+
border-width: 2 0 0 2px;
169+
}
170+
}
171+
162172
& > .group-or-rule-container:first-child > .group-or-rule {
163173
&::before {
164174
top: -12px;
@@ -197,13 +207,12 @@ ul.ant-select-selection__rendered {
197207
cursor: grabbing;
198208
}
199209

200-
.group--header,
201-
.group--footer {
202-
padding: {
203-
top: 10px;
204-
right: 5px;
205-
bottom: 10px;
206-
left: 10px;
210+
.group--drag-handler {
211+
margin-right: 8px;
212+
}
213+
.group--conjunctions {
214+
.group--drag-handler {
215+
margin-left: 10px;
207216
}
208217
}
209218

@@ -240,8 +249,49 @@ ul.ant-select-selection__rendered {
240249
}
241250

242251

243-
.group--drag-handler {
244-
margin-left: 8px;
252+
/******************************************************************************/
253+
/** RULE_GROUP *********************************************************************/
254+
/******************************************************************************/
255+
256+
.rule_group {
257+
display: flex;
258+
padding-left: 10px;
259+
260+
.group--drag-handler {
261+
align-self: center;
262+
}
263+
.group--field {
264+
align-self: center;
265+
}
266+
.group--actions {
267+
align-self: center;
268+
flex: 0;
269+
}
270+
271+
.rule_group--children {
272+
flex: 1;
273+
274+
margin-top: 5px;
275+
margin-bottom: 5px;
276+
.group-or-rule-container {
277+
margin-bottom: 5px;
278+
margin-top: 5px;
279+
padding-right: 5px;
280+
}
281+
282+
padding-left: 18px;
283+
&.one--child {
284+
padding-left: 10px;
285+
}
286+
287+
& > .group-or-rule-container > .group-or-rule {
288+
&::before, &::after {
289+
left: -10px;
290+
width: 10px;
291+
height: calc(50% + 8px);
292+
}
293+
}
294+
}
245295
}
246296

247297
/******************************************************************************/
@@ -267,7 +317,7 @@ ul.ant-select-selection__rendered {
267317
margin-right: 8px;
268318
}
269319

270-
.rule--field, .rule--operator, .rule--value, .rule--operator-options, .rule--widget,
320+
.rule--field, .group--field, .rule--operator, .rule--value, .rule--operator-options, .rule--widget,
271321
.widget--widget, .widget--valuesrc, .widget--sep, .operator--options--sep,
272322
.rule--before-widget, .rule--after-widget {
273323
display: inline-block;
@@ -289,7 +339,7 @@ div.tooltip-inner {
289339
max-width: 500px;
290340
}
291341

292-
.rule--field, .rule--operator, .widget--widget {
342+
.rule--field, .group--field, .rule--operator, .widget--widget {
293343
label {
294344
display: block;
295345
font-weight: bold;
@@ -391,7 +441,9 @@ div.tooltip-inner {
391441
transition: opacity 0.2s;
392442
}
393443
.group--header:hover .group--header,
394-
.group--header:not(:hover) {
444+
.group--header:not(:hover),
445+
.rule_group:hover .rule_group,
446+
.rule_group:not(:hover) {
395447
#{$what} {
396448
opacity: 0;
397449
}
@@ -403,7 +455,9 @@ div.tooltip-inner {
403455
transition: padding 0.2s;
404456
}
405457
.group--header:hover .group--header,
406-
.group--header:not(:hover) {
458+
.group--header:not(:hover),
459+
.rule_group:hover .rule_group,
460+
.rule_group:not(:hover) {
407461
#{$inactive} {
408462
width: 0;
409463
padding: 0;
@@ -457,3 +511,37 @@ $rule_actions: ".widget--valuesrc", ".rule--drag-handler", ".rule--header";
457511
@include force_not_display($inactive_conjs);
458512
}
459513
}
514+
515+
516+
517+
/******************************************************************************/
518+
/** Vertical padding ****************************************************************/
519+
/******************************************************************************/
520+
521+
522+
.group--header,
523+
.group--footer {
524+
padding: {
525+
left: 10px;
526+
right: 5px;
527+
}
528+
margin: {
529+
top: 10px;
530+
bottom: 10px;
531+
}
532+
}
533+
.group-or-rule-container {
534+
margin-top: 10px;
535+
margin-bottom: 10px;
536+
padding-right: 10px;
537+
&:first-child {
538+
margin-top: 0px !important;
539+
}
540+
&:last-child {
541+
margin-bottom: 0px !important;
542+
}
543+
}
544+
.group--children {
545+
margin-top: 10px;
546+
margin-bottom: 10px;
547+
}

examples/demo/config.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,25 @@ const fields: Fields = {
223223
}
224224
}
225225
},
226+
results: {
227+
label: 'Results',
228+
type: '!group',
229+
subfields: {
230+
product: {
231+
type: 'select',
232+
listValues: ['abc', 'def', 'xyz'],
233+
valueSources: ['value'],
234+
},
235+
score: {
236+
type: 'number',
237+
fieldSettings: {
238+
min: 0,
239+
max: 100
240+
},
241+
valueSources: ['value'],
242+
}
243+
}
244+
},
226245
prox1: {
227246
label: 'prox',
228247
tooltip: 'Proximity search',

examples/demo/init_value.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,47 @@ export default
5858
"number"
5959
]
6060
}
61+
},
62+
"aaab8999-cdef-4012-b456-71702cd50090": {
63+
"type": "rule_group",
64+
"properties": {
65+
"conjunction": "AND",
66+
"field": "results"
67+
},
68+
"children1": {
69+
"99b8a8a8-89ab-4cde-b012-31702cd5078b": {
70+
"type": "rule",
71+
"properties": {
72+
"field": "results.product",
73+
"operator": "select_equals",
74+
"value": [
75+
"abc"
76+
],
77+
"valueSrc": [
78+
"value"
79+
],
80+
"valueType": [
81+
"select"
82+
]
83+
}
84+
},
85+
"88b9bb89-4567-489a-bcde-f1702cd53266": {
86+
"type": "rule",
87+
"properties": {
88+
"field": "results.score",
89+
"operator": "greater",
90+
"value": [
91+
8
92+
],
93+
"valueSrc": [
94+
"value"
95+
],
96+
"valueType": [
97+
"number"
98+
]
99+
}
100+
}
101+
}
61102
}
62103
},
63104
"properties": {

0 commit comments

Comments
 (0)