Hide legacy groups criterion option (#5521)

This commit is contained in:
WithoutPants 2024-12-03 08:02:13 +11:00 committed by GitHub
parent 7f8349469a
commit 60bb6bf50b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 5 deletions

View File

@ -243,11 +243,13 @@ export const EditFilterDialog: React.FC<IEditFilterProps> = ({
}, [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(

View File

@ -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;
}

View File

@ -50,5 +50,6 @@ export const LegacyMoviesCriterionOption = new CriterionOption({
modifierOptions,
defaultModifier,
inputType,
hidden: true,
makeCriterion: () => new GroupsCriterion(GroupsCriterionOption),
});