Skip to content
Snippets Groups Projects
Commit e83e310a authored by Florent Poittevin's avatar Florent Poittevin Committed by Nicolas.Rod
Browse files

fix: MR by creating enums

parent e625c6b6
No related tags found
1 merge request!515refactor: set type and booleanClauseType when searching with facets values
......@@ -93,6 +93,38 @@ export namespace Enums {
};
}
export namespace SearchCondition {
export type Type =
"MATCH"
| "TERM"
| "RANGE"
| "QUERY"
| "SIMPLE_QUERY"
| "NESTED_BOOLEAN";
export const Type = {
MATCH: "MATCH" as Type,
TERM: "TERM" as Type,
RANGE: "RANGE" as Type,
QUERY: "QUERY" as Type,
SIMPLE_QUERY: "SIMPLE_QUERY" as Type,
NESTED_BOOLEAN: "NESTED_BOOLEAN" as Type,
};
export type BooleanClauseType =
"MUST"
| "FILTER"
| "SHOULD"
| "MUST_NOT";
export const BooleanClauseType = {
MUST: "MUST" as BooleanClauseType,
FILTER: "FILTER" as BooleanClauseType,
SHOULD: "SHOULD" as BooleanClauseType,
MUST_NOT: "MUST_NOT" as BooleanClauseType,
};
}
export namespace Aip {
export type AipContainerEnum = AipPartial.ArchiveContainerEnum;
export const AipContainerEnum = AipPartial.ArchiveContainerEnum;
......
......@@ -27,7 +27,7 @@ import {
} from "@angular/router";
import {Enums} from "@enums";
import {environment} from "@environments/environment";
import {SearchFacet} from "@models";
import {SearchCondition} from "@models";
import {Navigate} from "@ngxs/router-plugin";
import {Store} from "@ngxs/store";
import {RoutesEnum} from "@shared/enums/routes.enum";
......@@ -123,8 +123,8 @@ export class HomeHelper {
};
}
static getFacetsSelectedForBackend(facetsSelected: MappingObject<Enums.Facet.Name, string[]>): SearchFacet[] {
const facetsSelectedForBackend: SearchFacet[] = [];
static getFacetsSelectedForBackend(facetsSelected: MappingObject<Enums.Facet.Name, string[]>): SearchCondition[] {
const facetsSelectedForBackend: SearchCondition[] = [];
MappingObjectUtil.forEach(facetsSelected, (value, key) => {
if (isNullOrUndefined(value) || isEmptyArray(value)) {
return;
......@@ -133,9 +133,9 @@ export class HomeHelper {
// FOR OR, equal value = [ "orgUnitName1", "orgUnitName2" ]
const facet = {
field: key,
type: "TERM",
booleanClauseType: "MUST"
} as SearchFacet;
type: Enums.SearchCondition.Type.TERM,
booleanClauseType: Enums.SearchCondition.BooleanClauseType.MUST,
} as SearchCondition;
if (value.length === 1) {
facet.value = value[0];
} else {
......@@ -147,9 +147,9 @@ export class HomeHelper {
value.forEach(v => {
facetsSelectedForBackend.push({
field: key,
type: "TERM",
type: Enums.SearchCondition.Type.TERM,
value: v,
booleanClauseType: "MUST"
booleanClauseType: Enums.SearchCondition.BooleanClauseType.MUST,
});
});
}
......
......@@ -371,20 +371,24 @@ export interface User extends UserPartial, BaseResource, UserInfo {
lastLoginTime?: string;
}
export interface SearchFacet {
field: string;
value?: string;
values?: string[];
type: undefined | "TERM" | "NOT_MATCH";
booleanClauseType: undefined | "MUST";
}
export interface FacetProperty {
name: string;
defaultVisibleValues: number;
labels: Label[];
}
export interface SearchCondition {
type?: Enums.SearchCondition.Type;
booleanClauseType?: Enums.SearchCondition.BooleanClauseType;
field?: string;
fields?: string[];
value?: string;
values?: string[];
upperValue?: string;
lowerValue?: string;
nestedConditions?: SearchCondition[];
}
export interface Label extends SolidifyLabel {
languageCode?: Enums.Language.LanguageEnum;
text?: string;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment