Commit 5b5ba414 authored by Florent Poittevin's avatar Florent Poittevin
Browse files

fix(archive search): [DLCM-2003] facetted search with multiple values on same field cause error

parent f66c64cb
......@@ -10,6 +10,7 @@ import {RoutesEnum} from "@shared/enums/routes.enum";
import {ViewModeTableEnum} from "@shared/enums/view-mode-table.enum";
import {Observable} from "rxjs";
import {
isEmptyArray,
isNonEmptyString,
isNotNullNorUndefined,
isNullOrUndefined,
......@@ -101,13 +102,21 @@ export class HomeHelper {
static getFacetsSelectedForBackend(facetsSelected: MappingObject<string[]>): SearchFacet[] {
const facetsSelectedForBackend: SearchFacet[] = [];
MappingObjectUtil.forEach(facetsSelected, (value, key) => {
if (isNullOrUndefined(value) || isEmptyArray(value)) {
return;
}
if (this.LIST_FACET_USE_OPERATOR_AND.indexOf(key as Enums.Facet.Name) === -1) {
// FOR OR, equal value = [ "orgUnitName1", "orgUnitName2" ]
facetsSelectedForBackend.push({
const facet = {
field: key,
type: undefined,
equalValue: value.length === 1 ? value[0] : value,
});
} as SearchFacet;
if (value.length === 1) {
facet.equalValue = value[0];
} else {
facet.equalValues = value;
}
facetsSelectedForBackend.push(facet);
} else {
// FOR AND, equal value = "orgUnitName1", need to create a second search facet with "orgUnitName2"
value.forEach(v => {
......
......@@ -336,7 +336,8 @@ export interface User extends UserPartial, BaseResource, UserInfo {
export interface SearchFacet {
field: string;
equalValue: string | string[];
equalValue?: string;
equalValues?: string[];
type: undefined | "NOT_MATCH";
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment