diff --git a/src/app/datasets/datasets-filter/datasets-filter.component.html b/src/app/datasets/datasets-filter/datasets-filter.component.html index 119eb9814..171dc077b 100644 --- a/src/app/datasets/datasets-filter/datasets-filter.component.html +++ b/src/app/datasets/datasets-filter/datasets-filter.component.html @@ -173,6 +173,9 @@  =  + +  contains  +  <  @@ -181,7 +184,7 @@ {{ - condition.relation === "EQUAL_TO_STRING" + ["EQUAL_TO_STRING", "CONTAINS_STRING"].includes(condition.relation) ? '"' + condition.rhs + '"' : condition.rhs }} diff --git a/src/app/samples/sample-dashboard/sample-dashboard.component.html b/src/app/samples/sample-dashboard/sample-dashboard.component.html index c7694a8fc..1d4eb0acf 100644 --- a/src/app/samples/sample-dashboard/sample-dashboard.component.html +++ b/src/app/samples/sample-dashboard/sample-dashboard.component.html @@ -48,6 +48,9 @@  =  + +  =  +  <  @@ -56,7 +59,7 @@ {{ - characteristic.relation === "EQUAL_TO_STRING" + [ "EQUAL_TO_STRING", "CONTAINS_STRING" ].includes(characteristic.relation) ? '"' + characteristic.rhs + '"' : characteristic.rhs }} diff --git a/src/app/shared/modules/search-parameters-dialog/search-parameters-dialog.component.html b/src/app/shared/modules/search-parameters-dialog/search-parameters-dialog.component.html index 9be96519c..d1225e411 100644 --- a/src/app/shared/modules/search-parameters-dialog/search-parameters-dialog.component.html +++ b/src/app/shared/modules/search-parameters-dialog/search-parameters-dialog.component.html @@ -1,93 +1,94 @@ -

Add Characteristic

-
- - - Field - - - - {{ key }} - - - - - - Operator - - is greater than - is less than - is equal to (numeric) - is equal to (string) - - - - - Value - - - - - - Unit - - - - {{ unit }} - - - - - - - - - -
+

Add Characteristic

+
+ + + Field + + + + {{ key }} + + + + + + Operator + + is greater than + is less than + is equal to (numeric) + is equal to (string) + contains string + + + + + Value + + + + + + Unit + + + + {{ unit }} + + + + + + + + + +
diff --git a/src/app/shared/modules/search-parameters-dialog/search-parameters-dialog.component.spec.ts b/src/app/shared/modules/search-parameters-dialog/search-parameters-dialog.component.spec.ts index 5865322f8..e69dc06b0 100644 --- a/src/app/shared/modules/search-parameters-dialog/search-parameters-dialog.component.spec.ts +++ b/src/app/shared/modules/search-parameters-dialog/search-parameters-dialog.component.spec.ts @@ -107,7 +107,7 @@ describe("SearchParametersDialogComponent", () => { }); describe("#toggleUnitField()", () => { - it("should enable unitField if lhs is valid and relation is not EQUAL_TO_STRING", () => { + it("should enable unitField if lhs is valid and relation is not CONTAINS_STRING or EQUAL_TO_STRING", () => { const formValues = { lhs: "mass", relation: "LESS_THAN", diff --git a/src/app/shared/modules/search-parameters-dialog/search-parameters-dialog.component.ts b/src/app/shared/modules/search-parameters-dialog/search-parameters-dialog.component.ts index e5af6d850..2c54e3233 100644 --- a/src/app/shared/modules/search-parameters-dialog/search-parameters-dialog.component.ts +++ b/src/app/shared/modules/search-parameters-dialog/search-parameters-dialog.component.ts @@ -57,8 +57,9 @@ export class SearchParametersDialogComponent { add = (): void => { const { lhs, relation, unit } = this.parametersForm.value; const rawRhs = this.parametersForm.get("rhs")?.value; - const rhs = - relation === "EQUAL_TO_STRING" ? String(rawRhs) : Number(rawRhs); + const rhs = ["CONTAINS_STRING", "EQUAL_TO_STRING"].includes(relation) + ? String(rawRhs) + : Number(rawRhs); this.parametersForm.patchValue({ rhs }); this.dialogRef.close({ data: { lhs, relation, rhs, unit } }); }; @@ -73,7 +74,11 @@ export class SearchParametersDialogComponent { toggleUnitField = (): void => { const lhsInvalid = this.parametersForm.get("lhs")?.invalid; const { relation } = this.parametersForm.value; - const isStringRelation = relation === "EQUAL_TO_STRING" ? true : false; + const isStringRelation = ["CONTAINS_STRING", "EQUAL_TO_STRING"].includes( + relation, + ) + ? true + : false; const unitField = this.parametersForm.get("unit"); unitField?.enable(); if (lhsInvalid || isStringRelation) { @@ -88,7 +93,10 @@ export class SearchParametersDialogComponent { if (invalid) { return invalid; } - if (relation !== "EQUAL_TO_STRING" && isNaN(Number(rhs))) { + if ( + !["CONTAINS_STRING", "EQUAL_TO_STRING"].includes(relation) && + isNaN(Number(rhs)) + ) { return true; } return lhs.length * (rhs as string).length === 0; diff --git a/src/app/state-management/models/index.ts b/src/app/state-management/models/index.ts index 12f769a01..fde0343a3 100644 --- a/src/app/state-management/models/index.ts +++ b/src/app/state-management/models/index.ts @@ -81,6 +81,7 @@ export enum JobViewMode { type ScientificConditionRelation = | "EQUAL_TO_NUMERIC" | "EQUAL_TO_STRING" + | "CONTAINS_STRING" | "GREATER_THAN" | "LESS_THAN";