From cf53b4110a732ec476c6c4c489cf6247054436d0 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Thu, 22 Oct 2026 00:37:00 -0700 Subject: [PATCH] Frontend fixed/relative toggle. This kinda sucks atm but works --- ...ustom-fields-query-dropdown.component.html | 45 ++++++++++++------- .../custom-fields-query-dropdown.component.ts | 16 +++++++ 2 files changed, 46 insertions(+), 15 deletions(-) diff --git a/src-ui/src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.html b/src-ui/src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.html index 6923df150..d39ca8ef0 100644 --- a/src-ui/src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.html +++ b/src-ui/src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.html @@ -33,21 +33,36 @@ @if (getCustomFieldByID(atom.field)?.data_type === CustomFieldDataType.Date) { - - - -
- - -
-
+
+ + @if (isRelativeDate(atom)) { + + } @else { + + + +
+ + +
+
+ } +
} @else if (getCustomFieldByID(atom.field)?.data_type === CustomFieldDataType.Float || getCustomFieldByID(atom.field)?.data_type === CustomFieldDataType.Integer) { } @else if (getCustomFieldByID(atom.field)?.data_type === CustomFieldDataType.Boolean) { diff --git a/src-ui/src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.ts b/src-ui/src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.ts index 121e396e1..75ba99c9b 100644 --- a/src-ui/src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.ts +++ b/src-ui/src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.ts @@ -305,6 +305,22 @@ export class CustomFieldsQueryDropdownComponent extends LoadingComponentWithPerm public readonly today: string = new Date().toLocaleDateString('en-CA') + private readonly relativeDateModes = new Map() + + isRelativeDate(atom: CustomFieldQueryAtom): boolean { + return ( + this.relativeDateModes.get(atom.id) ?? + (typeof atom.value === 'string' && + !!atom.value && + !/^\d{4}-\d{2}-\d{2}$/.test(atom.value)) + ) + } + + setDateQueryMode(atom: CustomFieldQueryAtom, relative: boolean) { + this.relativeDateModes.set(atom.id, relative) + atom.value = null + } + public customFieldSearchFn = (term: string, field: CustomField): boolean => matchesSearchText(field?.name, term)