@stoker-platform/web-app 0.5.148 → 0.5.150

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,17 @@
1
1
  # @stoker-platform/web-app
2
2
 
3
+ ## 0.5.150
4
+
5
+ ### Patch Changes
6
+
7
+ - fix: fix page number / count when search present
8
+
9
+ ## 0.5.149
10
+
11
+ ### Patch Changes
12
+
13
+ - fix: apply isMobile condition on initial retrieval
14
+
3
15
  ## 0.5.148
4
16
 
5
17
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoker-platform/web-app",
3
- "version": "0.5.148",
3
+ "version": "0.5.150",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "scripts": {
package/src/Filters.tsx CHANGED
@@ -311,10 +311,10 @@ export function Filters({ collection, excluded, relationList }: FiltersProps) {
311
311
  }).then((data) => {
312
312
  clearTimeout(pickerDebounceTimeout.current)
313
313
 
314
+ const numberOfResults = isCollectionPreloadCacheEnabled && isMobile ? 20 : 10
314
315
  if (isCollectionPreloadCacheEnabled && query) {
315
316
  const searchResults = localFullTextSearch(collectionSchema, query, data.records)
316
317
  const objectIds = searchResults.map((result) => result.id)
317
- const numberOfResults = isMobile ? 20 : 10
318
318
  setData((prev) => ({
319
319
  ...prev,
320
320
  [field]: data.records.filter((doc) => objectIds.includes(doc.id)).slice(0, numberOfResults),
@@ -322,7 +322,7 @@ export function Filters({ collection, excluded, relationList }: FiltersProps) {
322
322
  } else {
323
323
  setData((prev) => ({
324
324
  ...prev,
325
- [field]: data.records.slice(0, 10),
325
+ [field]: data.records.slice(0, numberOfResults),
326
326
  }))
327
327
  }
328
328
  setLoadingImmediate((prev) => ({
package/src/Form.tsx CHANGED
@@ -2021,13 +2021,13 @@ function RelationField({
2021
2021
  }).then((data) => {
2022
2022
  clearTimeout(pickerDebounceTimeout.current)
2023
2023
 
2024
+ const numberOfResults = isCollectionPreloadCacheEnabled && isMobile ? 20 : 10
2024
2025
  if (isCollectionPreloadCacheEnabled && query) {
2025
2026
  const searchResults = localFullTextSearch(relationCollection, query, data.records, (result) => {
2026
2027
  if (!fieldCustomization.admin?.filterResults) return true
2027
2028
  return !!fieldCustomization.admin?.filterResults?.(result, collection, record)
2028
2029
  })
2029
2030
  const objectIds = searchResults.map((result) => result.id)
2030
- const numberOfResults = isMobile ? 20 : 10
2031
2031
  orderData(data.records.filter((doc) => objectIds.includes(doc.id)).slice(0, numberOfResults)).then(
2032
2032
  (data) => {
2033
2033
  setData(data)
@@ -2045,7 +2045,7 @@ function RelationField({
2045
2045
  record,
2046
2046
  )
2047
2047
  })
2048
- .slice(0, 10),
2048
+ .slice(0, numberOfResults),
2049
2049
  ).then((data) => {
2050
2050
  setData(data)
2051
2051
  })
package/src/List.tsx CHANGED
@@ -812,6 +812,9 @@ export function List({
812
812
  const timer = setTimeout(() => {
813
813
  if (isInitialized && fullTextSearch && !isPreloadCacheEnabled && !isServerReadOnly) {
814
814
  backToStart()
815
+ } else if (isInitialized && (isPreloadCacheEnabled || isServerReadOnly)) {
816
+ setPageIndex(0)
817
+ setState(`collection-page-number-${labels.collection.toLowerCase()}`, "page", 1)
815
818
  }
816
819
  }, 750)
817
820
  return () => clearTimeout(timer)
@@ -950,13 +953,13 @@ export function List({
950
953
  }
951
954
  }
952
955
  } else if (isInitialized && (isPreloadCacheEnabled || isServerReadOnly)) {
953
- const newPageCount = Math.ceil(list.length / pageSize) || 1
956
+ const newPageCount = Math.ceil(searchList.length / pageSize) || 1
954
957
  if (newPageCount !== pageCount) {
955
958
  setPageCount(newPageCount)
956
959
  }
957
960
  }
958
961
  }
959
- }, [list])
962
+ }, [list, searchList])
960
963
 
961
964
  const nextPage = useCallback(() => {
962
965
  if (isLoading) return
@@ -139,13 +139,13 @@ export const PermissionPicker = ({
139
139
  }).then((data) => {
140
140
  clearTimeout(pickerDebounceTimeout.current)
141
141
 
142
+ const numberOfResults = isCollectionPreloadCacheEnabled && isMobile ? 20 : 10
142
143
  if (isCollectionPreloadCacheEnabled && query) {
143
144
  const searchResults = localFullTextSearch(collection, query, data.records)
144
145
  const objectIds = searchResults.map((result) => result.id)
145
- const numberOfResults = isMobile ? 20 : 10
146
146
  setData(data.records.filter((doc) => objectIds.includes(doc.id)).slice(0, numberOfResults))
147
147
  } else {
148
- setData(data.records.slice(0, 10))
148
+ setData(data.records.slice(0, numberOfResults))
149
149
  }
150
150
  setIsLoadingImmediate(false)
151
151
  setIsLoading(false)