mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 12:54:38 +03:00
Caption support (#2462)
Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
42
ui/v2.5/src/models/list-filter/criteria/captions.ts
Normal file
42
ui/v2.5/src/models/list-filter/criteria/captions.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { CriterionModifier } from "src/core/generated-graphql";
|
||||
import { languageMap, valueToCode } from "src/utils/caption";
|
||||
import { CriterionType } from "../types";
|
||||
import { CriterionOption, StringCriterion } from "./criterion";
|
||||
|
||||
const languageStrings = Array.from(languageMap.values());
|
||||
|
||||
class CaptionsCriterionOptionType extends CriterionOption {
|
||||
constructor(value: CriterionType) {
|
||||
super({
|
||||
messageID: value,
|
||||
type: value,
|
||||
parameterName: value,
|
||||
modifierOptions: [
|
||||
CriterionModifier.Includes,
|
||||
CriterionModifier.Excludes,
|
||||
CriterionModifier.IsNull,
|
||||
CriterionModifier.NotNull,
|
||||
],
|
||||
options: languageStrings,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export const CaptionsCriterionOption = new CaptionsCriterionOptionType(
|
||||
"captions"
|
||||
);
|
||||
|
||||
export class CaptionCriterion extends StringCriterion {
|
||||
protected toCriterionInput() {
|
||||
const value = valueToCode(this.value);
|
||||
|
||||
return {
|
||||
value,
|
||||
modifier: this.modifier,
|
||||
};
|
||||
}
|
||||
|
||||
constructor() {
|
||||
super(CaptionsCriterionOption);
|
||||
}
|
||||
}
|
||||
@@ -43,6 +43,7 @@ import { CriterionType } from "../types";
|
||||
import { InteractiveCriterion } from "./interactive";
|
||||
import { RatingCriterionOption } from "./rating";
|
||||
import { DuplicatedCriterion, PhashCriterionOption } from "./phash";
|
||||
import { CaptionCriterion } from "./captions";
|
||||
|
||||
export function makeCriteria(type: CriterionType = "none") {
|
||||
switch (type) {
|
||||
@@ -159,6 +160,8 @@ export function makeCriteria(type: CriterionType = "none") {
|
||||
return new StringCriterion(new StringCriterionOption(type, type));
|
||||
case "interactive":
|
||||
return new InteractiveCriterion();
|
||||
case "captions":
|
||||
return new CaptionCriterion();
|
||||
case "parent_tag_count":
|
||||
return new NumberCriterion(
|
||||
new MandatoryNumberCriterionOption(
|
||||
|
||||
@@ -23,6 +23,7 @@ import {
|
||||
PhashCriterionOption,
|
||||
} from "./criteria/phash";
|
||||
import { PerformerFavoriteCriterionOption } from "./criteria/favorite";
|
||||
import { CaptionsCriterionOption } from "./criteria/captions";
|
||||
|
||||
const defaultSortBy = "date";
|
||||
const sortByOptions = [
|
||||
@@ -78,6 +79,7 @@ const criterionOptions = [
|
||||
createStringCriterionOption("url"),
|
||||
createStringCriterionOption("stash_id"),
|
||||
InteractiveCriterionOption,
|
||||
CaptionsCriterionOption,
|
||||
createMandatoryNumberCriterionOption("interactive_speed"),
|
||||
];
|
||||
|
||||
|
||||
@@ -113,6 +113,7 @@ export type CriterionType =
|
||||
| "stash_id"
|
||||
| "interactive"
|
||||
| "interactive_speed"
|
||||
| "captions"
|
||||
| "name"
|
||||
| "details"
|
||||
| "title"
|
||||
|
||||
Reference in New Issue
Block a user