Fixes to numeric and date intersection metadata. Adds logic for removing secondary metadatum metaquery from tag. #887.

This commit is contained in:
mateuswetah 2024-06-12 09:00:47 -03:00
parent 94a60a1a86
commit 710e3c50ed
7 changed files with 57 additions and 17 deletions

View File

@ -185,10 +185,15 @@
let dateInit = this.dateInit.getUTCFullYear() + '-' +
('00' + (this.dateInit.getUTCMonth() + 1)).slice(-2) + '-' +
('00' + this.dateInit.getUTCDate()).slice(-2);
if ( this.dateEnd !== null ) {
let dateEnd = this.dateEnd.getUTCFullYear() + '-' +
('00' + (this.dateEnd.getUTCMonth() + 1)).slice(-2) + '-' +
('00' + this.dateEnd.getUTCDate()).slice(-2);
values = [ dateInit, dateEnd ];
} else {
values = [ dateInit ];
}
}
if ( this.filterTypeOptions.accept_date_interval !== 'yes' ) {

View File

@ -116,6 +116,13 @@ class Dates_Intersection_Interval_Helper {
) {
$filter_arguments['label'] = $filter_arguments['label'][0] . ' - ' . $filter_arguments['label'][1];
}
if (
isset( $filter_arguments['filter'] ) &&
isset( $filter_arguments['filter']['metadatum'] ) &&
isset( $filter_arguments['filter']['metadatum']['metadatum_name'] )
) {
$filter_arguments['filter']['name'] = $filter_arguments['filter']['metadatum']['metadatum_name'];
}
if (
isset( $filter_arguments['filter'] ) &&
isset( $filter_arguments['filter']['filter_type_options'] ) &&

View File

@ -101,7 +101,7 @@
compare: this.filterTypeOptions.first_comparator,
metadatum_id: this.metadatumId,
collection_id: this.collectionId,
value: this.filterTypeOptions.accept_numeric_interval === 'yes' ? values : values[0]
value: values[0]
});
this.$emit('input', {
filter: 'intersection',
@ -109,7 +109,8 @@
compare: this.filterTypeOptions.second_comparator,
metadatum_id: this.filterTypeOptions.secondary_filter_metadatum_id,
collection_id: this.collectionId,
value: this.filterTypeOptions.accept_numeric_interval === 'yes' ? values : values[0]
value: values[0],
secondary: true
});
} else {
// Much more complicated logic to be implemented in the future. See #889

View File

@ -127,6 +127,13 @@ class Numerics_Intersection_Interval_Helper {
) {
$filter_arguments['label'] = $filter_arguments['label'][0] . ' - ' . $filter_arguments['label'][1];
}
if (
isset( $filter_arguments['filter'] ) &&
isset( $filter_arguments['filter']['metadatum'] ) &&
isset( $filter_arguments['filter']['metadatum']['metadatum_name'] )
) {
$filter_arguments['filter']['name'] = $filter_arguments['filter']['metadatum']['metadatum_name'];
}
if (
isset( $filter_arguments['filter'] ) &&
isset( $filter_arguments['filter']['filter_type_options'] ) &&

View File

@ -113,7 +113,8 @@
taxonomy: tag.taxonomy,
metadatumName: this.getMetadatumName(tag),
metadatumId: tag.metadatumId,
argType: tag.argType
argType: tag.argType,
secondaryMetadatumId: tag.secondaryMetadatumId
});
}
} else {
@ -124,7 +125,8 @@
taxonomy: tag.taxonomy,
metadatumName: this.getMetadatumName(tag),
metadatumId: tag.metadatumId,
argType: tag.argType
argType: tag.argType,
secondaryMetadatumId: tag.secondaryMetadatumId
});
}
});
@ -168,7 +170,7 @@
...mapGetters('search',[
'getFilterTags'
]),
removeMetaQuery({ filterId, value, singleLabel, label, taxonomy, metadatumId, metadatumName, argType }) {
removeMetaQuery({ filterId, value, singleLabel, label, taxonomy, metadatumId, metadatumName, argType, secondaryMetadatumId }) {
this.$eventBusSearch.resetPageOnStore();
this.$eventBusSearch.removeMetaFromFilterTag({
filterId: filterId,
@ -178,7 +180,8 @@
taxonomy: taxonomy,
metadatumId: metadatumId,
metadatumName:metadatumName,
argType: argType
argType: argType,
secondaryMetadatumId: secondaryMetadatumId
});
},
clearAllFilters() {

View File

@ -39,7 +39,8 @@ export default {
label: filterTag.singleLabel ? filterTag.singleLabel : filterTag.label,
isMultiValue: filterTag.singleLabel ? false : true,
taxonomy: filterTag.taxonomy,
value: filterTag.value
value: filterTag.value,
secondaryMetadatumId: filterTag.secondaryMetadatumId
});
} else {
app.config.globalProperties.$store.dispatch('search/removeMetaQuery', {
@ -47,7 +48,8 @@ export default {
label: filterTag.singleLabel ? filterTag.singleLabel : filterTag.label,
isMultiValue: filterTag.singleLabel ? false : true,
metadatum_id: filterTag.metadatumId,
value: filterTag.value
value: filterTag.value,
secondaryMetadatumId: filterTag.secondaryMetadatumId
});
}
} else {

View File

@ -98,6 +98,20 @@ export const removeMetaQuery = ( state, filter ) => {
state.postquery.metaquery[index].value.splice(otherIndex, 1)
} else
state.postquery.metaquery.splice(index, 1);
console.log(filter)
// Handles removing metaqueries from secondary filter metadata
if ( filter.secondaryMetadatumId ) {
let secondaryIndex = state.postquery.metaquery.findIndex( item => item.key == filter.secondaryMetadatumId);
if ( secondaryIndex >= 0 ) {
if ( !filter.isMultiValue && Array.isArray(state.postquery.metaquery[secondaryIndex].value) && state.postquery.metaquery[secondaryIndex].value.length > 1 ) {
let otherSecondaryIndex = state.postquery.metaquery[secondaryIndex].value.findIndex(item => item == filter.value);
if ( otherSecondaryIndex >= 0 )
state.postquery.metaquery[secondaryIndex].value.splice(otherSecondaryIndex, 1)
} else
state.postquery.metaquery.splice(secondaryIndex, 1);
}
}
}
};
@ -188,7 +202,8 @@ export const setFilterTags = ( state, filterArguments ) => {
) ? aFilterArgument.metadatum.metadata_type_object.options.taxonomy : '',
argType: aFilterArgument.arg_type ? aFilterArgument.arg_type : '',
metadatumId: (aFilterArgument.filter && aFilterArgument.metadatum.metadatum_id) ? aFilterArgument.metadatum.metadatum_id : (aFilterArgument.metadatum.id || ''),
metadatumName: (aFilterArgument.filter && aFilterArgument.filter.name) ? aFilterArgument.filter.name : (aFilterArgument.metadatum.name || '')
metadatumName: (aFilterArgument.filter && aFilterArgument.filter.name) ? aFilterArgument.filter.name : (aFilterArgument.metadatum.name || ''),
secondaryMetadatumId: (aFilterArgument.filter && aFilterArgument.filter.filter_type_options && aFilterArgument.filter.filter_type_options.secondary_filter_metadatum_id) ? aFilterArgument.filter.filter_type_options.secondary_filter_metadatum_id : '',
}
});
state.filter_tags = filterTags;