Skip to content

Commit

Permalink
Add filter country when click the performer flag (stashapp#795)
Browse files Browse the repository at this point in the history
  • Loading branch information
caustico authored Sep 12, 2020
1 parent 1e45443 commit d57fe01
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ui/v2.5/src/components/Performers/PerformerCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ export const PerformerCard: React.FC<IPerformerCardProps> = ({
<div className="card-section">
<h5 className="text-truncate">{performer.name}</h5>
{age !== 0 ? <div className="text-muted">{ageString}</div> : ""}
<CountryFlag country={performer.country} />
<Link to={NavUtils.makePerformersCountryUrl(performer)}>
<CountryFlag country={performer.country} />
</Link>
<div className="text-muted">
Stars in&nbsp;
<FormattedNumber value={performer.scene_count ?? 0} />
Expand Down
16 changes: 16 additions & 0 deletions ui/v2.5/src/models/list-filter/criteria/country.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { CriterionModifier } from "src/core/generated-graphql";
import { Criterion, CriterionType, ICriterionOption } from "./criterion";

export class CountryCriterion extends Criterion {
public type: CriterionType = "country";
public parameterName: string = "performers";
public modifier = CriterionModifier.Equals;
public modifierOptions = [];
public options: string[] = [true.toString(), false.toString()];
public value: string = "";
}

export class CountryCriterionOption implements ICriterionOption {
public label: string = Criterion.getLabel("performers");
public value: CriterionType = "country";
}
13 changes: 13 additions & 0 deletions ui/v2.5/src/utils/navigation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as GQL from "src/core/generated-graphql";
import { PerformersCriterion } from "src/models/list-filter/criteria/performers";
import { CountryCriterion } from "src/models/list-filter/criteria/country";
import {
StudiosCriterion,
ParentStudiosCriterion,
Expand All @@ -22,6 +23,17 @@ const makePerformerScenesUrl = (
return `/scenes?${filter.makeQueryParameters()}`;
};

const makePerformersCountryUrl = (
performer: Partial<GQL.PerformerDataFragment>
) => {
if (!performer.id) return "#";
const filter = new ListFilterModel(FilterMode.Performers);
const criterion = new CountryCriterion();
criterion.value = `${performer.country}`;
filter.criteria.push(criterion);
return `/performers?${filter.makeQueryParameters()}`;
};

const makeStudioScenesUrl = (studio: Partial<GQL.StudioDataFragment>) => {
if (!studio.id) return "#";
const filter = new ListFilterModel(FilterMode.Scenes);
Expand Down Expand Up @@ -82,6 +94,7 @@ const makeSceneMarkerUrl = (

export default {
makePerformerScenesUrl,
makePerformersCountryUrl,
makeStudioScenesUrl,
makeTagSceneMarkersUrl,
makeTagScenesUrl,
Expand Down

0 comments on commit d57fe01

Please sign in to comment.