@visns-studio/visns-components 5.15.23 → 5.15.24
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/package.json
CHANGED
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"react-dom": "^17.0.0 || ^18.0.0"
|
|
95
95
|
},
|
|
96
96
|
"name": "@visns-studio/visns-components",
|
|
97
|
-
"version": "5.15.
|
|
97
|
+
"version": "5.15.24",
|
|
98
98
|
"description": "Various packages to assist in the development of our Custom Applications.",
|
|
99
99
|
"main": "src/index.js",
|
|
100
100
|
"files": [
|
package/src/components/Fetch.jsx
CHANGED
|
@@ -52,12 +52,15 @@ const generateCacheKey = (url, method, formData) => {
|
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
// Helper to determine if request should be cached
|
|
55
|
-
const shouldCache = (method, url) => {
|
|
55
|
+
const shouldCache = (method, url, cacheOption = true) => {
|
|
56
56
|
const normalizedMethod = method.toUpperCase();
|
|
57
|
-
|
|
57
|
+
|
|
58
|
+
// If caching is explicitly disabled via option, return false
|
|
59
|
+
if (cacheOption === false) return false;
|
|
60
|
+
|
|
58
61
|
// Don't cache GET requests
|
|
59
62
|
if (normalizedMethod === 'GET') return false;
|
|
60
|
-
|
|
63
|
+
|
|
61
64
|
// Cache specific safe POST endpoints that return reference data
|
|
62
65
|
const cacheableEndpoints = [
|
|
63
66
|
'/dropdown', // Dropdown data (industries, facilities, etc.)
|
|
@@ -69,7 +72,7 @@ const shouldCache = (method, url) => {
|
|
|
69
72
|
'/getWharfUsage',
|
|
70
73
|
'/getFloatingWharfUsage',
|
|
71
74
|
];
|
|
72
|
-
|
|
75
|
+
|
|
73
76
|
return cacheableEndpoints.some(endpoint => url.includes(endpoint));
|
|
74
77
|
};
|
|
75
78
|
|
|
@@ -292,11 +295,14 @@ const CustomFetch = (
|
|
|
292
295
|
method,
|
|
293
296
|
formData,
|
|
294
297
|
successCallback = null,
|
|
295
|
-
errorCallback = null
|
|
298
|
+
errorCallback = null,
|
|
299
|
+
options = {}
|
|
296
300
|
) => {
|
|
297
301
|
const queryClient = getQueryClient();
|
|
298
302
|
const cacheKey = generateCacheKey(url, method, formData);
|
|
299
|
-
|
|
303
|
+
// Default cache to true, allow override via options.cache
|
|
304
|
+
const cacheEnabled = options.cache !== undefined ? options.cache : true;
|
|
305
|
+
const useCache = shouldCache(method, url, cacheEnabled);
|
|
300
306
|
|
|
301
307
|
if (useCache) {
|
|
302
308
|
// Use TanStack Query for cacheable requests
|
|
@@ -645,10 +645,16 @@ function GenericDashboard({ setting, userProfile, dynamicDashboard = false }) {
|
|
|
645
645
|
...widgetFilters,
|
|
646
646
|
};
|
|
647
647
|
|
|
648
|
+
// Check for cache option in widget.api (default: true)
|
|
649
|
+
const cacheOption = widget.api.cache !== undefined ? widget.api.cache : true;
|
|
650
|
+
|
|
648
651
|
return CustomFetch(
|
|
649
652
|
widget.api.url,
|
|
650
653
|
widget.api.method,
|
|
651
|
-
requestParams
|
|
654
|
+
requestParams,
|
|
655
|
+
null,
|
|
656
|
+
null,
|
|
657
|
+
{ cache: cacheOption }
|
|
652
658
|
);
|
|
653
659
|
}
|
|
654
660
|
return null;
|
|
@@ -1595,6 +1595,10 @@ function GenericFormBuilder({ setting, urlParam, userProfile }) {
|
|
|
1595
1595
|
optionKey
|
|
1596
1596
|
].label =
|
|
1597
1597
|
e.target.value;
|
|
1598
|
+
newOptions[
|
|
1599
|
+
optionKey
|
|
1600
|
+
].id =
|
|
1601
|
+
`${slugify(e.target.value)}-`;
|
|
1598
1602
|
setDataField(
|
|
1599
1603
|
(
|
|
1600
1604
|
items
|
|
@@ -1732,6 +1736,10 @@ function GenericFormBuilder({ setting, urlParam, userProfile }) {
|
|
|
1732
1736
|
optionKey
|
|
1733
1737
|
].label =
|
|
1734
1738
|
e.target.value;
|
|
1739
|
+
newOptions[
|
|
1740
|
+
optionKey
|
|
1741
|
+
].id =
|
|
1742
|
+
`${slugify(e.target.value)}-`;
|
|
1735
1743
|
setDataField(
|
|
1736
1744
|
(
|
|
1737
1745
|
items
|
|
@@ -2093,6 +2101,10 @@ function GenericFormBuilder({ setting, urlParam, userProfile }) {
|
|
|
2093
2101
|
rowKey
|
|
2094
2102
|
].label =
|
|
2095
2103
|
e.target.value;
|
|
2104
|
+
newRows[
|
|
2105
|
+
rowKey
|
|
2106
|
+
].id =
|
|
2107
|
+
`${slugify(e.target.value)}-`;
|
|
2096
2108
|
setDataField(
|
|
2097
2109
|
(
|
|
2098
2110
|
items
|