[Library | new-theme]: Sorted Advanced filters alphabetically | Added "pid" in advanced filters for Datasource | Organization lannding: projects tab: Added number of selected values in funder filter.

1. projects-in-modal.component.ts: Added the missing number of selected values next to the filter name - on updateFilters() method, update filter.countSelectedValues.
2. searchFields.ts:
   a. Added pid in  DATASOURCE_ADVANCED_FIELDS.
   b. Added method "sortFieldsByName()" to sort fields by name and leave "q" filter (Any field) first.
3. searchAll.component.ts & searchDataProviders.component.ts & searchResearchResults.component.ts & searchProjects.component.ts & searchOrganizations.component.ts: Added "this.searchFields.sortFieldsByName(this.fieldIds, this.fieldIdsMap);" to sort advanced fields alphabetically.
This commit is contained in:
Konstantina Galouni 2022-06-23 17:30:45 +03:00
parent d12138bc2a
commit 428a48223a
7 changed files with 28 additions and 6 deletions

View File

@ -18,7 +18,7 @@ import {OpenaireEntities} from '../../utils/properties/searchFields';
<ng-container *ngFor="let filter of fetchProjects.filters">
<div class="uk-inline">
<button class="uk-button uk-button-default uk-button-small uk-margin-small-bottom" type="button">
{{filter.title}} <span uk-icon="chevron-down"></span>
{{filter.title}}<span *ngIf="filter.countSelectedValues>0"> ({{filter.countSelectedValues}})</span> <span uk-icon="chevron-down"></span>
</button>
<div uk-dropdown="mode: click" class="uk-width-large uk-overflow-auto" style="max-width:460px !important; ">
<div class="uk-padding-small uk-overflow-auto uk-height-max-large uk-height-min-medium">
@ -111,12 +111,14 @@ export class ProjectsInModalComponent {
private updateFilters() {
this.filterQuery = "";
for (let filter of this.fetchProjects.filters) {
filter.countSelectedValues = 0;
var filterLimits = "";
for (let value of filter.values) {
if (value.selected == true) {
//filterLimits+=((filterLimits.length == 0)?'':',') +'"'+ StringUtils.URIEncode(value.id)+'"';
filterLimits += ((filterLimits.length == 0) ? '' : ' or ') + filter.filterId + ' exact ';
filterLimits += '"' + StringUtils.URIEncode(value.id) + '"';
filter.countSelectedValues++;
}
}
if (filterLimits.length > 0) {

View File

@ -136,6 +136,7 @@ export class SearchAllComponent {
this.fetchSoftware = new FetchResearchResults(this._searchResearchResultsService);
this.fetchOrps = new FetchResearchResults(this._searchResearchResultsService);
this.fetchOrganizations = new FetchOrganizations(this._searchOrganizationsService);
this.searchFields.sortFieldsByName(this.fieldIds, this.fieldIdsMap);
this.selectedFields.push(new AdvancedField(this.fieldIds[0], this.fieldIdsMap[this.fieldIds[0]].param, this.fieldIdsMap[this.fieldIds[0]].name, this.fieldIdsMap[this.fieldIds[0]].type, '', "and"));
}

View File

@ -99,6 +99,8 @@ export class SearchDataProvidersComponent {
this.errorCodes = new ErrorCodes();
this.errorMessages = new ErrorMessagesComponent();
this.searchUtils.status = this.errorCodes.LOADING;
this.searchFields.sortFieldsByName(this.fieldIds, this.fieldIdsMap);
}
ngOnInit() {
this.refineFields = DatasourcesHelperClass.getrefineFields(this.type);

View File

@ -89,8 +89,7 @@ export class SearchOrganizationsComponent {
this.errorMessages = new ErrorMessagesComponent();
this.searchUtils.status = this.errorCodes.LOADING;
this.searchFields.sortFieldsByName(this.fieldIds, this.fieldIdsMap);
}
ngOnInit() {

View File

@ -92,6 +92,8 @@ export class SearchProjectsComponent {
this.errorMessages = new ErrorMessagesComponent();
this.searchUtils.status = this.errorCodes.LOADING;
this.searchUtils.refineStatus = this.errorCodes.LOADING;
this.searchFields.sortFieldsByName(this.fieldIds, this.fieldIdsMap);
}
ngOnInit() {

View File

@ -113,6 +113,8 @@ export class SearchResearchResultsComponent {
this.searchUtils.status = this.errorCodes.LOADING;
this.searchUtils.refineStatus = this.errorCodes.LOADING;
this.getPublicCommunities();
this.searchFields.sortFieldsByName(this.fieldIds, this.fieldIdsMap);
}
getRoute(){

View File

@ -418,7 +418,7 @@ export class SearchFields {
"datasourcejurisdiction"];
public DATASOURCE_ADVANCED_FIELDS: string[] = ["q", "datasourceofficialname",
"datasourceenglishname", "datasourceodsubjects", "datasourcetypename", "datasourceodlanguages",
"datasourceodcontenttypes", "datasourcecompatibilityname", "relorganizationid", "collectedfromdatasourceid"];
"datasourceodcontenttypes", "datasourcecompatibilityname", "relorganizationid", "collectedfromdatasourceid", "pid"];
public DATASOURCE_FIELDS: { [key: string]: FieldDetails } = {
["q"]: {name: "Any field", type: "keyword", param: "q", operator: "op", equalityOperator: "=", filterType: null},
@ -549,7 +549,8 @@ export class SearchFields {
operator: "ju",
equalityOperator: " exact ",
filterType: "checkbox"
}
},
["pid"]: {name: "PID", type: "keyword", param: "pid", operator: "pd", equalityOperator: " exact ", filterType: null}
};
public DEPOSIT_DATASOURCE_KEYWORD_FIELDS: { "name": string, "equalityOperator": string } [] = [
@ -698,7 +699,20 @@ export class SearchFields {
let field = this.getField(fieldId, fieldType);
return field?field.name:"UNDEFINED";
}
sortFieldsByName(fieldIds: string[], fieldIdsMap: { [key: string]: FieldDetails }) {
fieldIds.sort((a: string, b: string) => {
if(a == "q") {
return -1;
} else if(b == "q") {
return 1;
}
let nameA: string = fieldIdsMap[a].name;
let nameB: string = fieldIdsMap[b].name;
return nameA.localeCompare(nameB);
})
}
getFieldFilterType(fieldId: string, fieldType: string, usedBy: string = "search"): string {
let field = this.getField(fieldId, fieldType);
return field?field.filterType:"checkbox";