[angular-16-irish-monitor | DONE | REMOVED] SearchCustomFilter: remove promptToAddFilter field, and code to add and remove filter

This commit is contained in:
argirok 2023-11-09 16:11:12 +02:00
parent a773cd8d1d
commit ce8b104c20
3 changed files with 6 additions and 78 deletions

View File

@ -4,9 +4,7 @@
<div [class.uk-invisible]="list.children.length === 0" class="uk-position-relative">
<div class="uk-slider-container">
<ul #list class="uk-slider-items uk-grid uk-grid-small uk-margin-small-right uk-flex-nowrap" style="padding-bottom: 1px">
<ng-container *ngIf="customFilter && ((customFilterEnabled &&
refineFields.indexOf(customFilter.queryFieldName) ==
-1) ||customFilter.isHiddenFilter)">
<ng-container *ngIf="customFilter && (customFilter.isHiddenFilter)">
<li class="uk-flex uk-flex-middle">
<span class="uk-label uk-label-secondary uk-text-truncate">
{{customFilter.valueName}}
@ -272,13 +270,7 @@
</div>
<div class="uk-width-expand@m uk-with-1-1@s">
<div [class.uk-padding-small]="mobile" class="uk-padding-remove-vertical">
<!-- Results only for Custom Filter? -->
<div *ngIf="customFilter && !customFilter.isHiddenFilter &&
customFilter.selected == false && customFilter.promptToAddFilter"
class="uk-alert uk-animation-slide-top-small">
Do you want to see results only for {{customFilter.valueName}}? <a
(click)="addCustomFilter();">Click here</a>.
</div>
<!-- Related results for Custom Filter Alert -->
<div *ngIf="openaireLink && (searchUtils.totalResults > 0 || !loadPaging )"
class="uk-alert uk-margin-small-top ">
@ -399,4 +391,3 @@
<div *ngIf="isMobile || isServer" class="uk-hidden@m">
<ng-container *ngTemplateOutlet="main; context: {mobile: true}"></ng-container>
</div>
<modal-alert #removeCustomFilter (alertOutput)="closeCustomFilterModal()"></modal-alert>

View File

@ -138,11 +138,9 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges {
//Dashboard
filterToggle = false;
customFilterEnabled: boolean = false;
//stickyform
@Input() stickyForm: boolean = false;
@ViewChild('removeCustomFilter') removeCustomFilter: AlertModal;
currentValueToRemove;
currentFilterToRemove;
public indexUpdateDate: Date;
@ -185,7 +183,6 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges {
if (params['page'] && params['page'] != 1) {
HelperFunctions.scrollToId("searchForm");
}
this.customFilterEnabled = params['cf'] && params['cf'] == "true";
if (this.basicMetaDescription.length == 0) {
if (this.entityType == "result") {
this.basicMetaDescription = [OpenaireEntities.RESULTS, "Discover" + (this.properties.adminToolsCommunity == 'openaire' ? " over 100 million of" : "") + " "+OpenaireEntities.RESULTS+" ", "categorized by research type, year range, funder, languages, "+OpenaireEntities.COMMUNITY+" and "+OpenaireEntities.DATASOURCES+"."];
@ -644,10 +641,6 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges {
public removeFilter(value: Value, filter: Filter, forceRemove: boolean = false) {
this.currentValueToRemove = value;
this.currentFilterToRemove = filter;
if (!forceRemove && this.customFilter && this.customFilter.queryFieldName == filter.filterId && this.customFilter.valueId == value.id && this.customFilter.promptToAddFilter) {
this.openRemoveCustomFilterModal();
return;
}
filter.countSelectedValues--;
this.selectedFilters--;
if (value.selected == true) {
@ -662,19 +655,6 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges {
this.goTo(1);
}
public openRemoveCustomFilterModal() {
this.removeCustomFilter.alertTitle = 'Remove filter';
this.removeCustomFilter.message = 'You are about to see results that are not related to ' + this.customFilter.valueName + '. Do you want to proceed?';
this.removeCustomFilter.okButtonText = 'Yes';
this.removeCustomFilter.cancelButtonText = 'No';
this.removeCustomFilter.open();
}
closeCustomFilterModal() {
this.customFilterEnabled = false;
this.removeFilter(this.currentValueToRemove, this.currentFilterToRemove, true);
}
public removeRangeFilter(filter: RangeFilter) {
filter.selectedFromValue = null;
filter.selectedToValue = null;
@ -718,41 +698,6 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges {
}
}*/
/**
* Set selected the value of the custom filter.
*/
addCustomFilter() {
this.customFilter.selected = true;
this.customFilterEnabled = true;
if (this.refineFields.indexOf(this.customFilter.queryFieldName) != -1) {
let found = false;
for (let filter of this.filters) {
if (this.customFilter.queryFieldName == filter.filterId) {
for (let value of filter.values) {
if (value.id == this.customFilter.valueId) {
value.selected = true;
filter.countSelectedValues++;
found = true;
break;
}
}
//add filter when field exist in refine but not in the refine values
if (!found) {
filter.countSelectedValues++;
filter.values.push({
selected: true,
name: this.customFilter.valueName,
id: this.customFilter.valueId,
number: 0
});
}
break;
}
}
}
this.filterChanged(null);
}
// for loading
public openLoading() {
@ -1112,8 +1057,7 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges {
allFqs += fq;
}
}
this.customFilterEnabled = URLparams["cf"] == "true";
if (this.customFilter && (this.customFilter.isHiddenFilter || this.customFilterEnabled)) {
if (this.customFilter && (this.customFilter.isHiddenFilter)) {
allFqs += "&fq=" + StringUtils.URIEncode(this.customFilter.queryFieldName + " exact " + StringUtils.quote((this.customFilter.valueId)));
}
@ -1456,11 +1400,6 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges {
this.parameterValues.push(this.searchUtils.keyword);
}
if (this.customFilterEnabled) {
this.parameterNames.push("cf");
this.parameterValues.push("true");
}
// if (this.searchUtils.size != this.resultsPerPage) {
// // allLimits += ((allLimits.length == 0) ? '?' : '&') + 'size=' + this.searchUtils.size;
// this.parameterNames.push("size");

View File

@ -27,7 +27,6 @@ export class SearchCustomFilter{
valueName:string; // Greece
isHiddenFilter:boolean;
selected:boolean;
promptToAddFilter:boolean;
constructor( fieldName:string, queryFieldName:string, valueId:string, valueName:string ){
if(valueId == "test" && properties.environment == "development"){
valueId = "covid-19";
@ -38,7 +37,6 @@ export class SearchCustomFilter{
this.valueId = valueId;
this.valueName = valueName;
this.selected = null;
this.promptToAddFilter = false;
}
public getParameters(params={}){