Fix prompts not opening page in edit mode when used in sucession
This commit is contained in:
parent
2fb301536c
commit
de90be03a7
@ -156,16 +156,22 @@ export default {
|
|||||||
.then(r => {
|
.then(r => {
|
||||||
record = new compose.Record(this.module, r)
|
record = new compose.Record(this.module, r)
|
||||||
})
|
})
|
||||||
.then(() => this.dispatchUiEvent('afterFormSubmit', this.record, { $records: records }))
|
.then(() => this.dispatchUiEvent('afterFormSubmit', record, { $records: records }))
|
||||||
.then(() => this.updatePrompts())
|
.then(() => this.updatePrompts())
|
||||||
.then(() => {
|
.then(() => {
|
||||||
if (this.record.valueErrors.set) {
|
if (record.valueErrors.set) {
|
||||||
this.toastWarning(this.$t('notification:record.validationWarnings'))
|
this.toastWarning(this.$t('notification:record.validationWarnings'))
|
||||||
} else {
|
} else {
|
||||||
|
// We do this prop mutation (BAD!!) so that prompts can use the edit prop properly since just redirecting to the /edit route doesn't work (for now)
|
||||||
|
if (this.edit) {
|
||||||
|
this.edit = false
|
||||||
|
}
|
||||||
|
|
||||||
this.inCreating = false
|
this.inCreating = false
|
||||||
this.inEditing = false
|
this.inEditing = false
|
||||||
|
|
||||||
// reset the record initial state in cases where the record edit page is redirected to the record view page
|
// reset the record initial state in cases where the record edit page is redirected to the record view page
|
||||||
this.initialRecordState = this.record.clone()
|
this.initialRecordState = record.clone()
|
||||||
|
|
||||||
if (this.showRecordModal) {
|
if (this.showRecordModal) {
|
||||||
this.$emit('handle-record-redirect', { recordID: record.recordID, recordPageID: this.page.pageID })
|
this.$emit('handle-record-redirect', { recordID: record.recordID, recordPageID: this.page.pageID })
|
||||||
|
|||||||
@ -316,23 +316,19 @@ export default {
|
|||||||
'page.pageID': {
|
'page.pageID': {
|
||||||
immediate: true,
|
immediate: true,
|
||||||
handler () {
|
handler () {
|
||||||
console.log('1')
|
|
||||||
if (this.page.pageID === NoID) return
|
if (this.page.pageID === NoID) return
|
||||||
|
|
||||||
this.layouts = this.getPageLayouts(this.page.pageID)
|
this.layouts = this.getPageLayouts(this.page.pageID)
|
||||||
this.layout = undefined
|
this.layout = undefined
|
||||||
console.log('1')
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
uniqueID: {
|
uniqueID: {
|
||||||
immediate: true,
|
immediate: true,
|
||||||
handler () {
|
handler () {
|
||||||
console.log('2')
|
|
||||||
this.record = undefined
|
this.record = undefined
|
||||||
this.initialRecordState = undefined
|
this.initialRecordState = undefined
|
||||||
this.refresh()
|
this.refresh()
|
||||||
console.log('2')
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@ -12,8 +12,8 @@ const variants = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
const openModeVariants = [
|
const openModeVariants = [
|
||||||
{ value: 'newTab', text: 'Open link in a new tab' },
|
|
||||||
{ value: 'sameTab', text: 'Open link in the same tab' },
|
{ value: 'sameTab', text: 'Open link in the same tab' },
|
||||||
|
{ value: 'newTab', text: 'Open link in a new tab' },
|
||||||
]
|
]
|
||||||
|
|
||||||
export const prompts = Object.freeze([
|
export const prompts = Object.freeze([
|
||||||
|
|||||||
@ -108,7 +108,7 @@ const definitions: Record<string, PromptDefinition> = {
|
|||||||
const module = pVal(v, 'module')
|
const module = pVal(v, 'module')
|
||||||
const namespace = pVal(v, 'namespace')
|
const namespace = pVal(v, 'namespace')
|
||||||
const record = pVal(v, 'record')
|
const record = pVal(v, 'record')
|
||||||
const edit = !!pVal(v, 'edit')
|
let edit = !!pVal(v, 'edit')
|
||||||
const delay = (pVal(v, 'delay') || 0) as number
|
const delay = (pVal(v, 'delay') || 0) as number
|
||||||
const openMode = pVal(v, 'openMode')
|
const openMode = pVal(v, 'openMode')
|
||||||
|
|
||||||
@ -185,9 +185,8 @@ const definitions: Record<string, PromptDefinition> = {
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
if (this.$root.$options.name === 'compose') {
|
if (this.$root.$options.name === 'compose') {
|
||||||
let name = 'page.record'
|
let name = 'page.record'
|
||||||
if (edit || !recordID || recordID === NoID) {
|
edit = edit || !recordID || recordID === NoID
|
||||||
name += recordID && recordID !== NoID ? '.edit' : '.create'
|
name += edit ? '.edit' : '.create'
|
||||||
}
|
|
||||||
|
|
||||||
// If name and params match, make sure to refresh page instead of push
|
// If name and params match, make sure to refresh page instead of push
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
@ -196,7 +195,7 @@ const definitions: Record<string, PromptDefinition> = {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
console.debug('reroute to %s via prompt in %d sec', name, delay, { namespaceID, slug, moduleID, recordID })
|
console.debug('reroute to %s via prompt in %d sec', name, delay, { namespaceID, slug, moduleID, recordID })
|
||||||
|
|
||||||
const routeParams = { name, params: { recordID, pageID, slug } }
|
const routeParams = { name, params: { recordID, pageID, slug, edit } }
|
||||||
if (reloadPage) {
|
if (reloadPage) {
|
||||||
window.location.reload()
|
window.location.reload()
|
||||||
} else if (openMode === 'modal') {
|
} else if (openMode === 'modal') {
|
||||||
@ -204,6 +203,7 @@ const definitions: Record<string, PromptDefinition> = {
|
|||||||
this.$root.$emit('show-record-modal', {
|
this.$root.$emit('show-record-modal', {
|
||||||
recordID: !recordID ? NoID : recordID,
|
recordID: !recordID ? NoID : recordID,
|
||||||
recordPageID: pageID,
|
recordPageID: pageID,
|
||||||
|
edit,
|
||||||
})
|
})
|
||||||
} else if (openMode === 'newTab') {
|
} else if (openMode === 'newTab') {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user