From 51ef12f9fe64b583e42cc8b8fdc9a912126b22fa Mon Sep 17 00:00:00 2001 From: Candid Dauth Date: Sat, 10 Apr 2021 00:27:08 +0200 Subject: [PATCH] Add lower() function to filter for case-insensitive comparison --- frontend/src/map/edit-filter/edit-filter.vue | 10 ++++++++-- utils/src/filter.ts | 9 ++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/frontend/src/map/edit-filter/edit-filter.vue b/frontend/src/map/edit-filter/edit-filter.vue index da3d6e9f..ab8d2f04 100644 --- a/frontend/src/map/edit-filter/edit-filter.vue +++ b/frontend/src/map/edit-filter/edit-filter.vue @@ -45,13 +45,13 @@ typeId / {{type.id}} ({{type.name}}) - typeId == 1 + typeId == {{types[0].id || 1}} data.<field> / prop(data, <field>) Field values (example: data.Description or prop(data, "Description") - data.Description ~= "camp" + lower(data.Description) ~= "camp" @@ -180,6 +180,12 @@ name ~= "^[Cc]amp$" + + lower() + Convert to lower case + lower(name) ~= "untitled" + + ceil(), floor(), round() Round (ceil: up, floor: down) diff --git a/utils/src/filter.ts b/utils/src/filter.ts index 255ca0ec..830def51 100644 --- a/utils/src/filter.ts +++ b/utils/src/filter.ts @@ -9,7 +9,14 @@ const customFuncs = { return obj && getProperty(obj, key); }, - random() { } // Does not work well with angular digest cycles + random() { }, // Does not work well with angular digest cycles + + lower(obj: any) { + if (typeof obj == "string") + return obj.toLowerCase(); + else + return obj; + } }; export function filterHasError(expr: string): Error | undefined {