From 4fc9eb21ee70ab946a05479f48bb488bd239514b Mon Sep 17 00:00:00 2001 From: WithoutPants <53250216+WithoutPants@users.noreply.github.com> Date: Mon, 2 Dec 2024 14:16:53 +1100 Subject: [PATCH] Hide legacy groups criterion option --- ui/v2.5/src/components/List/EditFilterDialog.tsx | 12 +++++++----- ui/v2.5/src/models/list-filter/criteria/criterion.ts | 6 ++++++ ui/v2.5/src/models/list-filter/criteria/groups.ts | 1 + 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/ui/v2.5/src/components/List/EditFilterDialog.tsx b/ui/v2.5/src/components/List/EditFilterDialog.tsx index 169199058ec..43546731f62 100644 --- a/ui/v2.5/src/components/List/EditFilterDialog.tsx +++ b/ui/v2.5/src/components/List/EditFilterDialog.tsx @@ -243,11 +243,13 @@ export const EditFilterDialog: React.FC = ({ }, [currentFilter.mode]); const criterionOptions = useMemo(() => { - return [...filterOptions.criterionOptions].sort((a, b) => { - return intl - .formatMessage({ id: a.messageID }) - .localeCompare(intl.formatMessage({ id: b.messageID })); - }); + return [...filterOptions.criterionOptions] + .filter((c) => !c.hidden) + .sort((a, b) => { + return intl + .formatMessage({ id: a.messageID }) + .localeCompare(intl.formatMessage({ id: b.messageID })); + }); }, [intl, filterOptions.criterionOptions]); const optionSelected = useCallback( diff --git a/ui/v2.5/src/models/list-filter/criteria/criterion.ts b/ui/v2.5/src/models/list-filter/criteria/criterion.ts index d950073be4c..f5dd8503bb4 100644 --- a/ui/v2.5/src/models/list-filter/criteria/criterion.ts +++ b/ui/v2.5/src/models/list-filter/criteria/criterion.ts @@ -192,6 +192,7 @@ interface ICriterionOptionsParams { modifierOptions?: CriterionModifier[]; defaultModifier?: CriterionModifier; options?: Option[]; + hidden?: boolean; makeCriterion: ( o: CriterionOption, config?: ConfigDataFragment @@ -204,6 +205,10 @@ export class CriterionOption { public readonly defaultModifier: CriterionModifier; public readonly options: Option[] | undefined; public readonly inputType: InputType; + + // used for legacy criteria that are not shown in the UI + public readonly hidden: boolean = false; + public readonly makeCriterionFn: ( o: CriterionOption, config?: ConfigDataFragment @@ -216,6 +221,7 @@ export class CriterionOption { this.defaultModifier = options.defaultModifier ?? CriterionModifier.Equals; this.options = options.options; this.inputType = options.inputType; + this.hidden = options.hidden ?? false; this.makeCriterionFn = options.makeCriterion; } diff --git a/ui/v2.5/src/models/list-filter/criteria/groups.ts b/ui/v2.5/src/models/list-filter/criteria/groups.ts index 762ebf6e8b7..0db384c6a73 100644 --- a/ui/v2.5/src/models/list-filter/criteria/groups.ts +++ b/ui/v2.5/src/models/list-filter/criteria/groups.ts @@ -50,5 +50,6 @@ export const LegacyMoviesCriterionOption = new CriterionOption({ modifierOptions, defaultModifier, inputType, + hidden: true, makeCriterion: () => new GroupsCriterion(GroupsCriterionOption), });