@stoker-platform/web-app 0.5.143 → 0.5.145

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.145
4
+
5
+ ### Patch Changes
6
+
7
+ - feat: allow bulk update of restricted fields
8
+
9
+ ## 0.5.144
10
+
11
+ ### Patch Changes
12
+
13
+ - feat: redirect to duplicated / converted record
14
+
3
15
  ## 0.5.143
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.143",
3
+ "version": "0.5.145",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "scripts": {
package/src/Form.tsx CHANGED
@@ -231,7 +231,7 @@ interface FormProps {
231
231
  isLoading?: React.RefObject<boolean>
232
232
  record?: StokerRecord
233
233
  draft?: boolean
234
- onSuccess?: () => void
234
+ onSuccess?: (record?: StokerRecord) => void
235
235
  onSaveRecord?: () => void
236
236
  rowSelection?: StokerRecord[]
237
237
  fromRelationList?: string
@@ -409,7 +409,7 @@ const RecordFormField = (props: FieldProps) => {
409
409
  if (operation === "update-many") {
410
410
  if ("unique" in field && field.unique) return null
411
411
  if (customization?.admin && "readOnly" in customization.admin) return null
412
- if ("restrictUpdate" in field) return null
412
+ if ("restrictUpdate" in field && !restrictUpdateAccess(field, permissions)) return null
413
413
 
414
414
  if (collection.auth && field.name === "Role") return null
415
415
  if (connectionStatus === "offline" && collection.auth) return null
@@ -2392,6 +2392,7 @@ function RecordForm({
2392
2392
  const { serverWriteOnly } = access
2393
2393
  const navigate = useNavigate()
2394
2394
  const params = useParams()
2395
+ const goToRecord = useGoToRecord()
2395
2396
  const { id } = params as { id: string }
2396
2397
  if (operation === "update" && !id) {
2397
2398
  throw new Error("ID param is required for update operation")
@@ -2476,6 +2477,9 @@ function RecordForm({
2476
2477
  const [draftData, setDraftData] = useState<any>(null)
2477
2478
  const [showDuplicateModal, setShowDuplicateModal] = useState(false)
2478
2479
  const [duplicateRecordData, setDuplicateRecordData] = useState<Partial<StokerRecord> | undefined>(undefined)
2480
+ const [pendingGoToRecord, setPendingGoToRecord] = useState<
2481
+ { collection: CollectionSchema; record: StokerRecord } | undefined
2482
+ >(undefined)
2479
2483
  const [convert, setConvert] = useState<Convert[] | undefined>(undefined)
2480
2484
  const [showConvertModal, setShowConvertModal] = useState(false)
2481
2485
  const [convertRecordData, setConvertRecordData] = useState<Partial<StokerRecord> | undefined>(undefined)
@@ -4136,7 +4140,7 @@ function RecordForm({
4136
4140
 
4137
4141
  const onValid = () => {
4138
4142
  if (!isServerReadOnly) {
4139
- if (onSuccess) onSuccess()
4143
+ if (onSuccess) onSuccess({ ...recordToSave, id: docId, Collection_Path: path } as StokerRecord)
4140
4144
  }
4141
4145
  }
4142
4146
 
@@ -4163,7 +4167,8 @@ function RecordForm({
4163
4167
 
4164
4168
  if (isServerReadOnly) {
4165
4169
  setIsAddingServer(false)
4166
- if (onSuccess) onSuccess()
4170
+ if (onSuccess)
4171
+ onSuccess({ ...recordToSave, id: docId, Collection_Path: path } as StokerRecord)
4167
4172
  }
4168
4173
  })
4169
4174
  .then(async () => {
@@ -4484,6 +4489,12 @@ function RecordForm({
4484
4489
  setFormResetKey((prev) => prev + 1)
4485
4490
  }, [form, prevState])
4486
4491
 
4492
+ useEffect(() => {
4493
+ if (!pendingGoToRecord || showDuplicateModal || showConvertModal) return
4494
+ goToRecord(pendingGoToRecord.collection, pendingGoToRecord.record)
4495
+ setPendingGoToRecord(undefined)
4496
+ }, [pendingGoToRecord, showDuplicateModal, showConvertModal])
4497
+
4487
4498
  const duplicateRecord = useCallback(async () => {
4488
4499
  if (!formValues) return
4489
4500
  const record = cloneDeep(originalRecord) as Partial<StokerRecord>
@@ -5520,10 +5531,11 @@ function RecordForm({
5520
5531
  operation="create"
5521
5532
  path={collectionPath || [labels.collection]}
5522
5533
  record={duplicateRecordData as StokerRecord}
5523
- onSuccess={() => {
5534
+ onSuccess={(record?: StokerRecord) => {
5524
5535
  setShowDuplicateModal(false)
5525
5536
  setDuplicateRecordData(undefined)
5526
5537
  setIsDuplicate(false)
5538
+ if (record?.id) setPendingGoToRecord({ collection, record })
5527
5539
  }}
5528
5540
  />
5529
5541
  </div>
@@ -5571,10 +5583,16 @@ function RecordForm({
5571
5583
  operation="create"
5572
5584
  path={[convertTargetCollection.labels.collection]}
5573
5585
  record={convertRecordData as StokerRecord}
5574
- onSuccess={() => {
5586
+ onSuccess={(record?: StokerRecord) => {
5587
+ const targetCollection = convertTargetCollection
5575
5588
  setShowConvertModal(false)
5576
5589
  setConvertRecordData(undefined)
5577
5590
  setConvertTargetCollection(undefined)
5591
+ if (record?.id)
5592
+ setPendingGoToRecord({
5593
+ collection: targetCollection,
5594
+ record,
5595
+ })
5578
5596
  }}
5579
5597
  />
5580
5598
  </div>
package/src/Record.tsx CHANGED
@@ -128,7 +128,9 @@ export const Record = ({ collection }: { collection: CollectionSchema }) => {
128
128
  id,
129
129
  async (data) => {
130
130
  if (!data) {
131
- setRecord(undefined)
131
+ if (!(!recordInitialised.current && recordFromState?.id === id)) {
132
+ setRecord(undefined)
133
+ }
132
134
  setIsRouteLoading("-", location.pathname)
133
135
  return
134
136
  }