[develop | DONE | FIXED]: [BUG FIX] Moved checks for filtering out filter values in parsing phase.

1. refineResults.class.ts:
   a. Updated method "includeValue()" and include "null" (as a string) check | Call method "includeValue()" when creating filters.
   b. Set filter.countUnfilteredValues to the length of values returned by the service before filtering them out.
   c. Check if filters returned by service before trying to parse anything.
2. searchHelperClasses.class.ts: Added in Filter structure the field "public countUnfilteredValues?: number = 0;", to check if there are more values to be queried (show "view all" link or not).
3. searchFilter.component.ts: Updated check of hasMoreValues to show or not the "view all" link - check filter.countUnfilteredValues | Comment filtering out of filter values - moved to refineResults.class.ts.
This commit is contained in:
Konstantina Galouni 2024-02-07 15:55:56 +02:00
parent 514e92b177
commit f45598b190
3 changed files with 15 additions and 8 deletions

View File

@ -84,9 +84,11 @@ export class SearchFilterComponent implements OnInit, OnChanges {
ngOnChanges(changes: SimpleChanges) {
if (changes.filter) {
this.hasMoreValues = this.filter.values.length > this.filterValuesNum;
this.hasMoreValues = (this.filter.countUnfilteredValues > 0 ? this.filter.countUnfilteredValues : this.filter.values.length) > this.filterValuesNum;
// this.filter.values = this.filter.values.filter(value => !value.name.toLowerCase().includes('unknown') && !value.name.toLowerCase().includes('not available'));
this.filter.values = this.filter.values.filter(value => value && value.name != "unidentified" && value.name != "Undetermined" && !value.name.toLowerCase().includes('unknown') && !value.name.toLowerCase().includes('not available'));
// this.filter.values = this.filter.values.filter(value => value && value.name != "unidentified" && value.name != "Undetermined" && !value.name.toLowerCase().includes('unknown') && !value.name.toLowerCase().includes('not available')
// && value.name.toLowerCase() != "null"
// );
if (this.filter.filterType == "radio") {
this.filter.radioValue = "";

View File

@ -13,6 +13,7 @@ export class Filter{
// public uniqueValueIdSelected: string;
public countAllValues?: number = -1; // -1: not yet requested, 0: request failed, >0 OK
public isOpen?: boolean = false;
public countUnfilteredValues?: number = 0;
}
export class Value{

View File

@ -11,7 +11,7 @@ export class RefineResultsUtils {
var searchFields:SearchFields = new SearchFields();
var filters:Filter[] = [];
if(data && fields){
if(data && Object.keys(data).length > 0 && fields){
for(let j=0; j<fields.length; j++) {
var filter:Filter = new Filter();
@ -27,15 +27,16 @@ export class RefineResultsUtils {
let field = data[fields[j]];
if(field){
filter.countUnfilteredValues = field.length;
for(let i=0; i<field.length; i++) {
var value:Value = new Value();
value.name = field[i].name;
value.name =this.removePartAfterCharacters(value,"||");
value.number = field[i].count;
value.id = field[i].id;
//if(RefineResultsUtils.includeValue(value)){
if(RefineResultsUtils.includeValue(value)){
filter.values.push(value);
//}
}
}
@ -51,11 +52,14 @@ export class RefineResultsUtils {
return filters;
}
private static includeValue (field):boolean {
if( !field || !field.name || field.name == "unidentified" || field.name == "Undetermined" ){
return false;
// if( !field || !field.name || field.name == "unidentified" || field.name == "Undetermined" ){
if( field && field.name && field.name != "unidentified" && field.name != "Undetermined"
&& !field.name.toLowerCase().includes('unknown') && !field.name.toLowerCase().includes('not available')
&& field.name.toLowerCase() != "null") {
return true;
}
return true;
return false;
}
private static removePartAfterCharacters(field, characters):string {
if( field.name.indexOf(characters) !=-1){