@stoker-platform/web-app 0.5.43 → 0.5.45
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/Calendar.tsx +48 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @stoker-platform/web-app
|
|
2
2
|
|
|
3
|
+
## 0.5.45
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- feat: add record filter to calendar
|
|
8
|
+
- @stoker-platform/node-client@0.5.29
|
|
9
|
+
- @stoker-platform/utils@0.5.23
|
|
10
|
+
- @stoker-platform/web-client@0.5.25
|
|
11
|
+
|
|
12
|
+
## 0.5.44
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- feat: add additionalFields option to calendar
|
|
17
|
+
- @stoker-platform/node-client@0.5.28
|
|
18
|
+
- @stoker-platform/utils@0.5.22
|
|
19
|
+
- @stoker-platform/web-client@0.5.24
|
|
20
|
+
|
|
3
21
|
## 0.5.43
|
|
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.45",
|
|
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.29",
|
|
55
|
+
"@stoker-platform/utils": "0.5.23",
|
|
56
|
+
"@stoker-platform/web-client": "0.5.25",
|
|
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/Calendar.tsx
CHANGED
|
@@ -28,7 +28,14 @@ import { ScrollArea } from "./components/ui/scroll-area"
|
|
|
28
28
|
import { useOptimistic } from "./providers/OptimisticProvider"
|
|
29
29
|
import { isServerUpdate } from "./utils/isServerWrite"
|
|
30
30
|
import { isOfflineDisabled as isOfflineDisabledSync } from "./utils/isOfflineDisabled"
|
|
31
|
-
import {
|
|
31
|
+
import {
|
|
32
|
+
canUpdateField,
|
|
33
|
+
getField,
|
|
34
|
+
getFieldCustomization,
|
|
35
|
+
getSystemFieldsSchema,
|
|
36
|
+
isRelationField,
|
|
37
|
+
tryFunction,
|
|
38
|
+
} from "@stoker-platform/utils"
|
|
32
39
|
import cloneDeep from "lodash/cloneDeep.js"
|
|
33
40
|
import { useGlobalLoading } from "./providers/LoadingProvider"
|
|
34
41
|
import { useToast } from "./hooks/use-toast"
|
|
@@ -622,8 +629,12 @@ export function Calendar({
|
|
|
622
629
|
updatedList.push(optimisticRecord)
|
|
623
630
|
}
|
|
624
631
|
})
|
|
625
|
-
|
|
626
|
-
.filter(
|
|
632
|
+
const mainEvents = updatedList
|
|
633
|
+
.filter(
|
|
634
|
+
(record) =>
|
|
635
|
+
record[calendarConfig.startField] &&
|
|
636
|
+
(!calendarConfig.filterRecords || calendarConfig.filterRecords(record)),
|
|
637
|
+
)
|
|
627
638
|
.map((record) => {
|
|
628
639
|
const isPendingServer = isGlobalLoading.get(record.id)?.server
|
|
629
640
|
|
|
@@ -663,6 +674,39 @@ export function Calendar({
|
|
|
663
674
|
}
|
|
664
675
|
return event
|
|
665
676
|
})
|
|
677
|
+
|
|
678
|
+
const additionalEvents: EventInput[] = []
|
|
679
|
+
if (calendarConfig?.additionalFields) {
|
|
680
|
+
calendarConfig.additionalFields.forEach((additionalField) => {
|
|
681
|
+
updatedList
|
|
682
|
+
// eslint-disable-next-line security/detect-object-injection
|
|
683
|
+
.filter(
|
|
684
|
+
(record) =>
|
|
685
|
+
record[additionalField] &&
|
|
686
|
+
(!calendarConfig.filterRecords || calendarConfig.filterRecords(record)),
|
|
687
|
+
)
|
|
688
|
+
.forEach((record) => {
|
|
689
|
+
const additionalFieldSchema = getField(fields, additionalField)
|
|
690
|
+
const additionalFieldCustomization = getFieldCustomization(additionalFieldSchema, customization)
|
|
691
|
+
const label = tryFunction(additionalFieldCustomization.admin?.label) || additionalField
|
|
692
|
+
const title =
|
|
693
|
+
// eslint-disable-next-line security/detect-object-injection
|
|
694
|
+
tryFunction(calendarConfig.eventTitle, [record]) || record[recordTitleField] || record.id
|
|
695
|
+
|
|
696
|
+
const event: EventInput = {
|
|
697
|
+
id: `${record.id}-${additionalField}`,
|
|
698
|
+
title: `${label}- ${title}`,
|
|
699
|
+
// eslint-disable-next-line security/detect-object-injection
|
|
700
|
+
start: record[additionalField].toDate(),
|
|
701
|
+
editable: false,
|
|
702
|
+
allDay: true,
|
|
703
|
+
color: "#6b7280",
|
|
704
|
+
}
|
|
705
|
+
additionalEvents.push(event)
|
|
706
|
+
})
|
|
707
|
+
})
|
|
708
|
+
}
|
|
709
|
+
return mainEvents.concat(additionalEvents)
|
|
666
710
|
}, [
|
|
667
711
|
calendarConfig,
|
|
668
712
|
list,
|
|
@@ -956,7 +1000,7 @@ export function Calendar({
|
|
|
956
1000
|
selectable: canAddRecords && !isCreateDisabled && !!calendarConfig?.endField,
|
|
957
1001
|
droppable: hasStartUpdateAccess,
|
|
958
1002
|
eventClick(info: EventClickArg) {
|
|
959
|
-
const record = list?.find((record) => record.id === info.event.id) as StokerRecord
|
|
1003
|
+
const record = list?.find((record) => record.id === info.event.id.split("-")[0]) as StokerRecord
|
|
960
1004
|
goToRecord(collection, record)
|
|
961
1005
|
},
|
|
962
1006
|
eventDrop(info: EventDropArg) {
|