mirror of
https://github.com/stashapp/stash.git
synced 2025-12-06 08:26:00 +01:00
Markers scene filter (#5097)
* Add scene filter to markers * Fix labels for scenes --------- Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
parent
62ff6f3c7f
commit
3089e1ad69
6 changed files with 56 additions and 3 deletions
|
|
@ -191,6 +191,8 @@ input SceneMarkerFilterType {
|
||||||
scene_tags: HierarchicalMultiCriterionInput
|
scene_tags: HierarchicalMultiCriterionInput
|
||||||
"Filter to only include scene markers with these performers"
|
"Filter to only include scene markers with these performers"
|
||||||
performers: MultiCriterionInput
|
performers: MultiCriterionInput
|
||||||
|
"Filter to only include scene markers from these scenes"
|
||||||
|
scenes: MultiCriterionInput
|
||||||
"Filter by creation time"
|
"Filter by creation time"
|
||||||
created_at: TimestampCriterionInput
|
created_at: TimestampCriterionInput
|
||||||
"Filter by last update time"
|
"Filter by last update time"
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@ type SceneMarkerFilterType struct {
|
||||||
SceneTags *HierarchicalMultiCriterionInput `json:"scene_tags"`
|
SceneTags *HierarchicalMultiCriterionInput `json:"scene_tags"`
|
||||||
// Filter to only include scene markers with these performers
|
// Filter to only include scene markers with these performers
|
||||||
Performers *MultiCriterionInput `json:"performers"`
|
Performers *MultiCriterionInput `json:"performers"`
|
||||||
|
// Filter to only include scene markers from these scenes
|
||||||
|
Scenes *MultiCriterionInput `json:"scenes"`
|
||||||
// Filter by created at
|
// Filter by created at
|
||||||
CreatedAt *TimestampCriterionInput `json:"created_at"`
|
CreatedAt *TimestampCriterionInput `json:"created_at"`
|
||||||
// Filter by updated at
|
// Filter by updated at
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ func (qb *sceneMarkerFilterHandler) criterionHandler() criterionHandler {
|
||||||
qb.tagsCriterionHandler(sceneMarkerFilter.Tags),
|
qb.tagsCriterionHandler(sceneMarkerFilter.Tags),
|
||||||
qb.sceneTagsCriterionHandler(sceneMarkerFilter.SceneTags),
|
qb.sceneTagsCriterionHandler(sceneMarkerFilter.SceneTags),
|
||||||
qb.performersCriterionHandler(sceneMarkerFilter.Performers),
|
qb.performersCriterionHandler(sceneMarkerFilter.Performers),
|
||||||
|
qb.scenesCriterionHandler(sceneMarkerFilter.Scenes),
|
||||||
×tampCriterionHandler{sceneMarkerFilter.CreatedAt, "scene_markers.created_at", nil},
|
×tampCriterionHandler{sceneMarkerFilter.CreatedAt, "scene_markers.created_at", nil},
|
||||||
×tampCriterionHandler{sceneMarkerFilter.UpdatedAt, "scene_markers.updated_at", nil},
|
×tampCriterionHandler{sceneMarkerFilter.UpdatedAt, "scene_markers.updated_at", nil},
|
||||||
&dateCriterionHandler{sceneMarkerFilter.SceneDate, "scenes.date", qb.joinScenes},
|
&dateCriterionHandler{sceneMarkerFilter.SceneDate, "scenes.date", qb.joinScenes},
|
||||||
|
|
@ -187,3 +188,18 @@ func (qb *sceneMarkerFilterHandler) performersCriterionHandler(performers *model
|
||||||
handler(ctx, f)
|
handler(ctx, f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (qb *sceneMarkerFilterHandler) scenesCriterionHandler(scenes *models.MultiCriterionInput) criterionHandlerFunc {
|
||||||
|
addJoinsFunc := func(f *filterBuilder) {
|
||||||
|
f.addLeftJoin(sceneTable, "markers_scenes", "markers_scenes.id = scene_markers.scene_id")
|
||||||
|
}
|
||||||
|
h := multiCriterionHandlerBuilder{
|
||||||
|
primaryTable: sceneMarkerTable,
|
||||||
|
foreignTable: "markers_scenes",
|
||||||
|
joinTable: "",
|
||||||
|
primaryFK: sceneIDColumn,
|
||||||
|
foreignFK: sceneIDColumn,
|
||||||
|
addJoinsFunc: addJoinsFunc,
|
||||||
|
}
|
||||||
|
return h.handler(scenes)
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { Form } from "react-bootstrap";
|
import { Form } from "react-bootstrap";
|
||||||
import { FilterSelect, SelectObject } from "src/components/Shared/Select";
|
import { FilterSelect, SelectObject } from "src/components/Shared/Select";
|
||||||
|
import { objectTitle } from "src/core/files";
|
||||||
import { galleryTitle } from "src/core/galleries";
|
import { galleryTitle } from "src/core/galleries";
|
||||||
import { Criterion } from "src/models/list-filter/criteria/criterion";
|
import { Criterion } from "src/models/list-filter/criteria/criterion";
|
||||||
import { ILabeledId } from "src/models/list-filter/types";
|
import { ILabeledId } from "src/models/list-filter/types";
|
||||||
|
|
@ -31,8 +32,11 @@ export const LabeledIdFilter: React.FC<ILabeledIdFilterProps> = ({
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLabel(i: SelectObject) {
|
function getLabel(i: SelectObject) {
|
||||||
if (inputType === "galleries") {
|
switch (inputType) {
|
||||||
return galleryTitle(i);
|
case "galleries":
|
||||||
|
return galleryTitle(i);
|
||||||
|
case "scenes":
|
||||||
|
return objectTitle(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
return i.name ?? i.title ?? "";
|
return i.name ?? i.title ?? "";
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,9 @@
|
||||||
import { ILabeledIdCriterion, ILabeledIdCriterionOption } from "./criterion";
|
import {
|
||||||
|
CriterionOption,
|
||||||
|
ILabeledIdCriterion,
|
||||||
|
ILabeledIdCriterionOption,
|
||||||
|
} from "./criterion";
|
||||||
|
import { CriterionModifier } from "src/core/generated-graphql";
|
||||||
|
|
||||||
const inputType = "scenes";
|
const inputType = "scenes";
|
||||||
|
|
||||||
|
|
@ -15,3 +20,25 @@ export class ScenesCriterion extends ILabeledIdCriterion {
|
||||||
super(ScenesCriterionOption);
|
super(ScenesCriterionOption);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const modifierOptions = [
|
||||||
|
CriterionModifier.Includes,
|
||||||
|
CriterionModifier.Excludes,
|
||||||
|
];
|
||||||
|
|
||||||
|
const defaultModifier = CriterionModifier.Includes;
|
||||||
|
|
||||||
|
export const MarkersScenesCriterionOption = new CriterionOption({
|
||||||
|
messageID: "scenes",
|
||||||
|
type: "scenes",
|
||||||
|
modifierOptions,
|
||||||
|
defaultModifier,
|
||||||
|
inputType,
|
||||||
|
makeCriterion: () => new MarkersScenesCriterion(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export class MarkersScenesCriterion extends ILabeledIdCriterion {
|
||||||
|
constructor() {
|
||||||
|
super(MarkersScenesCriterionOption);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { PerformersCriterionOption } from "./criteria/performers";
|
import { PerformersCriterionOption } from "./criteria/performers";
|
||||||
|
import { MarkersScenesCriterionOption } from "./criteria/scenes";
|
||||||
import { SceneTagsCriterionOption, TagsCriterionOption } from "./criteria/tags";
|
import { SceneTagsCriterionOption, TagsCriterionOption } from "./criteria/tags";
|
||||||
import { ListFilterOptions } from "./filter-options";
|
import { ListFilterOptions } from "./filter-options";
|
||||||
import { DisplayMode } from "./types";
|
import { DisplayMode } from "./types";
|
||||||
|
|
@ -18,6 +19,7 @@ const sortByOptions = [
|
||||||
const displayModeOptions = [DisplayMode.Wall];
|
const displayModeOptions = [DisplayMode.Wall];
|
||||||
const criterionOptions = [
|
const criterionOptions = [
|
||||||
TagsCriterionOption,
|
TagsCriterionOption,
|
||||||
|
MarkersScenesCriterionOption,
|
||||||
SceneTagsCriterionOption,
|
SceneTagsCriterionOption,
|
||||||
PerformersCriterionOption,
|
PerformersCriterionOption,
|
||||||
createMandatoryTimestampCriterionOption("created_at"),
|
createMandatoryTimestampCriterionOption("created_at"),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue