From a6fe33a4c4fe7721624cfdf0c50d821652a9fee2 Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Tue, 20 Jun 2023 16:28:01 +0000 Subject: [PATCH] Bug 34587: Move column options into reports store to tidy up url params Signed-off-by: Jessica Zairo Signed-off-by: Michaela Sieber Signed-off-by: Nick Clemens Signed-off-by: Tomas Cohen Arazi --- .../ERM/UsageStatisticsReportBuilder.vue | 78 +---------------- .../ERM/UsageStatisticsReportsViewer.vue | 13 ++- .../prog/js/vue/stores/usage-reports.js | 84 ++++++++++++++++++- 3 files changed, 97 insertions(+), 78 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/UsageStatisticsReportBuilder.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/UsageStatisticsReportBuilder.vue index 3900b65c69..810ce0d324 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/UsageStatisticsReportBuilder.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/UsageStatisticsReportBuilder.vue @@ -314,9 +314,10 @@ export default { const { setConfirmationDialog, setMessage, setError } = inject("mainStore") - const { getMonthsData } = inject("reportsStore") + const { getMonthsData, getColumnOptions } = inject("reportsStore") const months_data = getMonthsData() + const title_property_column_options = getColumnOptions() return { av_report_types, @@ -328,82 +329,11 @@ export default { setMessage, setError, months_data, + title_property_column_options, } }, data() { return { - title_property_column_options: { - provider_name: { - name: "Provider name", - active: true, - column: { - title: __("Data provider"), - data: "provider_name", - searchable: true, - orderable: true, - }, - }, - publisher: { - name: "Publisher", - active: false, - column: { - title: __("Publisher"), - data: "publisher", - searchable: true, - orderable: true, - }, - }, - publisher_id: { - name: "Publisher ID", - active: false, - column: { - title: __("Publisher ID"), - data: "publisher_id", - searchable: true, - orderable: true, - }, - }, - online_issn: { - name: "Online ISSN", - active: false, - column: { - title: __("Online ISSN"), - data: "online_issn", - searchable: true, - orderable: true, - }, - }, - print_issn: { - name: "Print ISSN", - active: false, - column: { - title: __("Print ISSN"), - data: "print_issn", - searchable: true, - orderable: true, - }, - }, - title_doi: { - name: "DOI", - active: false, - column: { - title: __("DOI"), - data: "title_doi", - searchable: true, - orderable: true, - }, - }, - title_uri: { - name: "URI", - active: false, - column: { - title: __("URI"), - data: "title_uri", - searchable: true, - orderable: true, - }, - }, - }, query: { data_display: "monthly", report_type: null, @@ -842,7 +772,7 @@ export default { const title_properties = Object.keys(title_props) title_properties.forEach(prop => { if (title_props[prop].active) { - columns.push(title_props[prop].column) + columns.push(title_props[prop].id) } }) diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/UsageStatisticsReportsViewer.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/UsageStatisticsReportsViewer.vue index 1db72386bf..c953e46bd0 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/UsageStatisticsReportsViewer.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/UsageStatisticsReportsViewer.vue @@ -31,10 +31,11 @@ export default { setup() { const table = ref() - const { getMonthsData } = inject("reportsStore") + const { getMonthsData, getColumnOptions } = inject("reportsStore") return { getMonthsData, + getColumnOptions, table, } }, @@ -87,12 +88,18 @@ export default { methods: { buildColumnArray(report_type, params) { const columns = params.columns - const months_data = this.getMonthsData() // + const months_data = this.getMonthsData() + const column_options = this.getColumnOptions() const time_period_columns = params.tp_columns const yearly_filter = params.yearly_filter const query = params.queryObject + const column_set = [] - const column_set = [...columns] + columns.forEach(column => { + column_set.push(column_options[column].column) + // Reset all columns except data providers to inactive + if (column !== 1) column_options[column].active = false + }) report_type !== "usage_data_provider" && column_set.unshift({ diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/stores/usage-reports.js b/koha-tmpl/intranet-tmpl/prog/js/vue/stores/usage-reports.js index c80f248bc2..4942ccb10a 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/stores/usage-reports.js +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/stores/usage-reports.js @@ -16,11 +16,93 @@ export const useReportsStore = defineStore('reports', { { short: "Nov", description: "November", value: 11, active: true }, { short: "Dec", description: "December", value: 12, active: true }, ], - query: null + query: null, + title_property_column_options: { + 1: { + id: 1, + name: "Provider name", + active: true, + column: { + title: __("Data provider"), + data: "provider_name", + searchable: true, + orderable: true, + }, + }, + 2: { + id: 2, + name: "Publisher", + active: false, + column: { + title: __("Publisher"), + data: "publisher", + searchable: true, + orderable: true, + }, + }, + 3: { + id: 3, + name: "Publisher ID", + active: false, + column: { + title: __("Publisher ID"), + data: "publisher_id", + searchable: true, + orderable: true, + }, + }, + 4: { + id: 4, + name: "Online ISSN", + active: false, + column: { + title: __("Online ISSN"), + data: "online_issn", + searchable: true, + orderable: true, + }, + }, + 5: { + id: 5, + name: "Print ISSN", + active: false, + column: { + title: __("Print ISSN"), + data: "print_issn", + searchable: true, + orderable: true, + }, + }, + 6: { + id: 6, + name: "DOI", + active: false, + column: { + title: __("DOI"), + data: "title_doi", + searchable: true, + orderable: true, + }, + }, + 7: { + id: 7, + name: "URI", + active: false, + column: { + title: __("URI"), + data: "title_uri", + searchable: true, + orderable: true, + }, + }, + }, }), actions: { getMonthsData() { return this.months_data }, + getColumnOptions() { + return this.title_property_column_options + } } }) \ No newline at end of file -- 2.20.1