Skip to content

Commit 0d48eb7

Browse files
authored
Merge pull request #10 from findologic/FINDO-8454_2nd_combine_available_and_selected_filters
FINDO-8454_combine_available_and_selected_filters (Step 1: Refactor the current filter system)
2 parents 5693c4e + 1619b0b commit 0d48eb7

File tree

2 files changed

+101
-44
lines changed

2 files changed

+101
-44
lines changed

example/response.json

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,6 @@
1010
"field": "salesfrequency",
1111
"relevanceBased": true,
1212
"direction": "DESC"
13-
},
14-
"selectedFilters": {
15-
"cat": [
16-
{
17-
"value": "Gardening"
18-
}
19-
],
20-
"price": [
21-
{
22-
"min": 0.0,
23-
"max": 15
24-
}
25-
],
26-
"vendor": [
27-
{
28-
"value": "Blubbergurken International Inc."
29-
}
30-
]
3113
}
3214
},
3315
"result": {
@@ -80,7 +62,7 @@
8062
}
8163
}
8264
],
83-
"availableFilters": {
65+
"filters": {
8466
"main": [
8567
{
8668
"name": "cat",
@@ -96,6 +78,32 @@
9678
],
9779
"pinnedFilterValueCount": 6
9880
},
81+
{
82+
"type": "range-slider",
83+
"totalRange": {
84+
"min": 2.37,
85+
"max": 10106.09
86+
},
87+
"selectedRange": {
88+
"min": 2.37,
89+
"max": 10106.09
90+
},
91+
"stepSize": 0.1,
92+
"unit": "",
93+
"name": "price",
94+
"displayName": "Preis",
95+
"selectMode": "single",
96+
"values": [
97+
{
98+
"value": {
99+
"min": 2.37,
100+
"max": 30.75
101+
},
102+
"weight": 0.3948,
103+
"frequency": null
104+
}
105+
]
106+
},
99107
{
100108
"name": "vendor",
101109
"displayName": "Brand",
@@ -107,7 +115,8 @@
107115
"value": "Blubbergurken International Inc.",
108116
"weight": 0.8,
109117
"frequency": 5,
110-
"selected": true
118+
"selected": true,
119+
"frequencyType" : "additive"
111120
}
112121
]
113122
}
@@ -117,6 +126,7 @@
117126
"name": "color",
118127
"displayName": "Color",
119128
"type": "color",
129+
"selectMode": "multiple",
120130
"cssClass": "my-colors",
121131
"values": [
122132
{

resources/schema.json

Lines changed: 71 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"properties": {
1010
"value": {
1111
"description": "The filter value, as selected or suitable for visualization.",
12-
"type": "string",
12+
"type": ["string", "object"],
1313
"minLength": 1
1414
},
1515
"min": {
@@ -36,6 +36,14 @@
3636
"description": "The number of products matching a filter. Not supported in all configuration constellations.",
3737
"type": ["number", "null"]
3838
},
39+
"frequencyType": {
40+
"type": "string",
41+
"enum": [
42+
"additive",
43+
"absolute"
44+
],
45+
"description": "In case of a selected-filter, this property indicates whether the frequency is the number of additional products you'll get after selecting the filter (additive), or whether it's the total number of results you'll have after selecting the filter (absolute)."
46+
},
3947
"colorCode": {
4048
"description": "For color filters, the hexadecimal code corresponding to the color. The filter's value is the configured color name in such a case.",
4149
"type": "string",
@@ -52,7 +60,7 @@
5260
},
5361
"additionalProperties": false
5462
},
55-
"availableFilter": {
63+
"filter": {
5664
"description": "A selected value, with limited metadata as compared to available filters.",
5765
"type": "object",
5866
"properties": {
@@ -71,7 +79,7 @@
7179
"type": "string",
7280
"enum": [
7381
"select",
74-
"rangeSlider",
82+
"range-slider",
7583
"color",
7684
"label",
7785
"image"
@@ -83,7 +91,7 @@
8391
"single",
8492
"multiple"
8593
],
86-
"description": "Whether one or more filter values can be selected at the same time. Only applies to a subset of available filter types."
94+
"description": "Whether one or more filter values can be selected at the same time."
8795
},
8896
"cssClass": {
8997
"type": "string",
@@ -104,6 +112,58 @@
104112
"pinnedFilterValueCount": {
105113
"type": "integer",
106114
"description": "This is the number of filter values that should always be shown, and any more values than that should be hidden, e.g. by putting them in a dropdown."
115+
},
116+
"combinationOperation": {
117+
"type": "string",
118+
"enum": [
119+
"or",
120+
"and"
121+
],
122+
"description": "This indicates whether multiple-filters are applied in a OR- or AND-condition and do only apply after a minimum of two filters have been selected. The AND-condition shrinks the result (A and B have to match), while the OR-condition makes it grow (A or B have to match)."
123+
},
124+
"totalRange": {
125+
"description": "The usable range of a range slider.",
126+
"properties": {
127+
"min": {
128+
"type": "number",
129+
"description": "The minimum of the possible range."
130+
},
131+
"max": {
132+
"type": "number",
133+
"description": "The maximum of the possible range."
134+
}
135+
},
136+
"additionalProperties": false,
137+
"required": [
138+
"min",
139+
"max"
140+
]
141+
},
142+
"selectedRange": {
143+
"description": "The currently selected range of a range slider.",
144+
"properties": {
145+
"min": {
146+
"type": "number",
147+
"description": "The minimum of the selected range."
148+
},
149+
"max": {
150+
"type": "number",
151+
"description": "The maximum of the selected range."
152+
}
153+
},
154+
"additionalProperties": false,
155+
"required": [
156+
"min",
157+
"max"
158+
]
159+
},
160+
"stepSize": {
161+
"type": "number",
162+
"description": "The step size for range filters."
163+
},
164+
"unit": {
165+
"type": "string",
166+
"description": "The unit for range filters."
107167
}
108168
},
109169
"additionalProperties": false,
@@ -136,7 +196,7 @@
136196
"description": "Items per page."
137197
},
138198
"serviceId": {
139-
"description": "Mirrored from the required request parameter \"shopkey\"",
199+
"description": "Mirrored from the required request parameter \"shopkey\".",
140200
"type": "string",
141201
"pattern": "^[0-9A-F]{32}$"
142202
},
@@ -186,18 +246,6 @@
186246
"relevanceBased",
187247
"direction"
188248
]
189-
},
190-
"selectedFilters": {
191-
"description": "Filters that have previously been selected.",
192-
"type": "object",
193-
"patternProperties": {
194-
"^.*$": {
195-
"type": "array",
196-
"items": {
197-
"$ref": "#/definitions/filterMetadata"
198-
}
199-
}
200-
}
201249
}
202250
},
203251
"additionalProperties": false,
@@ -208,8 +256,7 @@
208256
"serviceId",
209257
"usergroup",
210258
"userId",
211-
"order",
212-
"selectedFilters"
259+
"order"
213260
]
214261
},
215262
"result": {
@@ -380,7 +427,7 @@
380427
"minLength": 0
381428
},
382429
"properties": {
383-
"description": "Non-searchable value exported as properties. Includes additional images, if applicable. The desired values have to be requested with the 'properties[]' parameter",
430+
"description": "Non-searchable value exported as properties. Includes additional images, if applicable. The desired values have to be requested with the 'properties[]' parameter.",
384431
"type": "object",
385432
"properties": {
386433
".*": {
@@ -434,22 +481,22 @@
434481
]
435482
}
436483
},
437-
"availableFilters": {
484+
"filters": {
438485
"description": "Filters available based on the query, and as configured in the filter configuration. Does not include inactive filters.",
439486
"type": "object",
440487
"properties": {
441488
"main": {
442489
"description": "Filters configured for primary visibility.",
443490
"type": "array",
444491
"items": {
445-
"$ref": "#/definitions/availableFilter"
492+
"$ref": "#/definitions/filter"
446493
}
447494
},
448495
"other": {
449496
"description": "Filters configured for secondary visibility. Should be initially hidden or collapsed.",
450497
"type": "array",
451498
"items": {
452-
"$ref": "#/definitions/availableFilter"
499+
"$ref": "#/definitions/filter"
453500
}
454501
}
455502
},
@@ -465,7 +512,7 @@
465512
"metadata",
466513
"variant",
467514
"items",
468-
"availableFilters"
515+
"filters"
469516
]
470517
}
471518
},

0 commit comments

Comments
 (0)