@stoker-platform/web-app 0.5.191 → 0.5.193
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 +12 -0
- package/package.json +1 -1
- package/src/DashboardReminder.tsx +47 -12
- package/src/Form.tsx +10 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @stoker-platform/web-app
|
|
2
2
|
|
|
3
|
+
## 0.5.193
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- feat: improve Dashboard reminder sorting
|
|
8
|
+
|
|
9
|
+
## 0.5.192
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- feat: remove image field images from image carousel
|
|
14
|
+
|
|
3
15
|
## 0.5.191
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -17,6 +17,7 @@ import { Card, CardContent } from "./components/ui/card"
|
|
|
17
17
|
import { useConnection } from "./providers/ConnectionProvider"
|
|
18
18
|
import { getField, getFieldCustomization, isRelationField, tryFunction } from "@stoker-platform/utils"
|
|
19
19
|
import { getFormattedFieldValue } from "./utils/getFormattedFieldValue"
|
|
20
|
+
import { getSortingValue } from "./utils/getSortingValue"
|
|
20
21
|
|
|
21
22
|
interface DashboardReminderProps {
|
|
22
23
|
reminder: Reminder
|
|
@@ -198,26 +199,60 @@ export const DashboardReminder = ({ reminder, title, collection }: DashboardRemi
|
|
|
198
199
|
</TableRow>
|
|
199
200
|
) : (
|
|
200
201
|
results
|
|
201
|
-
.slice(page * pages, (page + 1) * pages)
|
|
202
202
|
.sort((a, b) => {
|
|
203
203
|
if (!sorting) return 0
|
|
204
204
|
const sortingField = getField(fields, sorting.field)
|
|
205
|
-
const
|
|
206
|
-
|
|
205
|
+
const valueA = getSortingValue(
|
|
206
|
+
collectionSchema,
|
|
207
207
|
customization,
|
|
208
|
+
sorting.field,
|
|
209
|
+
a,
|
|
208
210
|
)
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
211
|
+
const valueB = getSortingValue(
|
|
212
|
+
collectionSchema,
|
|
213
|
+
customization,
|
|
214
|
+
sorting.field,
|
|
215
|
+
b,
|
|
216
|
+
)
|
|
217
|
+
let result: number
|
|
218
|
+
if (sortingField.type === "String") {
|
|
219
|
+
const rawA = valueA?.toString().toLowerCase() ?? ""
|
|
220
|
+
const rawB = valueB?.toString().toLowerCase() ?? ""
|
|
221
|
+
result = rawA > rawB ? 1 : rawA < rawB ? -1 : 0
|
|
222
|
+
} else if (isRelationField(sortingField)) {
|
|
223
|
+
const titleField = sortingField.titleField
|
|
224
|
+
let rawA: string
|
|
225
|
+
let rawB: string
|
|
226
|
+
if (titleField) {
|
|
227
|
+
const recordA = Object.values(a[sortingField.name] ?? {})[0] as
|
|
228
|
+
| StokerRecord
|
|
229
|
+
| undefined
|
|
230
|
+
const recordB = Object.values(b[sortingField.name] ?? {})[0] as
|
|
231
|
+
| StokerRecord
|
|
232
|
+
| undefined
|
|
233
|
+
// eslint-disable-next-line security/detect-object-injection
|
|
234
|
+
rawA = recordA?.[titleField]?.toString().toLowerCase() ?? ""
|
|
235
|
+
// eslint-disable-next-line security/detect-object-injection
|
|
236
|
+
rawB = recordB?.[titleField]?.toString().toLowerCase() ?? ""
|
|
237
|
+
} else {
|
|
238
|
+
rawA = (
|
|
239
|
+
Object.keys(a[sortingField.name] ?? {})[0] ?? ""
|
|
240
|
+
).toLowerCase()
|
|
241
|
+
rawB = (
|
|
242
|
+
Object.keys(b[sortingField.name] ?? {})[0] ?? ""
|
|
243
|
+
).toLowerCase()
|
|
244
|
+
}
|
|
245
|
+
result = rawA > rawB ? 1 : rawA < rawB ? -1 : 0
|
|
246
|
+
} else if (sortingField.type === "Timestamp") {
|
|
247
|
+
const rawA = Number(valueA?.valueOf() || 0)
|
|
248
|
+
const rawB = Number(valueB?.valueOf() || 0)
|
|
249
|
+
result = rawA > rawB ? 1 : rawA < rawB ? -1 : 0
|
|
217
250
|
} else {
|
|
218
|
-
|
|
251
|
+
result = valueA > valueB ? 1 : valueA < valueB ? -1 : 0
|
|
219
252
|
}
|
|
253
|
+
return sorting.direction === "asc" ? result : -result
|
|
220
254
|
})
|
|
255
|
+
.slice(page * pages, (page + 1) * pages)
|
|
221
256
|
.map((result: StokerRecord) => (
|
|
222
257
|
<TableRow
|
|
223
258
|
key={result.id}
|
package/src/Form.tsx
CHANGED
|
@@ -3713,6 +3713,15 @@ function RecordForm({
|
|
|
3713
3713
|
useEffect(() => {
|
|
3714
3714
|
const loadImages = async () => {
|
|
3715
3715
|
if (!formImagesEnabled || operation !== "update" || !record || isOffline) return
|
|
3716
|
+
const imageFieldUrls = fields
|
|
3717
|
+
.filter((field) => {
|
|
3718
|
+
if (field.type !== "String") return false
|
|
3719
|
+
const fieldCustomization = getFieldCustomization(field, customization)
|
|
3720
|
+
return tryFunction(fieldCustomization.admin?.image)
|
|
3721
|
+
})
|
|
3722
|
+
.map((field) => {
|
|
3723
|
+
return record?.[field.name]
|
|
3724
|
+
})
|
|
3716
3725
|
try {
|
|
3717
3726
|
const items = await getFiles("", record)
|
|
3718
3727
|
const imageItems = items.filter((item) => {
|
|
@@ -3724,7 +3733,7 @@ function RecordForm({
|
|
|
3724
3733
|
return url
|
|
3725
3734
|
}),
|
|
3726
3735
|
)
|
|
3727
|
-
setCarouselImages(urls)
|
|
3736
|
+
setCarouselImages(urls.filter((url) => !imageFieldUrls.includes(url)))
|
|
3728
3737
|
} finally {
|
|
3729
3738
|
setCarouselLoading(false)
|
|
3730
3739
|
}
|