Skip to content

Commit

Permalink
Hide legacy groups criterion option (#5521)
Browse files Browse the repository at this point in the history
  • Loading branch information
WithoutPants authored Dec 2, 2024
1 parent 7f83494 commit 60bb6bf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
12 changes: 7 additions & 5 deletions ui/v2.5/src/components/List/EditFilterDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 6 additions & 0 deletions ui/v2.5/src/models/list-filter/criteria/criterion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ interface ICriterionOptionsParams {
modifierOptions?: CriterionModifier[];
defaultModifier?: CriterionModifier;
options?: Option[];
hidden?: boolean;
makeCriterion: (
o: CriterionOption,
config?: ConfigDataFragment
Expand All @@ -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
Expand All @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions ui/v2.5/src/models/list-filter/criteria/groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,6 @@ export const LegacyMoviesCriterionOption = new CriterionOption({
modifierOptions,
defaultModifier,
inputType,
hidden: true,
makeCriterion: () => new GroupsCriterion(GroupsCriterionOption),
});

0 comments on commit 60bb6bf

Please sign in to comment.