@stoker-platform/web-app 0.5.59 → 0.5.61

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 CHANGED
@@ -1,5 +1,25 @@
1
1
  # @stoker-platform/web-app
2
2
 
3
+ ## 0.5.61
4
+
5
+ ### Patch Changes
6
+
7
+ - feat: add ID to single relation nodes
8
+ - Updated dependencies
9
+ - @stoker-platform/node-client@0.5.40
10
+ - @stoker-platform/utils@0.5.34
11
+ - @stoker-platform/web-client@0.5.38
12
+
13
+ ## 0.5.60
14
+
15
+ ### Patch Changes
16
+
17
+ - feat: add relation list loadAll option
18
+ - Updated dependencies
19
+ - @stoker-platform/web-client@0.5.37
20
+ - @stoker-platform/node-client@0.5.39
21
+ - @stoker-platform/utils@0.5.33
22
+
3
23
  ## 0.5.59
4
24
 
5
25
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoker-platform/web-app",
3
- "version": "0.5.59",
3
+ "version": "0.5.61",
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.47.0",
54
- "@stoker-platform/node-client": "0.5.38",
55
- "@stoker-platform/utils": "0.5.32",
56
- "@stoker-platform/web-client": "0.5.36",
54
+ "@stoker-platform/node-client": "0.5.40",
55
+ "@stoker-platform/utils": "0.5.34",
56
+ "@stoker-platform/web-client": "0.5.38",
57
57
  "@tanstack/react-table": "^8.21.3",
58
58
  "@types/react": "18.3.13",
59
59
  "@types/react-dom": "18.3.1",
@@ -36,6 +36,7 @@ import {
36
36
  subscribeMany,
37
37
  SubscribeManyOptions,
38
38
  updateRecord,
39
+ getPreloadListeners,
39
40
  } from "@stoker-platform/web-client"
40
41
  import { createElement, useCallback, useEffect, useMemo, useRef, useState } from "react"
41
42
  import { useLocation, useNavigate } from "react-router"
