@abcagency/hc-ui-components 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +12 -15
- package/package.json +1 -1
- package/src/util/urlFilterUtil.js +29 -30
package/dist/index.js
CHANGED
|
@@ -1190,27 +1190,25 @@ var setStorageObject = function setStorageObject(key, item) {
|
|
|
1190
1190
|
};
|
|
1191
1191
|
|
|
1192
1192
|
var updateURLWithFilters = function updateURLWithFilters(filters, location, navigate, query) {
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1193
|
+
var searchParams = new URLSearchParams(location.search);
|
|
1194
|
+
Object.keys(Object.fromEntries(searchParams)).forEach(function (key) {
|
|
1195
|
+
if (!key.includes('.') && key !== 'query') {
|
|
1196
|
+
searchParams.set(key, searchParams.get(key));
|
|
1197
|
+
}
|
|
1198
|
+
});
|
|
1199
|
+
if (query) {
|
|
1200
|
+
searchParams.set('query', query);
|
|
1201
|
+
}
|
|
1201
1202
|
Object.keys(filters).forEach(function (category) {
|
|
1202
1203
|
Object.keys(filters[category]).forEach(function (filter) {
|
|
1204
|
+
var key = "".concat(category, ".").concat(filter);
|
|
1203
1205
|
if (filters[category][filter]) {
|
|
1204
|
-
var key = "".concat(category, ".").concat(filter);
|
|
1205
1206
|
searchParams.set(key, 'true');
|
|
1207
|
+
} else {
|
|
1208
|
+
searchParams["delete"](key);
|
|
1206
1209
|
}
|
|
1207
1210
|
});
|
|
1208
1211
|
});
|
|
1209
|
-
|
|
1210
|
-
// Add the query to search params if it exists
|
|
1211
|
-
if (query) {
|
|
1212
|
-
searchParams.set('query', query);
|
|
1213
|
-
}
|
|
1214
1212
|
navigate({
|
|
1215
1213
|
search: searchParams.toString()
|
|
1216
1214
|
}, {
|
|
@@ -1278,7 +1276,6 @@ var hasFiltersInURL = function hasFiltersInURL(location) {
|
|
|
1278
1276
|
});
|
|
1279
1277
|
};
|
|
1280
1278
|
var hasQueryInUrl = function hasQueryInUrl(location) {
|
|
1281
|
-
console.log(location);
|
|
1282
1279
|
if (!location || !location.search) return;
|
|
1283
1280
|
var queryParams = parseQueryParams(location.search);
|
|
1284
1281
|
if (!queryParams) return;
|
package/package.json
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
export const updateURLWithFilters = (filters, location, navigate, query) => {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
2
|
+
const searchParams = new URLSearchParams(location.search);
|
|
3
|
+
|
|
4
|
+
Object.keys(Object.fromEntries(searchParams)).forEach(key => {
|
|
5
|
+
if (!key.includes('.') && key !== 'query') {
|
|
6
|
+
searchParams.set(key, searchParams.get(key));
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
if (query) {
|
|
11
|
+
searchParams.set('query', query);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
Object.keys(filters).forEach(category => {
|
|
15
|
+
Object.keys(filters[category]).forEach(filter => {
|
|
16
|
+
const key = `${category}.${filter}`;
|
|
17
|
+
if (filters[category][filter]) {
|
|
18
|
+
searchParams.set(key, 'true');
|
|
19
|
+
} else {
|
|
20
|
+
searchParams.delete(key);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
navigate({
|
|
26
|
+
search: searchParams.toString(),
|
|
27
|
+
}, { replace: true });
|
|
28
|
+
|
|
29
|
+
notifyParentOfUrlChange();
|
|
30
|
+
};
|
|
31
31
|
|
|
32
32
|
function notifyParentOfUrlChange() {
|
|
33
33
|
setTimeout(() => {
|
|
@@ -83,7 +83,6 @@ export const hasFiltersInURL = location => {
|
|
|
83
83
|
};
|
|
84
84
|
|
|
85
85
|
export const hasQueryInUrl = location => {
|
|
86
|
-
console.log(location);
|
|
87
86
|
if (!location || !location.search) return;
|
|
88
87
|
const queryParams = parseQueryParams(location.search);
|
|
89
88
|
if (!queryParams) return;
|