@stoker-platform/web-app 0.5.31 → 0.5.33
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/CHANGELOG.md +18 -0
- package/package.json +4 -4
- package/src/Collection.tsx +34 -17
- package/src/List.tsx +6 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @stoker-platform/web-app
|
|
2
2
|
|
|
3
|
+
## 0.5.33
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- feat: add filter default value option
|
|
8
|
+
- @stoker-platform/node-client@0.5.21
|
|
9
|
+
- @stoker-platform/utils@0.5.15
|
|
10
|
+
- @stoker-platform/web-client@0.5.16
|
|
11
|
+
|
|
12
|
+
## 0.5.32
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- feat: add custom list metric
|
|
17
|
+
- @stoker-platform/node-client@0.5.20
|
|
18
|
+
- @stoker-platform/utils@0.5.14
|
|
19
|
+
- @stoker-platform/web-client@0.5.15
|
|
20
|
+
|
|
3
21
|
## 0.5.31
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stoker-platform/web-app",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.33",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"scripts": {
|
|
@@ -51,9 +51,9 @@
|
|
|
51
51
|
"@radix-ui/react-tooltip": "^1.2.8",
|
|
52
52
|
"@react-google-maps/api": "^2.20.8",
|
|
53
53
|
"@sentry/react": "^10.38.0",
|
|
54
|
-
"@stoker-platform/node-client": "0.5.
|
|
55
|
-
"@stoker-platform/utils": "0.5.
|
|
56
|
-
"@stoker-platform/web-client": "0.5.
|
|
54
|
+
"@stoker-platform/node-client": "0.5.21",
|
|
55
|
+
"@stoker-platform/utils": "0.5.15",
|
|
56
|
+
"@stoker-platform/web-client": "0.5.16",
|
|
57
57
|
"@tanstack/react-table": "^8.21.3",
|
|
58
58
|
"@types/react": "18.3.13",
|
|
59
59
|
"@types/react-dom": "18.3.1",
|
package/src/Collection.tsx
CHANGED
|
@@ -120,6 +120,8 @@ export interface Query {
|
|
|
120
120
|
}[]
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
+
const hasFirstPageLoaded: { [key: StokerCollection]: boolean } = {}
|
|
124
|
+
|
|
123
125
|
function Collection({
|
|
124
126
|
collection,
|
|
125
127
|
formList,
|
|
@@ -822,24 +824,38 @@ function Collection({
|
|
|
822
824
|
|
|
823
825
|
const filtersClone = cloneDeep(filters)
|
|
824
826
|
const filtersState = state[`collection-filters-${labels.collection.toLowerCase()}`]
|
|
825
|
-
if (!relationList
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
const filterValue = filterValues.find((value) => value.split("=")[0] === filter.field)
|
|
832
|
-
if (filterValue) {
|
|
833
|
-
const field = getField(fields, filter.field)
|
|
834
|
-
if (field.type === "Number") {
|
|
835
|
-
// eslint-disable-next-line security/detect-object-injection
|
|
836
|
-
filter.value = Number(filterValue.split("=")[1])
|
|
837
|
-
} else {
|
|
838
|
-
// eslint-disable-next-line security/detect-object-injection
|
|
839
|
-
filter.value = filterValue.split("=")[1]
|
|
827
|
+
if (!relationList) {
|
|
828
|
+
if (filtersState) {
|
|
829
|
+
const filterValues = filtersState.split(",")
|
|
830
|
+
filtersClone.forEach((filter: Filter) => {
|
|
831
|
+
if (filter.type === "status" || filter.type === "range") {
|
|
832
|
+
return
|
|
840
833
|
}
|
|
841
|
-
|
|
842
|
-
|
|
834
|
+
const filterValue = filterValues.find((value) => value.split("=")[0] === filter.field)
|
|
835
|
+
if (filterValue) {
|
|
836
|
+
const field = getField(fields, filter.field)
|
|
837
|
+
if (field.type === "Number") {
|
|
838
|
+
// eslint-disable-next-line security/detect-object-injection
|
|
839
|
+
filter.value = Number(filterValue.split("=")[1])
|
|
840
|
+
} else {
|
|
841
|
+
// eslint-disable-next-line security/detect-object-injection
|
|
842
|
+
filter.value = filterValue.split("=")[1]
|
|
843
|
+
}
|
|
844
|
+
} else if (
|
|
845
|
+
filter.type === "select" &&
|
|
846
|
+
!hasFirstPageLoaded[labels.collection] &&
|
|
847
|
+
filter.defaultValue
|
|
848
|
+
) {
|
|
849
|
+
filter.value = tryFunction(filter.defaultValue)
|
|
850
|
+
}
|
|
851
|
+
})
|
|
852
|
+
} else {
|
|
853
|
+
filtersClone.forEach((filter: Filter) => {
|
|
854
|
+
if (filter.type === "select" && !hasFirstPageLoaded[labels.collection] && filter.defaultValue) {
|
|
855
|
+
filter.value = tryFunction(filter.defaultValue)
|
|
856
|
+
}
|
|
857
|
+
})
|
|
858
|
+
}
|
|
843
859
|
}
|
|
844
860
|
|
|
845
861
|
if (statusField || softDelete) {
|
|
@@ -1022,6 +1038,7 @@ function Collection({
|
|
|
1022
1038
|
setOrder({ field: recordTitleField, direction: "asc" })
|
|
1023
1039
|
}
|
|
1024
1040
|
|
|
1041
|
+
hasFirstPageLoaded[labels.collection] = true
|
|
1025
1042
|
setIsInitialized(true)
|
|
1026
1043
|
}
|
|
1027
1044
|
|
package/src/List.tsx
CHANGED
|
@@ -1133,7 +1133,10 @@ export function List({
|
|
|
1133
1133
|
const values: Record<string, MetricValue> = {}
|
|
1134
1134
|
metrics?.forEach((metric: Metric | Chart, index: number) => {
|
|
1135
1135
|
if (permissions?.Role && (!metric.roles || metric.roles.includes(permissions?.Role))) {
|
|
1136
|
-
if (metric.type === "
|
|
1136
|
+
if (metric.type === "custom" && metric.formula) {
|
|
1137
|
+
// eslint-disable-next-line security/detect-object-injection
|
|
1138
|
+
values[index] = metric.formula(list).toString() || ""
|
|
1139
|
+
} else if (metric.type === "count") {
|
|
1137
1140
|
let value = (list?.length || 0).toString()
|
|
1138
1141
|
if (metric.prefix) {
|
|
1139
1142
|
value = `${metric.prefix}${value}`
|
|
@@ -1316,7 +1319,8 @@ export function List({
|
|
|
1316
1319
|
if (
|
|
1317
1320
|
metric.type === "sum" ||
|
|
1318
1321
|
metric.type === "average" ||
|
|
1319
|
-
metric.type === "count"
|
|
1322
|
+
metric.type === "count" ||
|
|
1323
|
+
metric.type === "custom"
|
|
1320
1324
|
) {
|
|
1321
1325
|
const metricTitle =
|
|
1322
1326
|
metric.title || `Total ${collectionTitle || labels.collection}`
|