mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 12:54:38 +03:00
Filter tag by hierarchy (#1746)
* Add API support for filtering tags by parent / children * Add parent & child tags filters for tags to UI * Add API support for filtering tags by parent / child count * Add parent & child count filters for tags to UI * Update db generator * Add missing build tag * Add unit tests Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
@@ -27,6 +27,8 @@ import { PerformersCriterion } from "./performers";
|
||||
import { AverageResolutionCriterion, ResolutionCriterion } from "./resolution";
|
||||
import { StudiosCriterion, ParentStudiosCriterion } from "./studios";
|
||||
import {
|
||||
ChildTagsCriterionOption,
|
||||
ParentTagsCriterionOption,
|
||||
PerformerTagsCriterionOption,
|
||||
SceneTagsCriterionOption,
|
||||
TagsCriterion,
|
||||
@@ -98,6 +100,10 @@ export function makeCriteria(type: CriterionType = "none") {
|
||||
return new TagsCriterion(SceneTagsCriterionOption);
|
||||
case "performerTags":
|
||||
return new TagsCriterion(PerformerTagsCriterionOption);
|
||||
case "parentTags":
|
||||
return new TagsCriterion(ParentTagsCriterionOption);
|
||||
case "childTags":
|
||||
return new TagsCriterion(ChildTagsCriterionOption);
|
||||
case "performers":
|
||||
return new PerformersCriterion();
|
||||
case "studios":
|
||||
@@ -145,5 +151,21 @@ export function makeCriteria(type: CriterionType = "none") {
|
||||
return new StringCriterion(new StringCriterionOption(type, type));
|
||||
case "interactive":
|
||||
return new InteractiveCriterion();
|
||||
case "parent_tag_count":
|
||||
return new NumberCriterion(
|
||||
new MandatoryNumberCriterionOption(
|
||||
"parent_tag_count",
|
||||
"parent_tag_count",
|
||||
"parent_count"
|
||||
)
|
||||
);
|
||||
case "child_tag_count":
|
||||
return new NumberCriterion(
|
||||
new MandatoryNumberCriterionOption(
|
||||
"sub_tag_count",
|
||||
"child_tag_count",
|
||||
"child_count"
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,3 +23,15 @@ export const PerformerTagsCriterionOption = new ILabeledIdCriterionOption(
|
||||
"performer_tags",
|
||||
true
|
||||
);
|
||||
export const ParentTagsCriterionOption = new ILabeledIdCriterionOption(
|
||||
"parent_tags",
|
||||
"parentTags",
|
||||
"parents",
|
||||
true
|
||||
);
|
||||
export const ChildTagsCriterionOption = new ILabeledIdCriterionOption(
|
||||
"sub_tags",
|
||||
"childTags",
|
||||
"children",
|
||||
true
|
||||
);
|
||||
|
||||
@@ -2,10 +2,15 @@ import {
|
||||
createMandatoryNumberCriterionOption,
|
||||
createMandatoryStringCriterionOption,
|
||||
createStringCriterionOption,
|
||||
MandatoryNumberCriterionOption,
|
||||
} from "./criteria/criterion";
|
||||
import { TagIsMissingCriterionOption } from "./criteria/is-missing";
|
||||
import { ListFilterOptions } from "./filter-options";
|
||||
import { DisplayMode } from "./types";
|
||||
import {
|
||||
ChildTagsCriterionOption,
|
||||
ParentTagsCriterionOption,
|
||||
} from "./criteria/tags";
|
||||
|
||||
const defaultSortBy = "name";
|
||||
const sortByOptions = ["name", "random"]
|
||||
@@ -43,6 +48,18 @@ const criterionOptions = [
|
||||
createMandatoryNumberCriterionOption("gallery_count"),
|
||||
createMandatoryNumberCriterionOption("performer_count"),
|
||||
createMandatoryNumberCriterionOption("marker_count"),
|
||||
ParentTagsCriterionOption,
|
||||
new MandatoryNumberCriterionOption(
|
||||
"parent_tag_count",
|
||||
"parent_tag_count",
|
||||
"parent_count"
|
||||
),
|
||||
ChildTagsCriterionOption,
|
||||
new MandatoryNumberCriterionOption(
|
||||
"sub_tag_count",
|
||||
"child_tag_count",
|
||||
"child_count"
|
||||
),
|
||||
];
|
||||
|
||||
export const TagListFilterOptions = new ListFilterOptions(
|
||||
|
||||
@@ -75,6 +75,8 @@ export type CriterionType =
|
||||
| "tags"
|
||||
| "sceneTags"
|
||||
| "performerTags"
|
||||
| "parentTags"
|
||||
| "childTags"
|
||||
| "tag_count"
|
||||
| "performers"
|
||||
| "studios"
|
||||
@@ -114,4 +116,6 @@ export type CriterionType =
|
||||
| "galleryChecksum"
|
||||
| "phash"
|
||||
| "director"
|
||||
| "synopsis";
|
||||
| "synopsis"
|
||||
| "parent_tag_count"
|
||||
| "child_tag_count";
|
||||
|
||||
Reference in New Issue
Block a user