修复pagetype重命名后无法自动刷新显示新pagetype名称的问题
This commit is contained in:
parent
048d8ee270
commit
dfac0fb4ba
@ -1282,32 +1282,19 @@ async function handleDelete() {
|
||||
}
|
||||
|
||||
// 重命名记录后跳转到新名称
|
||||
// Align with old frontend toolbar.js: enqueue=true returns old name,
|
||||
// so we listen for realtime list_update event and wait for rename completion.
|
||||
// Align with old frontend toolbar.js: directly navigate to new name after rename.
|
||||
// Old frontend calls reload_form(input_name) immediately (line 170), regardless of enqueue.
|
||||
function handleRename(newName: string) {
|
||||
if (!newName) return
|
||||
|
||||
const oldName = id.value
|
||||
|
||||
// When enqueue=true, backend returns old name (rename is queued async).
|
||||
// We must wait for the realtime list_update event before navigating.
|
||||
if (newName !== oldName) {
|
||||
// Subscribe to new name's realtime events (like old frontend's pagetype_subscribe)
|
||||
realtime.pgSubscribe(entity.value, newName)
|
||||
|
||||
// Show queued alert (align with old frontend)
|
||||
message.info(t('Document renaming from {0} to {1} has been queued', [oldName, newName]))
|
||||
|
||||
// Listen for list_update to know when rename completes (align with old frontend)
|
||||
const offListUpdate = realtime.subscribe('list_update', (data: any) => {
|
||||
if (data.pagetype === entity.value && data.name === newName) {
|
||||
offListUpdate()
|
||||
message.success(t('Document renamed from {0} to {1}', [oldName, newName]))
|
||||
router.push({
|
||||
name: 'PageTypeDetail',
|
||||
params: { entity: pagetypeSlug.value, id: newName }
|
||||
})
|
||||
}
|
||||
// Directly navigate to the new name's detail page (align with old frontend)
|
||||
message.success(t('Document renamed from {0} to {1}', [oldName, newName]))
|
||||
router.push({
|
||||
name: 'PageTypeDetail',
|
||||
params: { entity: pagetypeSlug.value, id: newName }
|
||||
})
|
||||
} else {
|
||||
// Same name (e.g. title-only change), just reload
|
||||
|
||||
@ -283,7 +283,7 @@ async function handleRenameConfirm() {
|
||||
if (result.success) {
|
||||
message.success(t('Document renamed successfully'))
|
||||
showRenameDialog.value = false
|
||||
emit('rename', result.data || newName)
|
||||
emit('rename', newName)
|
||||
} else {
|
||||
message.error(result.message || t('Failed to rename document'))
|
||||
return false
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user