mirror of
https://github.com/stashapp/stash.git
synced 2026-01-03 22:24:41 +01:00
* Add basic support for hierarchical filters Add a new `hierarchicalMultiCriterionHandlerBuilder` filter type which can / will be used for filtering hierarchical things like the parent/child relation of the studios. On the frontend side a new IHierarchicalLabeledIdCriterion criterion type has been added to accompany this new filter type. * Refactor movieQueryBuilder to use filterBuilder Refactor the movieQueryBuilder to use the filterBuilder just as scene, image and gallery as well. * Support specifying depth for studios filter Add an optional depth field to the studios filter for scenes, images, galleries and movies. When specified that number of included (grant)children are shown as well. In other words: this adds support for showing scenes set to child studios when searching on the parent studio. Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
import * as GQL from "src/core/generated-graphql";
|
|
import { StudiosCriterion } from "src/models/list-filter/criteria/studios";
|
|
import { ListFilterModel } from "src/models/list-filter/filter";
|
|
|
|
export const studioFilterHook = (studio: Partial<GQL.StudioDataFragment>) => {
|
|
return (filter: ListFilterModel) => {
|
|
const studioValue = { id: studio.id!, label: studio.name! };
|
|
// if studio is already present, then we modify it, otherwise add
|
|
let studioCriterion = filter.criteria.find((c) => {
|
|
return c.criterionOption.value === "studios";
|
|
}) as StudiosCriterion;
|
|
|
|
if (
|
|
studioCriterion &&
|
|
(studioCriterion.modifier === GQL.CriterionModifier.IncludesAll ||
|
|
studioCriterion.modifier === GQL.CriterionModifier.Includes)
|
|
) {
|
|
// add the studio if not present
|
|
if (
|
|
!studioCriterion.value.items.find((p) => {
|
|
return p.id === studio.id;
|
|
})
|
|
) {
|
|
studioCriterion.value.items.push(studioValue);
|
|
}
|
|
|
|
studioCriterion.modifier = GQL.CriterionModifier.IncludesAll;
|
|
} else {
|
|
// overwrite
|
|
studioCriterion = new StudiosCriterion();
|
|
studioCriterion.value = {
|
|
items: [studioValue],
|
|
depth: 0,
|
|
};
|
|
filter.criteria.push(studioCriterion);
|
|
}
|
|
|
|
return filter;
|
|
};
|
|
};
|