Bug 34587: Fix titles search in reports viewer
Titles search does not currently work when data from multiple providers is present. This patch allows for titles to be individually fetched per provider 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:
parent
8cc8b2501e
commit
979e9df5e2
|
|
@ -46,7 +46,9 @@
|
|||
provider.erm_usage_data_provider_id
|
||||
"
|
||||
:options="usage_data_providers"
|
||||
@update:modelValue="setReportTypes($event)"
|
||||
@update:modelValue="
|
||||
setReportTypesAndResetTitles($event)
|
||||
"
|
||||
multiple
|
||||
/>
|
||||
</li>
|
||||
|
|
@ -148,7 +150,11 @@
|
|||
:options="titles"
|
||||
multiple
|
||||
@input="titlesSearchFilter($event)"
|
||||
:placeholder="$__('Type to search')"
|
||||
:placeholder="
|
||||
$__(
|
||||
'Type at least two characters to search'
|
||||
)
|
||||
"
|
||||
/>
|
||||
</li>
|
||||
</ol>
|
||||
|
|
@ -195,7 +201,7 @@
|
|||
type="radio"
|
||||
name="yearly_or_monthly"
|
||||
id="yearly_filter_required_yes"
|
||||
@change="month_selector($event)"
|
||||
@change="monthSelector($event)"
|
||||
:checked="yearly_filter_required ? true : false"
|
||||
/>
|
||||
Yes - Table will be limited to 12 columns (Jan-Dec)
|
||||
|
|
@ -209,7 +215,7 @@
|
|||
type="radio"
|
||||
name="yearly_or_monthly"
|
||||
id="yearly_filter_required_no"
|
||||
@change="month_selector($event)"
|
||||
@change="monthSelector($event)"
|
||||
:checked="
|
||||
!yearly_filter_required ? true : false
|
||||
"
|
||||
|
|
@ -245,7 +251,7 @@
|
|||
:key="month + key + i"
|
||||
:checked="true"
|
||||
@change="
|
||||
update_months_required(
|
||||
updateMonthsRequired(
|
||||
$event,
|
||||
key,
|
||||
i,
|
||||
|
|
@ -458,7 +464,7 @@ export default {
|
|||
methods: {
|
||||
async getTitles(query) {
|
||||
const client = APIClient.erm
|
||||
await client.titles.getAll(query).then(
|
||||
await client.usage_titles.getAll(query).then(
|
||||
titles => {
|
||||
// If multiple searches are done we need to keep the results of the
|
||||
// earlier searches but not allow for duplicate titles in the option array
|
||||
|
|
@ -473,13 +479,19 @@ export default {
|
|||
error => {}
|
||||
)
|
||||
},
|
||||
change_custom_or_default(e) {
|
||||
this.initialized = false
|
||||
this.custom_or_default = e.target.getAttribute("data-content")
|
||||
},
|
||||
titlesSearchFilter(e) {
|
||||
const queryString = `title=${e.target.value}`
|
||||
this.getTitles(queryString)
|
||||
if (e.target.value.length > 1) {
|
||||
const providers = this.query.usage_data_providers
|
||||
? this.query.usage_data_providers
|
||||
: []
|
||||
const titlesQueryObject = {
|
||||
title: { "-like": `${e.target.value}%` },
|
||||
...(providers.length && {
|
||||
usage_data_provider_id: providers,
|
||||
}),
|
||||
}
|
||||
this.getTitles(titlesQueryObject)
|
||||
}
|
||||
},
|
||||
validateYear(year) {
|
||||
const validYearCheck = /^\d{4}$/.test(year) ? true : false
|
||||
|
|
@ -544,12 +556,12 @@ export default {
|
|||
const metric_report_type =
|
||||
data_display === "metric_type" ? true : false
|
||||
const url = !data_display.includes("yearly")
|
||||
? this.build_monthly_url_query(
|
||||
? this.buildMonthlyUrlQuery(
|
||||
queryObject,
|
||||
this.time_period_columns_builder,
|
||||
metric_report_type
|
||||
)
|
||||
: this.build_yearly_url_query(queryObject)
|
||||
: this.buildYearlyUrlQuery(queryObject)
|
||||
const type = data_display
|
||||
const columns = this.defineColumns(
|
||||
this.title_property_column_options
|
||||
|
|
@ -570,7 +582,7 @@ export default {
|
|||
name: "UsageStatisticsReportsViewer",
|
||||
})
|
||||
},
|
||||
month_selector(e) {
|
||||
monthSelector(e) {
|
||||
if (!this.query.start_year || !this.query.end_year) {
|
||||
alert(
|
||||
"Please select a start and end year before choosing this option"
|
||||
|
|
@ -587,7 +599,7 @@ export default {
|
|||
years.push(i)
|
||||
}
|
||||
|
||||
const months = this.determine_months(
|
||||
const months = this.determineMonths(
|
||||
this.query,
|
||||
years,
|
||||
this.months_data
|
||||
|
|
@ -600,7 +612,7 @@ export default {
|
|||
this.yearly_filter_required = true
|
||||
}
|
||||
},
|
||||
determine_months(query, years, months_data) {
|
||||
determineMonths(query, years, months_data) {
|
||||
const { start_month, end_month } = query
|
||||
const months_per_year = {}
|
||||
const numberOfYears = years.length
|
||||
|
|
@ -656,18 +668,14 @@ export default {
|
|||
})
|
||||
return months_per_year
|
||||
},
|
||||
update_months_required($event, key, index, time_period_columns) {
|
||||
updateMonthsRequired($event, key, index, time_period_columns) {
|
||||
const value = $event.target.checked
|
||||
|
||||
time_period_columns[key][index].active = value
|
||||
|
||||
this.time_period_columns_builder = time_period_columns
|
||||
},
|
||||
build_monthly_url_query(
|
||||
query,
|
||||
time_period_columns,
|
||||
metric_type_report
|
||||
) {
|
||||
buildMonthlyUrlQuery(query, time_period_columns, metric_type_report) {
|
||||
let url = metric_type_report
|
||||
? "/api/v1/erm/usage_titles/metric_types_report"
|
||||
: "/api/v1/erm/usage_titles/monthly_report"
|
||||
|
|
@ -688,7 +696,7 @@ export default {
|
|||
|
||||
const months = time_period_columns
|
||||
? time_period_columns
|
||||
: this.determine_months(query, years, this.months_data)
|
||||
: this.determineMonths(query, years, this.months_data)
|
||||
this.time_period_columns_builder = months
|
||||
|
||||
// Build a query array by year - [{ year1 }, {year2} ...etc]
|
||||
|
|
@ -729,7 +737,7 @@ export default {
|
|||
|
||||
return url
|
||||
},
|
||||
build_yearly_url_query(query) {
|
||||
buildYearlyUrlQuery(query) {
|
||||
let url = "/api/v1/erm/usage_titles/yearly_report"
|
||||
const {
|
||||
start_year,
|
||||
|
|
@ -810,7 +818,7 @@ export default {
|
|||
this.query.metric_types = null
|
||||
}
|
||||
},
|
||||
setReportTypes(report_types) {
|
||||
setReportTypesAndResetTitles(report_types) {
|
||||
const permittedReportTypes = []
|
||||
if (report_types.length === 0) {
|
||||
this.report_types_options = this.av_report_types
|
||||
|
|
@ -833,6 +841,8 @@ export default {
|
|||
})
|
||||
})
|
||||
this.report_types_options = permittedReportTypes
|
||||
// If we change/remove a data provider then we don't want titles being displayed from that provider in the dropdown
|
||||
this.titles.length = 0
|
||||
},
|
||||
defineColumns(title_props) {
|
||||
const columns = [
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
href="#"
|
||||
role="tab"
|
||||
data-content="default"
|
||||
@click="change_custom_or_default"
|
||||
@click="changeCustomOrDefault"
|
||||
>Default</a
|
||||
>
|
||||
</li>
|
||||
|
|
@ -28,7 +28,7 @@
|
|||
href="#"
|
||||
role="tab"
|
||||
data-content="custom"
|
||||
@click="change_custom_or_default"
|
||||
@click="changeCustomOrDefault"
|
||||
>Custom</a
|
||||
>
|
||||
</li>
|
||||
|
|
@ -73,31 +73,16 @@
|
|||
|
||||
<script>
|
||||
import { inject } from "vue"
|
||||
import { storeToRefs } from "pinia"
|
||||
import ButtonSubmit from "../ButtonSubmit.vue"
|
||||
import { APIClient } from "../../fetch/api-client.js"
|
||||
import UsageStatisticsReportBuilder from "./UsageStatisticsReportBuilder.vue"
|
||||
|
||||
export default {
|
||||
setup() {
|
||||
// const AVStore = inject("AVStore")
|
||||
// const {
|
||||
// av_report_types,
|
||||
// av_platform_reports_metrics,
|
||||
// av_database_reports_metrics,
|
||||
// av_title_reports_metrics,
|
||||
// av_item_reports_metrics,
|
||||
// } = storeToRefs(AVStore)
|
||||
|
||||
const { setConfirmationDialog, setMessage, setError } =
|
||||
inject("mainStore")
|
||||
|
||||
return {
|
||||
// av_report_types,
|
||||
// av_platform_reports_metrics,
|
||||
// av_database_reports_metrics,
|
||||
// av_title_reports_metrics,
|
||||
// av_item_reports_metrics,
|
||||
setConfirmationDialog,
|
||||
setMessage,
|
||||
setError,
|
||||
|
|
@ -126,79 +111,6 @@ export default {
|
|||
"Titles",
|
||||
// etc etc
|
||||
],
|
||||
// metric_types_matrix: {
|
||||
// Searches_Platform: ["PR", "PR_P1"],
|
||||
// Searches_Automated: ["DR", "DR_D1"],
|
||||
// Searches_Federated: ["DR", "DR_D1"],
|
||||
// Searches_Regular: ["DR", "DR_D1"],
|
||||
// Total_Item_Investigations: [
|
||||
// "PR",
|
||||
// "DR",
|
||||
// "DR_D1",
|
||||
// "TR",
|
||||
// "TR_B3",
|
||||
// "TR_J3",
|
||||
// "IR",
|
||||
// ],
|
||||
// Total_Item_Requests: [
|
||||
// "PR",
|
||||
// "PR_P1",
|
||||
// "DR",
|
||||
// "DR_D1",
|
||||
// "TR",
|
||||
// "TR_B1",
|
||||
// "TR_B3",
|
||||
// "TR_J1",
|
||||
// "TR_J3",
|
||||
// "TR_J4",
|
||||
// "IR",
|
||||
// "IR_A1",
|
||||
// "IR_M1",
|
||||
// ],
|
||||
// Unique_Item_Investigations: [
|
||||
// "PR",
|
||||
// "DR",
|
||||
// "TR",
|
||||
// "TR_B3",
|
||||
// "TR_J3",
|
||||
// "IR",
|
||||
// ],
|
||||
// Unique_Item_Requests: [
|
||||
// "PR",
|
||||
// "PR_P1",
|
||||
// "DR",
|
||||
// "TR",
|
||||
// "TR_B1",
|
||||
// "TR_B3",
|
||||
// "TR_J1",
|
||||
// "TR_J3",
|
||||
// "TR_J4",
|
||||
// "IR",
|
||||
// "IR_A1",
|
||||
// ],
|
||||
// Unique_Title_Investigations: ["PR", "DR", "TR", "TR_B3"],
|
||||
// Unique_Title_Requests: ["PR", "PR_P1", "DR", "TR", "TR_B3"],
|
||||
// Limit_Exceeded: ["DR", "DR_D2", "TR", "TR_B2", "TR_J2", "IR"],
|
||||
// No_License: ["DR", "DR_D2", "TR", "TR_B2", "TR_J2", "IR"],
|
||||
// },
|
||||
// metric_types_options: null,
|
||||
// months: [
|
||||
// { short: "Jan", description: "January", value: 1 },
|
||||
// { short: "Feb", description: "February", value: 2 },
|
||||
// { short: "Mar", description: "March", value: 3 },
|
||||
// { short: "Apr", description: "April", value: 4 },
|
||||
// { short: "May", description: "May", value: 5 },
|
||||
// { short: "Jun", description: "June", value: 6 },
|
||||
// { short: "Jul", description: "July", value: 7 },
|
||||
// { short: "Aug", description: "August", value: 8 },
|
||||
// { short: "Sep", description: "September", value: 9 },
|
||||
// { short: "Oct", description: "October", value: 10 },
|
||||
// { short: "Nov", description: "November", value: 11 },
|
||||
// { short: "Dec", description: "December", value: 12 },
|
||||
// ],
|
||||
// years: ["2022", "2023"],
|
||||
// titles: [],
|
||||
// usage_data_providers: [],
|
||||
}
|
||||
},
|
||||
beforeRouteEnter(to, from, next) {
|
||||
|
|
@ -227,8 +139,7 @@ export default {
|
|||
error => {}
|
||||
)
|
||||
},
|
||||
change_custom_or_default(e) {
|
||||
this.initialized = false
|
||||
changeCustomOrDefault(e) {
|
||||
this.custom_or_default = e.target.getAttribute("data-content")
|
||||
},
|
||||
displayDefaultReport(e) {
|
||||
|
|
@ -247,19 +158,4 @@ export default {
|
|||
.rows {
|
||||
float: none;
|
||||
}
|
||||
/* .report-builder {
|
||||
display: flex;
|
||||
}
|
||||
.custom-report {
|
||||
width: 50%;
|
||||
align-items: left;
|
||||
}
|
||||
.custom-report .v-select,
|
||||
input {
|
||||
width: 50%;
|
||||
min-width: 50%;
|
||||
}
|
||||
.default-report {
|
||||
width: 50%;
|
||||
} */
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -288,7 +288,7 @@ export class ERMAPIClient extends HttpClient {
|
|||
};
|
||||
}
|
||||
|
||||
get titles() {
|
||||
get usage_titles() {
|
||||
return {
|
||||
get: (id) =>
|
||||
this.get({
|
||||
|
|
@ -299,7 +299,7 @@ export class ERMAPIClient extends HttpClient {
|
|||
},
|
||||
}),
|
||||
getAll: (query) =>
|
||||
this.get({
|
||||
this.getAll({
|
||||
endpoint: "usage_titles",
|
||||
query
|
||||
}),
|
||||
|
|
@ -312,6 +312,16 @@ export class ERMAPIClient extends HttpClient {
|
|||
`${embed}`,
|
||||
},
|
||||
}),
|
||||
count: (query = {}) =>
|
||||
this.count({
|
||||
endpoint:
|
||||
"usage_titles?" +
|
||||
new URLSearchParams({
|
||||
_page: 1,
|
||||
_per_page: 1,
|
||||
...(query && { q: JSON.stringify(query) }),
|
||||
}),
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue