3
0

Fix manual refresh not working for chart, calendar, record organizer and reporter blocks

This commit is contained in:
Jože Fortun
2023-01-20 12:27:41 +01:00
parent 0419d0240b
commit 74f372794b
6 changed files with 28 additions and 23 deletions
@@ -226,7 +226,7 @@ export default {
created () {
this.changeLocale(this.currentLanguage)
this.refreshBlock(this.refresh, true)
this.refreshBlock(this.refresh)
},
methods: {
@@ -350,7 +350,9 @@ export default {
refresh () {
this.refreshing = true
this.api().refetchEvents()
this.api().refetchEvents().then(() => {
this.key++
})
},
},
}
@@ -38,7 +38,7 @@ export default {
mounted () {
this.fetchChart()
this.refreshBlock(this.refresh, true)
this.refreshBlock(this.refresh)
},
methods: {
@@ -46,7 +46,7 @@ export default {
findChartByID: 'chart/findByID',
}),
fetchChart (params = {}) {
async fetchChart (params = {}) {
const { chartID } = this.options
if (chartID === NoID) {
@@ -55,7 +55,7 @@ export default {
const { namespaceID } = this.namespace
this.findChartByID({ chartID, namespaceID, ...params }).then((chart) => {
return this.findChartByID({ chartID, namespaceID, ...params }).then((chart) => {
this.chart = chart
}).catch(this.toastErrorHandler(this.$t('chart.loadFailed')))
},
@@ -82,7 +82,9 @@ export default {
},
refresh () {
this.fetchChart({ force: true })
this.fetchChart({ force: true }).then(() => {
this.key++
})
},
},
@@ -2,6 +2,7 @@
<wrap
v-bind="$props"
v-on="$listeners"
@refreshBlock="refresh"
>
<template #default>
<div
@@ -2,6 +2,7 @@
<wrap
v-bind="$props"
v-on="$listeners"
@refreshBlock="refresh"
>
<div
v-if="processing"
@@ -57,18 +58,18 @@ export default {
},
created () {
this.refreshBlock(this.refresh, true)
this.refreshBlock(this.refresh)
},
methods: {
fetchReport (reportID) {
this.processing = true
this.$SystemAPI.reportRead({ reportID })
return this.$SystemAPI.reportRead({ reportID })
.then(report => {
this.report = new system.Report(report)
this.getDataframes()
return this.getDataframes()
}).catch(this.toastErrorHandler(this.$t('notification:report.fetchFailed')))
.finally(() => {
this.processing = false
@@ -97,7 +98,7 @@ export default {
const { dataframes: frames = [] } = element.reportDefinitions({ ...definition, ...scenarioDefinition })
if (frames.length) {
this.$SystemAPI.reportRun({ frames, reportID: this.options.reportID })
return this.$SystemAPI.reportRun({ frames, reportID: this.options.reportID })
.then(({ frames: dataframes = [] }) => {
this.displayElement = {
...element,
@@ -133,7 +134,9 @@ export default {
},
refresh () {
this.fetchReport(this.options.reportID)
this.fetchReport(this.options.reportID).then(() => {
this.key++
})
},
},
}
@@ -2,7 +2,7 @@
<wrap
v-bind="$props"
v-on="$listeners"
@refreshBlock="key++"
@refreshBlock="refresh"
>
<div
v-if="profile"
@@ -57,7 +57,7 @@ export default {
},
mounted () {
this.refreshBlock(() => {}, true)
this.refreshBlock(this.refresh)
},
methods: {
@@ -109,6 +109,10 @@ export default {
twitterHandle,
}
},
refresh () {
this.key++
},
},
}
</script>
@@ -94,21 +94,14 @@ export default {
/**
*
* @param {*} refreshFunction
* @param {*} forceRerender
* Key is used to force a component to re-render
* However, sometimes reloading data is enough
* Attach :key="key" if you need to re-render a component
*
* If reloading data does not refresh the page block
* You should attach :key="key" to it and increment it in the refreshFunction
*/
refreshBlock (refreshFunction, forceRerender) {
refreshBlock (refreshFunction) {
if (!this.allowsRefresh || this.refreshInterval) return
const interval = setInterval(() => {
refreshFunction()
if (forceRerender) {
this.key++
}
}, this.options.refreshRate * 1000)
this.refreshInterval = interval