3
0

Fix non-record blocks not refetching on record create/update

This commit is contained in:
Jože Fortun
2023-09-20 12:51:27 +02:00
parent c12ca79392
commit a544780753
17 changed files with 43 additions and 30 deletions
@@ -75,8 +75,8 @@ export default {
},
beforeDestroy () {
this.setDefaultValues()
this.destroyEvents()
this.setDefaultValues()
},
methods: {
@@ -146,8 +146,8 @@ export default {
},
beforeDestroy () {
this.setDefaultValues()
this.destroyEvents()
this.setDefaultValues()
},
methods: {
@@ -58,8 +58,8 @@ export default {
},
beforeDestroy () {
this.setDefaultValues()
this.destroyEvents()
this.setDefaultValues()
},
methods: {
@@ -95,8 +95,8 @@ export default {
beforeDestroy () {
this.abortRequests()
this.setDefaultValues()
this.destroyEvents()
this.setDefaultValues()
},
created () {
@@ -81,8 +81,8 @@ export default {
},
beforeDestroy () {
this.setDefaultValues()
this.destroyEvents()
this.setDefaultValues()
},
methods: {
@@ -1194,9 +1194,9 @@ export default {
* at the given point in time.
*
* It:
* * assures that local records have a sequencial indexing
* * appends aditional meta fields
* * resolves payloadediting
* * assures that local records have a sequential indexing
* * appends additional meta fields
* * resolves payload editing
*/
resolveRecords (resolve) {
this.ctr = 0
@@ -255,8 +255,8 @@ export default {
beforeDestroy () {
this.abortRequests()
this.setDefaultValues()
this.destroyEvents()
this.setDefaultValues()
},
methods: {
@@ -312,8 +312,8 @@ export default {
},
beforeDestroy () {
this.setDefaultValues()
this.destroyEvents()
this.setDefaultValues()
},
methods: {
@@ -75,8 +75,8 @@ export default {
},
beforeDestroy () {
this.setDefaultValues()
this.destroyEvents()
this.setDefaultValues()
},
methods: {
@@ -89,8 +89,8 @@ export default {
},
beforeDestroy () {
this.setDefaultValues()
this.destroyEvents()
this.setDefaultValues()
},
methods: {
@@ -115,8 +115,8 @@ export default {
},
beforeDestroy () {
this.setDefaultValues()
this.destroyEvents()
this.setDefaultValues()
},
methods: {
+25 -12
View File
@@ -88,6 +88,7 @@ export default {
queue.push(p)
}
})
const pairs = await Promise.all(queue)
for (const p of pairs) {
@@ -103,18 +104,26 @@ export default {
// Construct batch record payload
const records = pairs.reduce((acc, cur) => {
acc.push({
refField: cur.refField,
set: cur.items
.map(({ r }) => r)
.filter(({ deletedAt, recordID }) => recordID !== NoID || !deletedAt),
module: cur.module,
idPrefix: cur.idPrefix,
})
if (cur.idPrefix) {
// If same module exists, use latest to avoid stale data
const existingIndex = acc.findIndex(({ module }) => module.moduleID === cur.module.moduleID)
if (existingIndex !== -1) {
acc[existingIndex].set = cur.items.map(({ r }) => r).filter(({ deletedAt, recordID }) => recordID !== NoID || !deletedAt)
} else {
acc.push({
refField: cur.refField,
set: cur.items.map(({ r }) => r).filter(({ deletedAt, recordID }) => recordID !== NoID || !deletedAt),
module: cur.module,
idPrefix: cur.idPrefix,
})
}
}
return acc
}, [])
const { recordID = NoID } = this.record || {}
// Append after the payload construction, so it is not presented as a
// sub record.
pairs.push({
@@ -152,15 +161,19 @@ export default {
if (this.record.valueErrors.set) {
this.toastWarning(this.$t('notification:record.validationWarnings'))
} else {
this.inCreating = false
this.inEditing = false
this.record = record
if (this.showRecordModal) {
this.$emit('handle-record-redirect', { recordID: record.recordID, recordPageID: this.page.pageID })
} else {
this.$router.push({ name: route, params: { ...this.$route.params, recordID: record.recordID } })
}
// Refresh record
this.inCreating = false
this.inEditing = false
this.record = undefined
this.loadRecord().then(() => {
this.determineLayout()
})
}
this.toastSuccess(this.$t(`notification:record.${isNew ? 'create' : 'update'}Success`))
@@ -512,8 +512,8 @@ export default {
},
beforeDestroy () {
this.setDefaultValues()
this.destroyEvents()
this.setDefaultValues()
},
methods: {
+1 -1
View File
@@ -192,8 +192,8 @@ export default {
},
beforeDestroy () {
this.setDefaultValues()
this.destroyEvents()
this.setDefaultValues()
},
methods: {
@@ -317,8 +317,8 @@ export default {
beforeDestroy () {
this.abortRequests()
this.setDefaultValues()
this.destroyEvents()
this.setDefaultValues()
},
// Destroy event before route leave to ensure it doesn't destroy the newly created one
@@ -197,8 +197,8 @@ export default {
},
beforeDestroy () {
this.setDefaultValues()
this.destroyEvents()
this.setDefaultValues()
},
beforeRouteLeave (to, from, next) {
@@ -334,8 +334,8 @@ export default {
},
beforeDestroy () {
this.setDefaultValues()
this.destroyEvents()
this.setDefaultValues()
},
methods: {