@stoker-platform/web-app 0.5.29 → 0.5.31

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.31
4
+
5
+ ### Patch Changes
6
+
7
+ - fix: treat modified display value as Computed field type
8
+
9
+ ## 0.5.30
10
+
11
+ ### Patch Changes
12
+
13
+ - fix: wait for conditional fields to render
14
+
3
15
  ## 0.5.29
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.29",
3
+ "version": "0.5.31",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "scripts": {
package/src/Form.tsx CHANGED
@@ -301,7 +301,6 @@ const RecordFormField = (props: FieldProps) => {
301
301
  setCondition(!!condition)
302
302
 
303
303
  const [
304
- readOnly,
305
304
  label,
306
305
  description,
307
306
  descriptionCondition,
@@ -316,7 +315,6 @@ const RecordFormField = (props: FieldProps) => {
316
315
  isRadio,
317
316
  icon,
318
317
  ] = await Promise.all([
319
- tryPromise(admin?.readOnly, [operation, record]),
320
318
  tryFunction(admin?.label),
321
319
  tryFunction(admin?.description?.message, [record]),
322
320
  tryPromise(admin?.description?.condition, [record]),
@@ -362,6 +360,10 @@ const RecordFormField = (props: FieldProps) => {
362
360
  return
363
361
  }
364
362
  setCondition(true)
363
+ setTimeout(() => {
364
+ const readOnly = tryFunction(admin?.readOnly, [operation, form.getValues()])
365
+ setReadOnly(!!readOnly)
366
+ }, 0)
365
367
  }, [form.watch()])
366
368
 
367
369
  const hasUpdateAccess = useMemo(() => {
@@ -3453,19 +3455,21 @@ function RecordForm({
3453
3455
  }
3454
3456
  }
3455
3457
 
3456
- if (isInitialized && (operation === "create" || operation === "update") && customization.admin?.onChange) {
3457
- tryPromise(customization.admin.onChange, [
3458
- operation,
3459
- cloneDeep(formValues) as StokerRecord,
3460
- prevState as StokerRecord,
3461
- ]).then((updatedRecord: StokerRecord) => {
3462
- if (updatedRecord && !isEqual(updatedRecord, formValues)) {
3463
- Object.entries(updatedRecord).forEach(([key, value]) => {
3464
- form.setValue(key, value)
3465
- })
3466
- }
3467
- })
3468
- }
3458
+ setTimeout(() => {
3459
+ if (isInitialized && (operation === "create" || operation === "update") && customization.admin?.onChange) {
3460
+ tryPromise(customization.admin.onChange, [
3461
+ operation,
3462
+ cloneDeep(form.getValues()) as StokerRecord,
3463
+ prevState as StokerRecord,
3464
+ ]).then((updatedRecord: StokerRecord) => {
3465
+ if (updatedRecord && !isEqual(updatedRecord, formValues)) {
3466
+ Object.entries(updatedRecord).forEach(([key, value]) => {
3467
+ form.setValue(key, value)
3468
+ })
3469
+ }
3470
+ })
3471
+ }
3472
+ }, 0)
3469
3473
  }, [form.watch()])
3470
3474
 
3471
3475
  const recordLoaded = useRef(false)
@@ -67,7 +67,9 @@ export const getFormattedFieldValue = (
67
67
  }
68
68
 
69
69
  let value = record[field.name]
70
+ let modified = false
70
71
  if (fieldCustomization?.admin?.modifyDisplayValue) {
72
+ modified = true
71
73
  value = tryFunction(fieldCustomization.admin.modifyDisplayValue, [
72
74
  record,
73
75
  card ? "card" : form ? "form" : "list",
@@ -134,7 +136,23 @@ export const getFormattedFieldValue = (
134
136
  )
135
137
  }
136
138
 
137
- if (isRelationField(field)) {
139
+ if (modified) {
140
+ if (value === "tick") {
141
+ return (
142
+ <div className="w-full flex justify-start">
143
+ <Check />
144
+ </div>
145
+ )
146
+ } else if (value === "cross") {
147
+ return (
148
+ <div className="w-full flex justify-start">
149
+ <X />
150
+ </div>
151
+ )
152
+ } else {
153
+ return getStandardDisplay()
154
+ }
155
+ } else if (isRelationField(field)) {
138
156
  const titleField = field.titleField
139
157
  const relationCollection = schema.collections[field.collection]
140
158
  if (["OneToOne", "OneToMany"].includes(field.type)) {