Restructure event destroy and request abort code
This commit is contained in:
@@ -75,8 +75,9 @@ export default {
|
||||
},
|
||||
|
||||
beforeDestroy () {
|
||||
const { pageID = NoID } = this.$route.params
|
||||
this.$root.$off(`refetch-non-record-blocks:${pageID}`)
|
||||
this.abortRequests()
|
||||
this.setDefaultValues()
|
||||
this.destroyEvents()
|
||||
},
|
||||
|
||||
methods: {
|
||||
@@ -199,6 +200,16 @@ export default {
|
||||
/* eslint-disable no-console */
|
||||
console.error(msg)
|
||||
},
|
||||
|
||||
setDefaultValues () {
|
||||
this.processing = false
|
||||
this.rendeder = undefined
|
||||
},
|
||||
|
||||
destroyEvents () {
|
||||
const { pageID = NoID } = this.$route.params
|
||||
this.$root.$off(`refetch-non-record-blocks:${pageID}`)
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -41,7 +41,7 @@ export default {
|
||||
|
||||
automationScripts: [],
|
||||
|
||||
abortRequests: [],
|
||||
abortableRequests: [],
|
||||
}
|
||||
},
|
||||
|
||||
@@ -52,11 +52,8 @@ export default {
|
||||
},
|
||||
|
||||
beforeDestroy () {
|
||||
this.abortRequests()
|
||||
this.setDefaultValues()
|
||||
|
||||
this.abortRequests.forEach((cancel) => {
|
||||
cancel()
|
||||
})
|
||||
},
|
||||
|
||||
created () {
|
||||
@@ -74,7 +71,7 @@ export default {
|
||||
const { response, cancel } = this.$ComposeAPI
|
||||
.automationListCancellable({ eventTypes: ['onManual'], excludeInvalid: true })
|
||||
|
||||
this.abortRequests.push(cancel)
|
||||
this.abortableRequests.push(cancel)
|
||||
|
||||
return response()
|
||||
.then(({ set = [] }) => {
|
||||
@@ -88,6 +85,13 @@ export default {
|
||||
setDefaultValues () {
|
||||
this.processing = false
|
||||
this.automationScripts = []
|
||||
this.abortableRequests = []
|
||||
},
|
||||
|
||||
abortRequests () {
|
||||
this.abortableRequests.forEach((cancel) => {
|
||||
cancel()
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -153,7 +153,6 @@ export default {
|
||||
allowExport: true,
|
||||
perPage: 14,
|
||||
showTotalCount: true,
|
||||
magnifyOption: 'modal',
|
||||
recordDisplayOption: 'modal',
|
||||
},
|
||||
})
|
||||
@@ -169,8 +168,7 @@ export default {
|
||||
},
|
||||
|
||||
destroyEvents () {
|
||||
this.$root.$off('drill-down-chart')
|
||||
this.$root.$off('magnify-page-block')
|
||||
this.$root.$off('drill-down-chart', this.drillDown)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ export default {
|
||||
content: '',
|
||||
},
|
||||
|
||||
abortRequests: [],
|
||||
abortableRequests: [],
|
||||
}
|
||||
},
|
||||
|
||||
@@ -218,11 +218,8 @@ export default {
|
||||
},
|
||||
|
||||
beforeDestroy () {
|
||||
this.abortRequests()
|
||||
this.setDefaultValues()
|
||||
|
||||
this.abortRequests.forEach((cancel) => {
|
||||
cancel()
|
||||
})
|
||||
},
|
||||
|
||||
methods: {
|
||||
@@ -346,7 +343,7 @@ export default {
|
||||
|
||||
const { response, cancel } = this.$ComposeAPI
|
||||
.recordListCancellable(params)
|
||||
this.abortRequests.push(cancel)
|
||||
this.abortableRequests.push(cancel)
|
||||
|
||||
return response()
|
||||
.then(({ set }) => set.map(r => Object.freeze(new compose.Record(module, r))))
|
||||
@@ -357,6 +354,13 @@ export default {
|
||||
this.filter = false
|
||||
this.records = []
|
||||
this.newRecord = {}
|
||||
this.abortableRequests = []
|
||||
},
|
||||
|
||||
abortRequests () {
|
||||
this.abortableRequests.forEach((cancel) => {
|
||||
cancel()
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ export default {
|
||||
processing: false,
|
||||
reports: [],
|
||||
|
||||
abortRequests: [],
|
||||
abortableRequests: [],
|
||||
}
|
||||
},
|
||||
|
||||
@@ -94,14 +94,9 @@ export default {
|
||||
},
|
||||
|
||||
beforeDestroy () {
|
||||
this.abortRequests()
|
||||
this.setDefaultValues()
|
||||
this.destroyEvents()
|
||||
this.$root.$off('metric.update', this.refresh)
|
||||
this.$root.$off(`refetch-non-record-blocks:${this.page.pageID}`)
|
||||
|
||||
this.abortRequests.forEach((cancel) => {
|
||||
cancel()
|
||||
})
|
||||
},
|
||||
|
||||
created () {
|
||||
@@ -147,7 +142,7 @@ export default {
|
||||
const { response, cancel } = this.$ComposeAPI
|
||||
.recordReportCancellable({ ...r, namespaceID })
|
||||
|
||||
this.abortRequests.push(cancel)
|
||||
this.abortableRequests.push(cancel)
|
||||
|
||||
return response()
|
||||
}
|
||||
@@ -204,18 +199,20 @@ export default {
|
||||
options: {
|
||||
moduleID,
|
||||
prefilter: filter,
|
||||
presort: '',
|
||||
presort: 'createdAt DESC',
|
||||
hideRecordReminderButton: true,
|
||||
hideRecordViewButton: false,
|
||||
hideConfigureFieldsButton: false,
|
||||
hideImportButton: true,
|
||||
enableRecordPageNavigation: true,
|
||||
selectable: true,
|
||||
allowExport: true,
|
||||
perPage: 14,
|
||||
showTotalCount: true,
|
||||
magnifyOption: 'modal',
|
||||
recordDisplayOption: 'modal',
|
||||
},
|
||||
})
|
||||
|
||||
this.$root.$emit('magnify-page-block', { block })
|
||||
}
|
||||
},
|
||||
@@ -223,11 +220,18 @@ export default {
|
||||
setDefaultValues () {
|
||||
this.processing = false
|
||||
this.reports = []
|
||||
this.abortableRequests = []
|
||||
},
|
||||
|
||||
abortRequests () {
|
||||
this.abortableRequests.forEach((cancel) => {
|
||||
cancel()
|
||||
})
|
||||
},
|
||||
|
||||
destroyEvents () {
|
||||
this.$root.$off('metric.update', this.refresh)
|
||||
this.$root.$off(`refetch-non-record-blocks:${this.page.pageID}`)
|
||||
this.$root.$off(`refetch-non-record-blocks:${this.page.pageID}`, this.refresh)
|
||||
this.$root.$off('drill-down-chart', this.drillDown)
|
||||
},
|
||||
},
|
||||
|
||||
@@ -140,7 +140,7 @@ export default {
|
||||
},
|
||||
|
||||
destroyEvents () {
|
||||
this.$root.$off(`refetch-non-record-blocks:${this.page.pageID}`)
|
||||
this.$root.$off(`refetch-non-record-blocks:${this.page.pageID}`, this.refresh)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ export default {
|
||||
initialRecord: {},
|
||||
},
|
||||
|
||||
abortRequests: [],
|
||||
abortableRequests: [],
|
||||
}
|
||||
},
|
||||
|
||||
@@ -216,10 +216,8 @@ export default {
|
||||
},
|
||||
|
||||
beforeDestroy () {
|
||||
this.abortRequests()
|
||||
this.setDefaultValues()
|
||||
this.abortRequests.forEach((cancel) => {
|
||||
cancel()
|
||||
})
|
||||
},
|
||||
|
||||
methods: {
|
||||
@@ -265,7 +263,7 @@ export default {
|
||||
const { response, cancel } = this.$ComposeAPI
|
||||
.recordReadCancellable({ namespaceID, moduleID, recordID })
|
||||
|
||||
this.abortRequests.push(cancel)
|
||||
this.abortableRequests.push(cancel)
|
||||
|
||||
response()
|
||||
.then(record => {
|
||||
@@ -327,6 +325,13 @@ export default {
|
||||
this.referenceRecord = undefined
|
||||
this.referenceModule = undefined
|
||||
this.inlineEdit = {}
|
||||
this.abortableRequests = []
|
||||
},
|
||||
|
||||
abortRequests () {
|
||||
this.abortableRequests.forEach((cancel) => {
|
||||
cancel()
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -830,7 +830,7 @@ export default {
|
||||
showCustomPresetFilterModal: false,
|
||||
selectedAllRecords: false,
|
||||
|
||||
abortRequests: [],
|
||||
abortableRequests: [],
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1055,6 +1055,7 @@ export default {
|
||||
},
|
||||
|
||||
beforeDestroy () {
|
||||
this.abortRequests()
|
||||
this.setDefaultValues()
|
||||
this.destroyEvents()
|
||||
},
|
||||
@@ -1091,17 +1092,6 @@ export default {
|
||||
})
|
||||
},
|
||||
|
||||
destroyEvents () {
|
||||
this.$root.$off(`record-line:collect:${this.uniqueID}`)
|
||||
this.$root.$off(`page-block:validate:${this.uniqueID}`)
|
||||
this.$root.$off(`drill-down-recordList:${this.uniqueID}`)
|
||||
this.$root.$off(`refetch-non-record-blocks:${this.page.pageID}`)
|
||||
|
||||
this.abortRequests.forEach((cancel) => {
|
||||
cancel()
|
||||
})
|
||||
},
|
||||
|
||||
onFilter (filter = []) {
|
||||
filter.forEach(f => {
|
||||
if (this.activeFilters.includes(f.name)) {
|
||||
@@ -1505,7 +1495,7 @@ export default {
|
||||
const { response, cancel } = this.$ComposeAPI
|
||||
.recordBulkUndeleteCancellable({ moduleID, namespaceID, query })
|
||||
|
||||
this.abortRequests.push(cancel)
|
||||
this.abortableRequests.push(cancel)
|
||||
|
||||
response()
|
||||
.then(() => {
|
||||
@@ -1539,7 +1529,7 @@ export default {
|
||||
const { response, cancel } = this.$ComposeAPI
|
||||
.recordBulkDeleteCancellable({ moduleID, namespaceID, query })
|
||||
|
||||
this.abortRequests.push(cancel)
|
||||
this.abortableRequests.push(cancel)
|
||||
|
||||
response()
|
||||
.then(() => this.refresh(true))
|
||||
@@ -1601,7 +1591,7 @@ export default {
|
||||
this.showingDeletedRecords ? this.filter.deleted = 2 : this.filter.deleted = 0
|
||||
|
||||
const { response, cancel } = this.$ComposeAPI.recordListCancellable({ ...this.filter, moduleID, namespaceID, query, ...paginationOptions })
|
||||
this.abortRequests.push(cancel)
|
||||
this.abortableRequests.push(cancel)
|
||||
|
||||
return response()
|
||||
.then(({ set, filter }) => {
|
||||
@@ -1883,6 +1873,24 @@ export default {
|
||||
this.currentCustomPresetFilter = undefined
|
||||
this.showCustomPresetFilterModal = false
|
||||
this.selectedAllRecords = false
|
||||
this.abortableRequests = []
|
||||
},
|
||||
|
||||
abortRequests () {
|
||||
this.abortableRequests.forEach((cancel) => {
|
||||
cancel()
|
||||
})
|
||||
},
|
||||
|
||||
destroyEvents () {
|
||||
const { pageID = NoID } = this.page
|
||||
|
||||
this.$root.$on(`record-line:collect:${this.uniqueID}`, this.resolveRecords)
|
||||
this.$root.$on(`page-block:validate:${this.uniqueID}`, this.validatePageBlock)
|
||||
this.$root.$on(`drill-down-recordList:${this.uniqueID}`, this.setDrillDownFilter)
|
||||
this.$root.$on(`refetch-non-record-blocks:${pageID}`, () => {
|
||||
this.refresh(true)
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ export default {
|
||||
|
||||
records: [],
|
||||
|
||||
abortRequests: [],
|
||||
abortableRequests: [],
|
||||
}
|
||||
},
|
||||
|
||||
@@ -254,12 +254,9 @@ export default {
|
||||
},
|
||||
|
||||
beforeDestroy () {
|
||||
this.abortRequests()
|
||||
this.setDefaultValues()
|
||||
this.destroyEvents()
|
||||
this.$root.$off(`refetch-non-record-blocks:${this.page.pageID}`)
|
||||
this.abortRequests.forEach((cancel) => {
|
||||
cancel()
|
||||
})
|
||||
},
|
||||
|
||||
methods: {
|
||||
@@ -446,7 +443,7 @@ export default {
|
||||
const { response, cancel } = this.$ComposeAPI
|
||||
.recordListCancellable({ namespaceID, moduleID, query, sort })
|
||||
|
||||
this.abortRequests.push(cancel)
|
||||
this.abortableRequests.push(cancel)
|
||||
|
||||
return response()
|
||||
.then(({ set }) => {
|
||||
@@ -503,10 +500,17 @@ export default {
|
||||
this.processing = false
|
||||
this.filter = {}
|
||||
this.records = []
|
||||
this.abortableRequests = []
|
||||
},
|
||||
|
||||
abortRequests () {
|
||||
this.abortableRequests.forEach((cancel) => {
|
||||
cancel()
|
||||
})
|
||||
},
|
||||
|
||||
destroyEvents () {
|
||||
this.$root.$off(`refetch-non-record-blocks:${this.page.pageID}`)
|
||||
this.$root.$off(`refetch-non-record-blocks:${this.page.pageID}`, this.refresh)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ export default {
|
||||
processing: false,
|
||||
report: undefined,
|
||||
displayElement: undefined,
|
||||
abortRequests: [],
|
||||
abortableRequests: [],
|
||||
}
|
||||
},
|
||||
|
||||
@@ -60,10 +60,8 @@ export default {
|
||||
},
|
||||
|
||||
beforeDestroy () {
|
||||
this.abortRequests()
|
||||
this.setDefaultValues()
|
||||
this.abortRequests.forEach((cancel) => {
|
||||
cancel()
|
||||
})
|
||||
},
|
||||
|
||||
created () {
|
||||
@@ -77,7 +75,7 @@ export default {
|
||||
const { response, cancel } = this.$SystemAPI
|
||||
.reportReadCancellable({ reportID })
|
||||
|
||||
this.abortRequests.push(cancel)
|
||||
this.abortableRequests.push(cancel)
|
||||
|
||||
return response()
|
||||
.then(report => {
|
||||
@@ -161,6 +159,13 @@ export default {
|
||||
this.processing = false
|
||||
this.report = undefined
|
||||
this.displayElement = undefined
|
||||
this.abortableRequests = []
|
||||
},
|
||||
|
||||
abortRequests () {
|
||||
this.abortableRequests.forEach((cancel) => {
|
||||
cancel()
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -71,17 +71,7 @@ export default {
|
||||
|
||||
created () {
|
||||
window.addEventListener('keyup', this.onKeyUp)
|
||||
this.$root.$on('showAttachmentsModal', ({ url, download, name, document = undefined, meta, enableDownload }) => {
|
||||
this.attachment = {
|
||||
document,
|
||||
download,
|
||||
meta,
|
||||
src: url,
|
||||
name: name,
|
||||
caption: name,
|
||||
enableDownload,
|
||||
}
|
||||
})
|
||||
this.$root.$on('showAttachmentsModal', this.showAttachmentModal)
|
||||
},
|
||||
|
||||
beforeDestroy () {
|
||||
@@ -96,13 +86,25 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
showAttachmentModal ({ url, download, name, document = undefined, meta, enableDownload }) {
|
||||
this.attachment = {
|
||||
document,
|
||||
download,
|
||||
meta,
|
||||
src: url,
|
||||
name: name,
|
||||
caption: name,
|
||||
enableDownload,
|
||||
}
|
||||
},
|
||||
|
||||
setDefaultValues () {
|
||||
this.attachment = undefined
|
||||
},
|
||||
|
||||
destroyEvents () {
|
||||
window.removeEventListener('keyup', this.onKeyUp)
|
||||
this.$root.$off('showAttachmentsModal')
|
||||
this.$root.$off('showAttachmentsModal', this.showAttachmentModal)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ export default {
|
||||
|
||||
onHidden () {
|
||||
setTimeout(() => {
|
||||
this.$router.push({
|
||||
this.$router.replace({
|
||||
query: {
|
||||
...this.$route.query,
|
||||
magnifiedBlockID: undefined,
|
||||
|
||||
@@ -154,7 +154,7 @@ export default {
|
||||
|
||||
onHidden () {
|
||||
setTimeout(() => {
|
||||
this.$router.push({
|
||||
this.$router.replace({
|
||||
query: {
|
||||
...this.$route.query,
|
||||
recordID: undefined,
|
||||
@@ -173,7 +173,7 @@ export default {
|
||||
},
|
||||
|
||||
destroyEvents () {
|
||||
this.$root.$off('show-record-modal')
|
||||
this.$root.$off('show-record-modal', this.loadRecord)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -93,7 +93,19 @@ export default {
|
||||
|
||||
mounted () {
|
||||
this.loaded = false
|
||||
this.$root.$on('c-translator', payload => {
|
||||
this.$root.$on('c-translator', this.loadModal)
|
||||
},
|
||||
|
||||
beforeDestroy () {
|
||||
this.destroyEvents()
|
||||
},
|
||||
|
||||
methods: {
|
||||
...mapActions({
|
||||
loadLanguages: 'languages/load',
|
||||
}),
|
||||
|
||||
loadModal (payload) {
|
||||
if (!payload) {
|
||||
// when falsy payload is received,
|
||||
// close the translator modal
|
||||
@@ -114,17 +126,7 @@ export default {
|
||||
this.translations = tt
|
||||
this.loaded = true
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
destroyed () {
|
||||
this.$root.$off('c-translator')
|
||||
},
|
||||
|
||||
methods: {
|
||||
...mapActions({
|
||||
loadLanguages: 'languages/load',
|
||||
}),
|
||||
},
|
||||
|
||||
onSubmit () {
|
||||
if (this.changes.length === 0) {
|
||||
@@ -155,6 +157,10 @@ export default {
|
||||
this.keyPrettyfier = undefined
|
||||
this.loaded = false
|
||||
},
|
||||
|
||||
destroyEvents () {
|
||||
this.$root.$off('c-translator', this.loadModal)
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -530,7 +530,7 @@ export default {
|
||||
modal: false,
|
||||
},
|
||||
|
||||
abortRequests: [],
|
||||
abortableRequests: [],
|
||||
}
|
||||
},
|
||||
|
||||
@@ -686,7 +686,7 @@ export default {
|
||||
const { response, cancel } = this.$ComposeAPI
|
||||
.recordListCancellable({ moduleID, namespaceID, limit: 1 })
|
||||
|
||||
this.abortRequests.push(cancel)
|
||||
this.abortableRequests.push(cancel)
|
||||
|
||||
response()
|
||||
.then(({ set }) => { this.hasRecords = (set.length > 0) })
|
||||
@@ -705,10 +705,8 @@ export default {
|
||||
},
|
||||
|
||||
beforeDestroy () {
|
||||
this.abortRequests()
|
||||
this.setDefaultValues()
|
||||
this.abortRequests.forEach((cancel) => {
|
||||
cancel()
|
||||
})
|
||||
},
|
||||
|
||||
beforeRouteUpdate (to, from, next) {
|
||||
@@ -879,6 +877,13 @@ export default {
|
||||
this.processing = false
|
||||
this.federationSettings = {}
|
||||
this.discoverySettings = {}
|
||||
this.abortableRequests = []
|
||||
},
|
||||
|
||||
abortRequests () {
|
||||
this.abortableRequests.forEach((cancel) => {
|
||||
cancel()
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ export default {
|
||||
namespace: this.$attrs.namespace,
|
||||
},
|
||||
|
||||
abortRequests: [],
|
||||
abortableRequests: [],
|
||||
}
|
||||
},
|
||||
|
||||
@@ -230,19 +230,16 @@ export default {
|
||||
},
|
||||
},
|
||||
|
||||
beforeDestroy () {
|
||||
this.setDefaultValues()
|
||||
|
||||
this.abortRequests.forEach((cancel) => {
|
||||
cancel()
|
||||
})
|
||||
},
|
||||
|
||||
created () {
|
||||
this.createBlocks()
|
||||
this.record = new compose.Record(this.module, { values: this.values })
|
||||
},
|
||||
|
||||
beforeDestroy () {
|
||||
this.abortRequests()
|
||||
this.setDefaultValues()
|
||||
},
|
||||
|
||||
methods: {
|
||||
createBlocks () {
|
||||
this.fields.forEach(f => {
|
||||
@@ -263,7 +260,7 @@ export default {
|
||||
const { response, cancel } = this.$ComposeAPI
|
||||
.recordReadCancellable({ namespaceID, moduleID, recordID })
|
||||
|
||||
this.abortRequests.push(cancel)
|
||||
this.abortableRequests.push(cancel)
|
||||
|
||||
response()
|
||||
.then(record => {
|
||||
@@ -311,6 +308,13 @@ export default {
|
||||
this.inEditing = false
|
||||
this.blocks = []
|
||||
this.bindParams = {}
|
||||
this.abortableRequests = []
|
||||
},
|
||||
|
||||
abortRequests () {
|
||||
this.abortableRequests.forEach((cancel) => {
|
||||
cancel()
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -904,7 +904,7 @@ export default {
|
||||
off: this.$t('general:label.no'),
|
||||
},
|
||||
|
||||
abortRequests: [],
|
||||
abortableRequests: [],
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1062,18 +1062,15 @@ export default {
|
||||
this.checkUnsavedComposePage(next)
|
||||
},
|
||||
|
||||
beforeDestroy () {
|
||||
this.setDefaultValues()
|
||||
|
||||
this.abortRequests.forEach((cancel) => {
|
||||
cancel()
|
||||
})
|
||||
},
|
||||
|
||||
created () {
|
||||
this.fetchRoles()
|
||||
},
|
||||
|
||||
beforeDestroy () {
|
||||
this.abortRequests()
|
||||
this.setDefaultValues()
|
||||
},
|
||||
|
||||
methods: {
|
||||
...mapActions({
|
||||
findPageByID: 'page/findByID',
|
||||
@@ -1100,7 +1097,7 @@ export default {
|
||||
const { response, cancel } = this.$SystemAPI
|
||||
.roleListCancellable({})
|
||||
|
||||
this.abortRequests.push(cancel)
|
||||
this.abortableRequests.push(cancel)
|
||||
|
||||
response()
|
||||
.then(({ set: roles = [] }) => {
|
||||
@@ -1290,6 +1287,13 @@ export default {
|
||||
this.removedLayouts.clear()
|
||||
this.roles = {}
|
||||
this.checkboxLabel = {}
|
||||
this.abortableRequests = []
|
||||
},
|
||||
|
||||
abortRequests () {
|
||||
this.abortableRequests.forEach((cancel) => {
|
||||
cancel()
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ export default {
|
||||
tree: [],
|
||||
page: new compose.Page({ visible: true }),
|
||||
processing: false,
|
||||
abortRequests: [],
|
||||
abortableRequests: [],
|
||||
}
|
||||
},
|
||||
|
||||
@@ -131,10 +131,8 @@ export default {
|
||||
},
|
||||
|
||||
beforeDestroy () {
|
||||
this.abortRequests()
|
||||
this.setDefaultValues()
|
||||
this.abortRequests.forEach((cancel) => {
|
||||
cancel()
|
||||
})
|
||||
},
|
||||
|
||||
methods: {
|
||||
@@ -150,7 +148,7 @@ export default {
|
||||
const { response, cancel } = this.$ComposeAPI
|
||||
.pageTreeCancellable({ namespaceID })
|
||||
|
||||
this.abortRequests.push(cancel)
|
||||
this.abortableRequests.push(cancel)
|
||||
|
||||
response()
|
||||
.then((tree) => {
|
||||
@@ -188,6 +186,13 @@ export default {
|
||||
this.tree = []
|
||||
this.page = {}
|
||||
this.processing = false
|
||||
this.abortableRequests = []
|
||||
},
|
||||
|
||||
abortRequests () {
|
||||
this.abortableRequests.forEach((cancel) => {
|
||||
cancel()
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -186,9 +186,8 @@ export default {
|
||||
* Listen for incoming warnings, alerts and other messages
|
||||
* from the (mostly) Corredor scripts and display them using toasts
|
||||
*/
|
||||
this.$root.$on('alert', ({ message, ...params }) => this.toast(message, params))
|
||||
this.$root.$on('alert', this.showAlert)
|
||||
this.$root.$on('reminder.show', this.showReminder)
|
||||
|
||||
this.$root.$on('check-namespace-sidebar', this.checkNamespaceSidebar)
|
||||
},
|
||||
|
||||
@@ -238,6 +237,10 @@ export default {
|
||||
})
|
||||
},
|
||||
|
||||
showAlert ({ message, ...params }) {
|
||||
this.toast(message, params)
|
||||
},
|
||||
|
||||
showReminder (r) {
|
||||
const i = this.toasts.findIndex(({ reminderID }) => reminderID === r.reminderID)
|
||||
if (i > -1 && (!r.editedAt || r.editedAt === this.toasts[i].editedAt)) {
|
||||
@@ -295,7 +298,7 @@ export default {
|
||||
},
|
||||
|
||||
destroyEvents () {
|
||||
this.$root.$off('alert')
|
||||
this.$root.$off('alert', this.showAlert)
|
||||
this.$root.$off('reminder.show', this.showReminder)
|
||||
this.$root.$off('check-namespace-sidebar', this.checkNamespaceSidebar)
|
||||
},
|
||||
|
||||
@@ -194,7 +194,7 @@ export default {
|
||||
next: undefined,
|
||||
},
|
||||
|
||||
abortRequests: [],
|
||||
abortableRequests: [],
|
||||
}
|
||||
},
|
||||
|
||||
@@ -312,31 +312,18 @@ export default {
|
||||
},
|
||||
|
||||
mounted () {
|
||||
this.$root.$on('refetch-record-blocks', () => {
|
||||
// Don't refresh when creating and prompt user before refreshing when editing
|
||||
if (this.inCreating || (this.inEditing && !window.confirm(this.$t('notification:record.staleDataRefresh')))) {
|
||||
return
|
||||
}
|
||||
|
||||
// Refetch the record and other page blocks that use records
|
||||
this.loadRecord()
|
||||
this.$root.$emit(`refetch-non-record-blocks:${this.page.pageID}`)
|
||||
})
|
||||
this.$root.$on('refetch-record-blocks', this.refetchRecordBlocks)
|
||||
},
|
||||
|
||||
beforeDestroy () {
|
||||
this.abortRequests()
|
||||
this.setDefaultValues()
|
||||
this.destroyEvents()
|
||||
this.$root.$off('refetch-record-blocks')
|
||||
|
||||
this.abortRequests.forEach((cancel) => {
|
||||
cancel()
|
||||
})
|
||||
},
|
||||
|
||||
// Destroy event before route leave to ensure it doesn't destroy the newly created one
|
||||
beforeRouteLeave (to, from, next) {
|
||||
this.$root.$off('refetch-record-blocks')
|
||||
this.$root.$off('refetch-record-blocks', this.refetchRecordBlocks)
|
||||
next()
|
||||
},
|
||||
|
||||
@@ -360,7 +347,7 @@ export default {
|
||||
const { response, cancel } = this.$ComposeAPI
|
||||
.recordReadCancellable({ namespaceID, moduleID, recordID })
|
||||
|
||||
this.abortRequests.push(cancel)
|
||||
this.abortableRequests.push(cancel)
|
||||
|
||||
return response()
|
||||
.then(record => {
|
||||
@@ -538,6 +525,17 @@ export default {
|
||||
})
|
||||
},
|
||||
|
||||
refetchRecordBlocks () {
|
||||
// Don't refresh when creating and prompt user before refreshing when editing
|
||||
if (this.inCreating || (this.inEditing && !window.confirm(this.$t('notification:record.staleDataRefresh')))) {
|
||||
return
|
||||
}
|
||||
|
||||
// Refetch the record and other page blocks that use records
|
||||
this.loadRecord()
|
||||
this.$root.$emit(`refetch-non-record-blocks:${this.page.pageID}`)
|
||||
},
|
||||
|
||||
setDefaultValues () {
|
||||
this.inEditing = false
|
||||
this.inCreating = false
|
||||
@@ -546,10 +544,17 @@ export default {
|
||||
this.layoutButtons.clear()
|
||||
this.blocks = undefined
|
||||
this.recordNavigation = {}
|
||||
this.abortableRequests = []
|
||||
},
|
||||
|
||||
abortRequests () {
|
||||
this.abortableRequests.forEach((cancel) => {
|
||||
cancel()
|
||||
})
|
||||
},
|
||||
|
||||
destroyEvents () {
|
||||
this.$root.$off('refetch-record-blocks')
|
||||
this.$root.$off('refetch-record-blocks', this.refetchRecordBlocks)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -193,10 +193,7 @@ export default {
|
||||
},
|
||||
|
||||
mounted () {
|
||||
this.$root.$on('refetch-records', () => {
|
||||
// If on a record page, let it take care of events else just refetch non record-blocks (that use records)
|
||||
this.$root.$emit(this.page.moduleID !== NoID ? 'refetch-record-blocks' : `refetch-non-record-blocks:${this.page.pageID}`)
|
||||
})
|
||||
this.$root.$on('refetch-records', this.refetchRecords)
|
||||
},
|
||||
|
||||
beforeDestroy () {
|
||||
@@ -310,6 +307,11 @@ export default {
|
||||
})
|
||||
},
|
||||
|
||||
refetchRecords () {
|
||||
// If on a record page, let it take care of events else just refetch non record-blocks (that use records)
|
||||
this.$root.$emit(this.page.moduleID !== NoID ? 'refetch-record-blocks' : `refetch-non-record-blocks:${this.page.pageID}`)
|
||||
},
|
||||
|
||||
setDefaultValues () {
|
||||
this.layouts = []
|
||||
this.layout = undefined
|
||||
@@ -318,7 +320,7 @@ export default {
|
||||
},
|
||||
|
||||
destroyEvents () {
|
||||
this.$root.$off('refetch-records')
|
||||
this.$root.$off('refetch-records', this.refetchRecords)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -218,15 +218,12 @@ export default {
|
||||
created () {
|
||||
this.checkIfMobile()
|
||||
|
||||
this.$root.$on('close-sidebar', () => {
|
||||
this.isExpanded = false
|
||||
this.isPinned = false
|
||||
})
|
||||
this.$root.$on('close-sidebar', this.closeSidebar)
|
||||
window.addEventListener('resize', this.checkIfMobile)
|
||||
},
|
||||
|
||||
beforeDestroy () {
|
||||
this.$root.$off('close-sidebar')
|
||||
this.$root.$off('close-sidebar', this.closeSidebar)
|
||||
window.removeEventListener('resize', this.checkIfMobile)
|
||||
},
|
||||
|
||||
|
||||
@@ -330,7 +330,16 @@ export default {
|
||||
mounted () {
|
||||
this.searchUsers('', () => {})
|
||||
|
||||
this.$root.$on(modalOpenEventName, ({ resource, title, target, allSpecific }) => {
|
||||
this.$root.$on(modalOpenEventName, this.loadModal)
|
||||
},
|
||||
|
||||
beforeDestroy () {
|
||||
this.setDefaultValues()
|
||||
this.destroyEvents()
|
||||
},
|
||||
|
||||
methods: {
|
||||
loadModal ({ resource, title, target, allSpecific }) {
|
||||
this.resource = resource
|
||||
this.title = title
|
||||
this.target = target
|
||||
@@ -364,16 +373,8 @@ export default {
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
})
|
||||
},
|
||||
|
||||
beforeDestroy () {
|
||||
this.setDefaultValues()
|
||||
this.destroyEvents()
|
||||
},
|
||||
|
||||
methods: {
|
||||
onHide () {
|
||||
this.clear()
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user