Bug 34587: Make column options dependent on data_type

In the reports builder you can select which columns you would like to display in a report. Not all columns are applicable to all data types so it needs limiting to only be selectable if that column is available for that data type

Signed-off-by: Jessica Zairo <jzairo@bywatersolutions.com>
Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Matt Blenkinsop 2023-08-03 16:45:41 +00:00 committed by Tomas Cohen Arazi
parent 6225966b8d
commit 1ad9959fa5
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F
2 changed files with 47 additions and 11 deletions

View file

@ -204,17 +204,20 @@
class="checkbox_options"
>
<!-- TODO: Check translations -->
<label :for="prop.property" class="checkbox"
<label :for="prop.name" class="checkbox"
>{{ $__(prop.name) }}:</label
>
<input
type="checkbox"
:name="prop.property"
:id="prop.property"
:name="prop.name"
:id="prop.name"
:checked="true"
v-model="
title_property_column_options[key].active
"
:disabled="
!prop.used_by.includes(this.data_type)
"
/>
</li>
</ol>
@ -788,6 +791,20 @@ export default {
return single_report_types.includes(report_type)
})
// Unselect any additional columns that aren't applicable to this data_type
const title_properties = Object.keys(
this.title_property_column_options
)
title_properties.shift() // Remove the first column as this is a default
title_properties.forEach(prop => {
if (
!this.title_property_column_options[
prop
].used_by.includes(this.data_type)
) {
this.title_property_column_options[prop].active = false
}
})
} else {
this.metric_types_options = []
this.query.metric_types = null

View file

@ -22,6 +22,7 @@ export const useReportsStore = defineStore('reports', {
id: 1,
name: "Provider name",
active: true,
used_by: ["title", "item", "database", 'platform'],
column: {
title: __("Data provider"),
data: "provider_name",
@ -33,6 +34,7 @@ export const useReportsStore = defineStore('reports', {
id: 2,
name: "Publisher",
active: false,
used_by: ["title", "item", "database"],
column: {
title: __("Publisher"),
data: "publisher",
@ -42,8 +44,21 @@ export const useReportsStore = defineStore('reports', {
},
3: {
id: 3,
name: "Platform",
active: false,
used_by: ["item", "database", "platforms"],
column: {
title: __("Platform"),
data: "platform",
searchable: true,
orderable: true,
},
},
4: {
id: 4,
name: "Publisher ID",
active: false,
used_by: ["title", "database"],
column: {
title: __("Publisher ID"),
data: "publisher_id",
@ -51,10 +66,11 @@ export const useReportsStore = defineStore('reports', {
orderable: true,
},
},
4: {
id: 4,
5: {
id: 5,
name: "Online ISSN",
active: false,
used_by: ["title"],
column: {
title: __("Online ISSN"),
data: "online_issn",
@ -62,10 +78,11 @@ export const useReportsStore = defineStore('reports', {
orderable: true,
},
},
5: {
id: 5,
6: {
id: 6,
name: "Print ISSN",
active: false,
used_by: ["title"],
column: {
title: __("Print ISSN"),
data: "print_issn",
@ -73,10 +90,11 @@ export const useReportsStore = defineStore('reports', {
orderable: true,
},
},
6: {
id: 6,
7: {
id: 7,
name: "DOI",
active: false,
used_by: ["title"],
column: {
title: __("DOI"),
data: "title_doi",
@ -84,10 +102,11 @@ export const useReportsStore = defineStore('reports', {
orderable: true,
},
},
7: {
id: 7,
8: {
id: 8,
name: "URI",
active: false,
used_by: ["title"],
column: {
title: __("URI"),
data: "title_uri",