@stoker-platform/web-app 0.5.143 → 0.5.144
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 +6 -0
- package/package.json +1 -1
- package/src/Form.tsx +23 -5
- package/src/Record.tsx +3 -1
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
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
|
|
@@ -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)
|
|
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
|
-
|
|
131
|
+
if (!(!recordInitialised.current && recordFromState?.id === id)) {
|
|
132
|
+
setRecord(undefined)
|
|
133
|
+
}
|
|
132
134
|
setIsRouteLoading("-", location.pathname)
|
|
133
135
|
return
|
|
134
136
|
}
|