Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filter country when click the performer flag #795

Merged
merged 2 commits into from
Sep 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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