15781: Uses 'contains' filter operator to search for properties.
authorLucas Di Pentima <lucas@di-pentima.com.ar>
Fri, 31 Jan 2020 18:38:36 +0000 (15:38 -0300)
committerLucas Di Pentima <lucas@di-pentima.com.ar>
Fri, 31 Jan 2020 18:38:36 +0000 (15:38 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas@di-pentima.com.ar>

src/services/api/filter-builder.test.ts
src/services/api/filter-builder.ts
src/store/search-bar/search-bar-actions.ts

index d9656934cb80ff8ad9cd73177f2abfec0bc67c3e..a4e2b2290cc368afa1209eeef2a2f5e65b3e15c3 100644 (file)
@@ -36,6 +36,12 @@ describe("FilterBuilder", () => {
         ).toEqual(`["etag","ilike","%etagValue%"]`);
     });
 
+    it("should add 'contains' rule", () => {
+        expect(
+            filters.addContains("properties.someProp", "someValue").getFilters()
+        ).toEqual(`["properties.someProp","contains","someValue"]`);
+    });
+
     it("should add 'is_a' rule", () => {
         expect(
             filters.addIsA("etag", "etagValue").getFilters()
index 102ff62c60e3eb1afc1076bf7ca2d85589e0fe63..489f7b8947a4f962ce1768b57e383269b28800db 100644 (file)
@@ -25,6 +25,10 @@ export class FilterBuilder {
         return this.addCondition(field, "ilike", value, "%", "%", resourcePrefix);
     }
 
+    public addContains(field: string, value?: string, resourcePrefix?: string) {
+        return this.addCondition(field, "contains", value, "", "", resourcePrefix);
+    }
+
     public addIsA(field: string, value?: string | string[], resourcePrefix?: string) {
         return this.addCondition(field, "is_a", value, "", "", resourcePrefix);
     }
index b91dc9d10fdbc1c8a6b0a063a30b9a20fbe96418..c12fcbe49cd10a6e56d9f2d7802cf44daed7afd3 100644 (file)
@@ -353,8 +353,8 @@ export const queryToFilters = (query: string) => {
     data.properties.forEach(p => {
         if (p.value) {
             filter
-                .addILike(`properties.${p.key}`, p.value, GroupContentsResourcePrefix.PROJECT)
-                .addILike(`properties.${p.key}`, p.value, GroupContentsResourcePrefix.COLLECTION);
+                .addContains(`properties.${p.key}`, p.value, GroupContentsResourcePrefix.PROJECT)
+                .addContains(`properties.${p.key}`, p.value, GroupContentsResourcePrefix.COLLECTION);
         }
         filter.addExists(p.key);
     });