Fixes to numeric and date intersection metadata. Adds logic for removing secondary metadatum metaquery from tag. #887.
This commit is contained in:
parent
36aaa845f6
commit
f208741957
|
@ -185,10 +185,15 @@
|
|||
let dateInit = this.dateInit.getUTCFullYear() + '-' +
|
||||
('00' + (this.dateInit.getUTCMonth() + 1)).slice(-2) + '-' +
|
||||
('00' + this.dateInit.getUTCDate()).slice(-2);
|
||||
let dateEnd = this.dateEnd.getUTCFullYear() + '-' +
|
||||
('00' + (this.dateEnd.getUTCMonth() + 1)).slice(-2) + '-' +
|
||||
('00' + this.dateEnd.getUTCDate()).slice(-2);
|
||||
values = [ dateInit, dateEnd ];
|
||||
|
||||
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' ) {
|
||||
|
|
|
@ -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'] ) &&
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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'] ) &&
|
||||
|
|
|
@ -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,11 +125,12 @@
|
|||
taxonomy: tag.taxonomy,
|
||||
metadatumName: this.getMetadatumName(tag),
|
||||
metadatumId: tag.metadatumId,
|
||||
argType: tag.argType
|
||||
argType: tag.argType,
|
||||
secondaryMetadatumId: tag.secondaryMetadatumId
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return flattenTags;
|
||||
}
|
||||
},
|
||||
|
@ -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() {
|
||||
|
|
|
@ -29,7 +29,7 @@ export default {
|
|||
this.updateURLQueries();
|
||||
},
|
||||
removeMetaFromFilterTag(filterTag) {
|
||||
|
||||
|
||||
if (filterTag.singleLabel != undefined || filterTag.label != undefined) {
|
||||
|
||||
if (filterTag.argType !== 'postin') {
|
||||
|
@ -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 {
|
||||
|
|
|
@ -91,13 +91,27 @@ export const removeMetaQuery = ( state, filter ) => {
|
|||
|
||||
let index = state.postquery.metaquery.findIndex( item => item.key == filter.metadatum_id);
|
||||
|
||||
if (index >= 0) {
|
||||
if ( index >= 0 ) {
|
||||
if (!filter.isMultiValue && Array.isArray(state.postquery.metaquery[index].value) && state.postquery.metaquery[index].value.length > 1) {
|
||||
let otherIndex = state.postquery.metaquery[index].value.findIndex(item => item == filter.value);
|
||||
if (otherIndex >= 0)
|
||||
if ( otherIndex >= 0 )
|
||||
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;
|
||||
|
|
Loading…
Reference in New Issue