@@ -453,7 +454,7 @@ function Collection({
453
454
  const startingTab = tabRef.current
454
455
  key ||= "default"
455
456
 
456
- if (!isPreloadCacheEnabled) {
457
+ if (!isPreloadCacheEnabled || relationList?.loadAll) {
457
458
  setIsRouteLoading("+", location.pathname)
458
459
  }
459
460
 
@@ -581,8 +582,8 @@ function Collection({
581
582
  if (!query.infinite || firstLoad) {
582
583
  setCursor((prev) => ({ ...prev, [key]: newCursor }))
583
584
  }
584
- if (!isPreloadCacheEnabled) {
585
- loadedKeys.current.add(key)
585
+ if (!isPreloadCacheEnabled || relationList?.loadAll) {
586
+ if (!isPreloadCacheEnabled) loadedKeys.current.add(key)
586
587
  if (loadedKeys.current.size === keysLength.current) {
587
588
  setIsRouteLoading("-", location.pathname)
588
589
  }
@@ -627,7 +628,7 @@ function Collection({
627
628
  },
628
629
  (error) => {
629
630
  console.error(error)
630
- if (!isPreloadCacheEnabled) {
631
+ if (!isPreloadCacheEnabled || relationList?.loadAll) {
631
632
  setIsRouteLoading("-", location.pathname)
632
633
  }
633
634
  resolve()
@@ -637,6 +638,15 @@ function Collection({
637
638
  },
638
639
  {
639
640
  ...currentQuery.options,
641
+ tempCache:
642
+ isPreloadCacheEnabled && relationList?.loadAll
643
+ ? {
644
+ label: `${labels.collection}-${relationList?.field}`,
645
+ constraints: [
646
+ [`${relationList?.field}_Single.id`, "==", relationParent?.id],
647
+ ],
648
+ }
649
+ : undefined,
640
650
  } as SubscribeManyOptions,
641
651
  )
642
652
  const { unsubscribe: newUnsubscribe, count: newCount, pages: newPages } = result
@@ -645,7 +655,7 @@ function Collection({
645
655
  load()
646
656
  }
647
657
  } catch (error) {
648
- if (!isPreloadCacheEnabled) {
658
+ if (!isPreloadCacheEnabled || relationList?.loadAll) {
649
659
  setIsRouteLoading("-", location.pathname)
650
660
  }
651
661
  reject(error)
@@ -980,51 +990,49 @@ function Collection({
980
990
  if (currentField && (!rangeFilter || isPreloadCacheEnabled)) {
981
991
  let rangeValue = rangeState
982
992
  if (preloadCache?.range) {
983
- if (!rangeValue) {
984
- if (formList) {
993
+ if (formList || relationList?.loadAll) {
994
+ rangeValue = JSON.stringify({
995
+ from: getMinDate(),
996
+ to: getMaxDate(),
997
+ })
998
+ } else if (!rangeValue) {
999
+ const now = convertDateToTimezone(new Date())
1000
+ if (rangeSelectorState === "month") {
1001
+ rangeValue = JSON.stringify({
1002
+ from: now
1003
+ .startOf("month")
1004
+ .plus({ days: preloadCache.range.startOffsetDays || 0 })
1005
+ .plus({ hours: preloadCache.range.startOffsetHours })
1006
+ .toJSDate()
1007
+ .toISOString(),
1008
+ to: now
1009
+ .endOf("month")
1010
+ .plus({ days: preloadCache.range.endOffsetDays || 0 })
1011
+ .plus({ hours: preloadCache.range.endOffsetHours })
1012
+ .toJSDate()
1013
+ .toISOString(),
1014
+ })
1015
+ } else if (rangeSelectorState === "week") {
985
1016
  rangeValue = JSON.stringify({
986
- from: getMinDate(),
987
- to: getMaxDate(),
1017
+ from: now
1018
+ .startOf("week")
1019
+ .plus({ days: preloadCache.range.startOffsetDays || 0 })
1020
+ .plus({ hours: preloadCache.range.startOffsetHours })
1021
+ .toJSDate()
1022
+ .toISOString(),
1023
+ to: now
1024
+ .endOf("week")
1025
+ .plus({ days: preloadCache.range.endOffsetDays || 0 })
1026
+ .plus({ hours: preloadCache.range.endOffsetHours })
1027
+ .toJSDate()
1028
+ .toISOString(),
988
1029
  })
989
1030
  } else {
990
- const now = convertDateToTimezone(new Date())
991
- if (rangeSelectorState === "month") {
992
- rangeValue = JSON.stringify({
993
- from: now
994
- .startOf("month")
995
- .plus({ days: preloadCache.range.startOffsetDays || 0 })
996
- .plus({ hours: preloadCache.range.startOffsetHours })
997
- .toJSDate()
998
- .toISOString(),
999
- to: now
1000
- .endOf("month")
1001
- .plus({ days: preloadCache.range.endOffsetDays || 0 })
1002
- .plus({ hours: preloadCache.range.endOffsetHours })
1003
- .toJSDate()
1004
- .toISOString(),
1005
- })
1006
- } else if (rangeSelectorState === "week") {
1007
- rangeValue = JSON.stringify({
1008
- from: now
1009
- .startOf("week")
1010
- .plus({ days: preloadCache.range.startOffsetDays || 0 })
1011
- .plus({ hours: preloadCache.range.startOffsetHours })
1012
- .toJSDate()
1013
- .toISOString(),
1014
- to: now
1015
- .endOf("week")
1016
- .plus({ days: preloadCache.range.endOffsetDays || 0 })
1017
- .plus({ hours: preloadCache.range.endOffsetHours })
1018
- .toJSDate()
1019
- .toISOString(),
1020
- })
1021
- } else {
1022
- const preloadCacheRange = getRange(preloadCache.range, timezone)
1023
- rangeValue = JSON.stringify({
1024
- from: preloadCacheRange.start.toISOString(),
1025
- to: preloadCacheRange.end?.toISOString(),
1026
- })
1027
- }
1031
+ const preloadCacheRange = getRange(preloadCache.range, timezone)
1032
+ rangeValue = JSON.stringify({
1033
+ from: preloadCacheRange.start.toISOString(),
1034
+ to: preloadCacheRange.end?.toISOString(),
1035
+ })
1028
1036
  }
1029
1037
  }
1030
1038
  filtersClone.push({
@@ -1153,6 +1161,12 @@ function Collection({
1153
1161
  document.removeEventListener(`stoker:loading:${labels.collection}`, cacheLoading)
1154
1162
  document.removeEventListener(`stoker:loaded:${labels.collection}`, cacheLoaded)
1155
1163
  }
1164
+ if (relationList?.loadAll) {
1165
+ const unsubscribes = getPreloadListeners()[`${labels.collection}-${relationList.field}`]
1166
+ if (unsubscribes) {
1167
+ unsubscribes.forEach((unsubscribe) => unsubscribe())
1168
+ }
1169
+ }
1156
1170
  }
1157
1171
  }, [])
1158
1172
 
@@ -1675,24 +1689,26 @@ function Collection({
1675
1689
  </Card>
1676
1690
  {(connectionStatus === "online" || isPreloadCacheEnabled) && (
1677
1691
  <>
1678
- {tab !== "calendar" && (hasRangeFilter || currentField) && (
1679
- <div
1680
- className={cn(
1681
- "hidden",
1682
- relationList ? "xl:flex" : "lg:flex",
1683
- "2xl:hidden absolute",
1684
- relationList ? "left-[calc(50%+98px)]" : "left-1/2",
1685
- "transform -translate-x-1/2",
1686
- )}
1687
- >
1688
- <DateRangeSelector
1689
- collection={collection}
1690
- rangeSelector={rangeSelector}
1691
- setRangeSelector={setRangeSelector}
1692
- relationList={!!relationList}
1693
- />
1694
- </div>
1695
- )}
1692
+ {tab !== "calendar" &&
1693
+ !relationList?.loadAll &&
1694
+ (hasRangeFilter || currentField) && (
1695
+ <div
1696
+ className={cn(
1697
+ "hidden",
1698
+ relationList ? "xl:flex" : "lg:flex",
1699
+ "2xl:hidden absolute",
1700
+ relationList ? "left-[calc(50%+98px)]" : "left-1/2",
1701
+ "transform -translate-x-1/2",
1702
+ )}
1703
+ >
1704
+ <DateRangeSelector
1705
+ collection={collection}
1706
+ rangeSelector={rangeSelector}
1707
+ setRangeSelector={setRangeSelector}
1708
+ relationList={!!relationList}
1709
+ />
1710
+ </div>
1711
+ )}
1696
1712
  <div className="relative ml-auto flex-1 md:grow-0 print:hidden flex items-center">
1697
1713
  {tab !== "calendar" &&
1698
1714
  tab !== "map" &&
@@ -1746,7 +1762,7 @@ function Collection({
1746
1762
  )}
1747
1763
  </header>
1748
1764
  )}
1749
- {!(connectionStatus === "online" || isPreloadCacheEnabled) ? (
1765
+ {!(connectionStatus === "online" || (isPreloadCacheEnabled && !relationList?.loadAll)) ? (
1750
1766
  <div
1751
1767
  className={cn(
1752
1768
  "flex justify-center items-center p-5",
@@ -1782,8 +1798,8 @@ function Collection({
1782
1798
  )}
1783
1799
  >
1784
1800
  {formList && (
1785
- <Badge variant="outline" className="py-2 px-4 text-md">
1786
- {formList.label || formList.collection}
1801
+ <Badge variant="outline" className="py-2 px-4 text-md whitespace-nowrap">
1802
+ {formList.label || collectionTitle || formList.collection}
1787
1803
  </Badge>
1788
1804
  )}
1789
1805
  <div className="lg:h-9">
@@ -1811,22 +1827,25 @@ function Collection({
1811
1827
  </TabsList>
1812
1828
  )}
1813
1829
  </div>
1814
- {!formList && tab !== "calendar" && (hasRangeFilter || currentField) && (
1815
- <div
1816
- className={cn(
1817
- relationList
1818
- ? "xl:hidden 2xl:flex xl:absolute xl:left-[calc(50%+128px)] xl:transform xl:-translate-x-[calc(50%+98px)] xl:mt-0 mt-2"
1819
- : "lg:hidden 2xl:flex lg:absolute lg:left-1/2 lg:transform lg:-translate-x-1/2 lg:mt-0 mt-2",
1820
- )}
1821
- >
1822
- <DateRangeSelector
1823
- collection={collection}
1824
- rangeSelector={rangeSelector}
1825
- setRangeSelector={setRangeSelector}
1826
- relationList={!!relationList}
1827
- />
1828
- </div>
1829
- )}
1830
+ {!formList &&
1831
+ !relationList?.loadAll &&
1832
+ tab !== "calendar" &&
1833
+ (hasRangeFilter || currentField) && (
1834
+ <div
1835
+ className={cn(
1836
+ relationList
1837
+ ? "xl:hidden 2xl:flex xl:absolute xl:left-[calc(50%+128px)] xl:transform xl:-translate-x-[calc(50%+98px)] xl:mt-0 mt-2"
1838
+ : "lg:hidden 2xl:flex lg:absolute lg:left-1/2 lg:transform lg:-translate-x-1/2 lg:mt-0 mt-2",
1839
+ )}
1840
+ >
1841
+ <DateRangeSelector
1842
+ collection={collection}
1843
+ rangeSelector={rangeSelector}
1844
+ setRangeSelector={setRangeSelector}
1845
+ relationList={!!relationList}
1846
+ />
1847
+ </div>
1848
+ )}
1830
1849
  <div
1831
1850
  className={cn(
1832
1851
  "ml-auto flex items-center gap-2 justify-center w-full",
package/src/Form.tsx CHANGED
@@ -5247,18 +5247,6 @@ function RecordForm({
5247
5247
  field: formList.sortField || relationCollection.recordTitleField,
5248
5248
  direction: formList.sortDirection,
5249
5249
  }}
5250
- additionalConstraints={(() => {
5251
- if (record) {
5252
- return [
5253
- [
5254
- `${relationList.field}_Array`,
5255
- "array-contains",
5256
- record.id,
5257
- ],
5258
- ]
5259
- }
5260
- return []
5261
- })()}
5262
5250
  />
5263
5251
  </FiltersProvider>
5264
5252
  </div>
package/vite.config.ts CHANGED
@@ -17,7 +17,7 @@ export default defineConfig(async () => {
17
17
 
18
18
  return {
19
19
  plugins: [
20
- eslint(),
20
+ // eslint(),
21
21
  react(),
22
22
  VitePWA({
23
23
  registerType: "autoUpdate",