@stoker-platform/web-app 0.5.88 → 0.5.90

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,19 @@
1
1
  # @stoker-platform/web-app
2
2
 
3
+ ## 0.5.90
4
+
5
+ ### Patch Changes
6
+
7
+ - fix: provide form values to filterValues
8
+ - fix: show title field in relation field
9
+ - feat: use list label for CSV column name
10
+
11
+ ## 0.5.89
12
+
13
+ ### Patch Changes
14
+
15
+ - feat: keep all list metrics when no chart present
16
+
3
17
  ## 0.5.88
4
18
 
5
19
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoker-platform/web-app",
3
- "version": "0.5.88",
3
+ "version": "0.5.90",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "scripts": {
package/src/Form.tsx CHANGED
@@ -578,7 +578,11 @@ function StringField({
578
578
  ?.filter(
579
579
  (option) =>
580
580
  !fieldCustomization.admin?.filterValues ||
581
- fieldCustomization.admin?.filterValues?.(option, collection, record),
581
+ fieldCustomization.admin?.filterValues?.(
582
+ option,
583
+ collection,
584
+ record || (form.getValues() as StokerRecord),
585
+ ),
582
586
  )
583
587
  .map((option) => (
584
588
  <div key={option} className="flex items-center space-x-2">
@@ -630,7 +634,11 @@ function StringField({
630
634
  ?.filter(
631
635
  (option) =>
632
636
  !fieldCustomization.admin?.filterValues ||
633
- fieldCustomization.admin?.filterValues?.(option, collection, record),
637
+ fieldCustomization.admin?.filterValues?.(
638
+ option,
639
+ collection,
640
+ record || (form.getValues() as StokerRecord),
641
+ ),
634
642
  )
635
643
  .map((option) => {
636
644
  return (
@@ -688,7 +696,11 @@ function StringField({
688
696
  ?.filter(
689
697
  (option) =>
690
698
  !fieldCustomization.admin?.filterValues ||
691
- fieldCustomization.admin?.filterValues?.(option, collection, record),
699
+ fieldCustomization.admin?.filterValues?.(
700
+ option,
701
+ collection,
702
+ record || (form.getValues() as StokerRecord),
703
+ ),
692
704
  )
693
705
  .map((option) => (
694
706
  <SelectItem key={option} value={option}>
@@ -1041,7 +1053,11 @@ function NumberField({
1041
1053
  ?.filter(
1042
1054
  (option) =>
1043
1055
  !fieldCustomization.admin?.filterValues ||
1044
- fieldCustomization.admin?.filterValues?.(option, collection, record),
1056
+ fieldCustomization.admin?.filterValues?.(
1057
+ option,
1058
+ collection,
1059
+ record || (form.getValues() as StokerRecord),
1060
+ ),
1045
1061
  )
1046
1062
  .map((option) => (
1047
1063
  <SelectItem key={option} value={option.toString()}>
@@ -1816,7 +1832,10 @@ function RelationField({
1816
1832
  if (fieldCustomization.admin?.modifyResultTitle) {
1817
1833
  setDisplay(fieldCustomization.admin.modifyResultTitle(relationRecord, collection, record))
1818
1834
  } else {
1819
- setDisplay(relationRecord[relationCollection.recordTitleField || "id"] || relationId)
1835
+ setDisplay(
1836
+ relationRecord[field.titleField || relationCollection.recordTitleField || "id"] ||
1837
+ relationId,
1838
+ )
1820
1839
  }
1821
1840
  } else {
1822
1841
  setDisplay(relationId)
package/src/List.tsx CHANGED
@@ -1304,6 +1304,19 @@ export function List({
1304
1304
  )
1305
1305
  }, [metrics])
1306
1306
 
1307
+ const hasChart = useMemo(() => {
1308
+ return (
1309
+ metrics &&
1310
+ metrics.filter((metric: Metric | Chart) => {
1311
+ return (
1312
+ metric.type === "area" &&
1313
+ permissions?.Role &&
1314
+ (!metric.roles || metric.roles.includes(permissions?.Role))
1315
+ )
1316
+ }).length > 0
1317
+ )
1318
+ }, [metrics])
1319
+
1307
1320
  return (
1308
1321
  <>
1309
1322
  {!formList && (
@@ -1325,7 +1338,7 @@ export function List({
1325
1338
  {metrics && hasMetrics && !relationList && (
1326
1339
  <div className="hidden lg:flex flex-row gap-4 mb-4 mt-4 max-w-[calc(100vw-96px)]">
1327
1340
  {metrics.map((metric: Metric | Chart, index: number) => {
1328
- const hideThirdMetric = index >= 2 ? "hidden xl:grid" : undefined
1341
+ const hideThirdMetric = index >= 2 && hasChart ? "hidden xl:grid" : undefined
1329
1342
  if (
1330
1343
  permissions?.Role &&
1331
1344
  (!metric.roles || metric.roles.includes(permissions?.Role))
@@ -38,7 +38,10 @@ export const prepareCSVData = (collection: CollectionSchema, data: any[]) => {
38
38
  if (field.name === softDelete?.timestampField) continue
39
39
  if (collection.auth && field.name === "User_ID") continue
40
40
  const fieldCustomization = getFieldCustomization(field, customization)
41
- const label = tryFunction(fieldCustomization.admin?.label) || field.name
41
+ const label =
42
+ tryFunction(fieldCustomization.admin?.listLabel) ||
43
+ tryFunction(fieldCustomization.admin?.label) ||
44
+ field.name
42
45
  const noExport = tryFunction(fieldCustomization.admin?.noExport) || false
43
46
  if (noExport) continue
44
47
  CSVData.headers.push({ label: escapeCSVField(label), key: field.name })