diff --git a/client/web/reporter/src/components/EditorToolbar.vue b/client/web/reporter/src/components/EditorToolbar.vue index b5c51bd88..151d7ebc1 100644 --- a/client/web/reporter/src/components/EditorToolbar.vue +++ b/client/web/reporter/src/components/EditorToolbar.vue @@ -28,16 +28,27 @@ size="lg" size-confirm="lg" variant="danger" - :disabled="deleteDisabled || processingDelete" + :disabled="deleteDisabled || processingDelete || processing" :processing="processingDelete" :text="$t('general:label.delete')" :borderless="false" @confirmed="$emit('delete')" /> + + diff --git a/client/web/reporter/src/components/ReportSidebar.vue b/client/web/reporter/src/components/ReportSidebar.vue index 2dd63adfb..d94bc299f 100644 --- a/client/web/reporter/src/components/ReportSidebar.vue +++ b/client/web/reporter/src/components/ReportSidebar.vue @@ -72,7 +72,7 @@ export default { return reports.map(({ reportID, handle, meta: { name = '' } }) => { return { - page: { pageID: reportID, name: 'report.view', title: name || handle }, + page: { pageID: reportID, name: this.$route.name, title: name || handle }, params: { reportID }, } }) @@ -90,6 +90,14 @@ export default { }, }, + created () { + this.$root.$on('refetch:reports', this.fetchReports) + }, + + beforeDestroy () { + this.$root.$off('refetch:reports', this.fetchReports) + }, + methods: { fetchReports () { this.$SystemAPI.reportList() diff --git a/client/web/reporter/src/components/faIcons.js b/client/web/reporter/src/components/faIcons.js index 768cd0207..088c1c515 100644 --- a/client/web/reporter/src/components/faIcons.js +++ b/client/web/reporter/src/components/faIcons.js @@ -48,6 +48,7 @@ import { faQuestion, faEllipsisV, faTools, + faClone, } from '@fortawesome/free-solid-svg-icons' import { @@ -112,4 +113,5 @@ library.add( faQuestion, faEllipsisV, faTools, + faClone, ) diff --git a/client/web/reporter/src/components/index.js b/client/web/reporter/src/components/index.js index 39fd9b3dd..519dc4d12 100644 --- a/client/web/reporter/src/components/index.js +++ b/client/web/reporter/src/components/index.js @@ -53,3 +53,4 @@ Vue.component('c-permissions-button', components.CPermissionsButton) Vue.component('c-input-confirm', components.CInputConfirm) Vue.component('c-button-submit', components.CButtonSubmit) Vue.component('c-input-select', components.CInputSelect) +Vue.component('c-form-table-wrapper', components.CFormTableWrapper) diff --git a/client/web/reporter/src/mixins/report.js b/client/web/reporter/src/mixins/report.js index fa8fd2437..054c58868 100644 --- a/client/web/reporter/src/mixins/report.js +++ b/client/web/reporter/src/mixins/report.js @@ -6,6 +6,7 @@ export default { processing: false, processingSave: false, processingDelete: false, + processingClone: false, report: undefined, } }, @@ -21,7 +22,9 @@ export default { }) .catch(this.toastErrorHandler(this.$t('notification:report.fetchFailed'))) .finally(() => { - this.processing = false + setTimeout(() => { + this.processing = false + }, 400) }) }, @@ -90,5 +93,29 @@ export default { this.processingDelete = false }) }, + + handleClone (report) { + this.processing = true + this.processingClone = true + const { meta, sources, blocks, scenarios, labels } = report + const cloneSuffix = `${meta.name} (${this.$t('general:cloneSuffix')})` + let name = meta.name + + if (!this.initialReportState || this.initialReportState.meta.name === name) { + name = cloneSuffix + } + + return this.$SystemAPI.reportCreate({ handle: '', meta: { ...meta, name }, sources, blocks, scenarios, labels }) + .then(report => { + report = new system.Report(report) + this.toastSuccess(this.$t('notification:report.created')) + return report + }) + .catch(this.toastErrorHandler(this.$t('notification:report.createFailed'))) + .finally(() => { + this.processing = false + this.processingClone = false + }) + }, }, } diff --git a/client/web/reporter/src/views/Report/Builder.vue b/client/web/reporter/src/views/Report/Builder.vue index c2651be3e..d8a7fe01d 100644 --- a/client/web/reporter/src/views/Report/Builder.vue +++ b/client/web/reporter/src/views/Report/Builder.vue @@ -2,7 +2,10 @@
- + {{ pageTitle }} @@ -13,10 +16,10 @@ :options="scenarioOptions" :get-option-key="getOptionKey" :placeholder="$t('builder:pick-scenario')" + :disabled="processing || fetchingReport" size="sm" @input="refreshReport()" /> - {{ $t('builder:datasources.label') }} - @@ -72,8 +74,15 @@ +
+ +
+
- - - - - - - - - - - - - - - - -