3
0

Open record fields in modal if you're already in a modal

This commit is contained in:
Jože Fortun
2024-06-03 16:57:09 +02:00
parent 7a4c1028c8
commit 2ef3e50686
6 changed files with 18 additions and 14 deletions
@@ -136,6 +136,13 @@ export default {
return edit || view
},
// detect when a page block is opened in a modal through magnification or record open type
inModal () {
const { recordPageID, magnifiedBlockID } = this.$route.query
return !!recordPageID || !!magnifiedBlockID
},
},
}
</script>
@@ -198,7 +198,7 @@ export default {
onRecordSelectorClick (e, route) {
e.preventDefault()
if (this.extraOptions.recordSelectorDisplayOption === 'modal') {
if (this.extraOptions.recordSelectorDisplayOption === 'modal' || this.inModal) {
this.$root.$emit('show-record-modal', {
recordID: route.params.recordID,
recordPageID: route.params.pageID,
@@ -76,6 +76,13 @@ export default {
options () {
return this.field.options
},
// detect when a page block is opened in a modal through magnification or record open type
inModal () {
const { recordPageID, magnifiedBlockID } = this.$route.query
return !!recordPageID || !!magnifiedBlockID
},
},
}
</script>
@@ -382,18 +382,13 @@ export default {
const route = { name: 'page.record', params: { recordID, pageID: page.pageID } }
if (this.inModal) {
if (this.options.eventDisplayOption === 'modal' || this.inModal) {
this.$root.$emit('show-record-modal', {
recordID,
recordPageID: page.pageID,
})
} else if (this.options.eventDisplayOption === 'newTab') {
window.open(this.$router.resolve(route).href)
} else if (this.options.eventDisplayOption === 'modal') {
this.$root.$emit('show-record-modal', {
recordID,
recordPageID: page.pageID,
})
} else {
this.$router.push(route)
}
@@ -255,18 +255,13 @@ export default {
const route = { name: 'page.record', params: { recordID, pageID: page.pageID } }
if (this.inModal) {
if (this.options.displayOption === 'modal' || this.inModal) {
this.$root.$emit('show-record-modal', {
recordID,
recordPageID: page.pageID,
})
} else if (this.options.displayOption === 'newTab') {
window.open(this.$router.resolve(route).href)
} else if (this.options.displayOption === 'modal') {
this.$root.$emit('show-record-modal', {
recordID,
recordPageID: page.pageID,
})
} else {
this.$router.push(route)
}
@@ -349,7 +349,7 @@ export default {
values[groupField] = group
}
if (this.inModal) {
if (this.options.displayOption === 'modal' || this.inModal) {
this.$root.$emit('show-record-modal', {
recordID: NoID,
recordPageID: (this.roRecordPage || {}).pageID,