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

Performer select calculated ages #5110

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,22 @@ export const GalleryEditPanel: React.FC<IProps> = ({
}

function renderPerformersField() {
const date = (() => {
try {
return schema.validateSyncAt("date", formik.values);
} catch (e) {
return undefined;
}
})();

const title = intl.formatMessage({ id: "performers" });
const control = (
<PerformerSelect isMulti onSelect={onSetPerformers} values={performers} />
<PerformerSelect
isMulti
onSelect={onSetPerformers}
values={performers}
ageFromDate={date}
/>
);

return renderField("performer_ids", title, control, fullWidthProps);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ export const GalleryScrapeDialog: React.FC<IGalleryScrapeDialogProps> = ({
onChange={(value) => setPerformers(value)}
newObjects={newPerformers}
onCreateNew={createNewPerformer}
ageFromDate={date.useNewValue ? date.newValue : date.originalValue}
/>
{scrapedTagsRow}
<ScrapedTextAreaRow
Expand Down
15 changes: 14 additions & 1 deletion ui/v2.5/src/components/Images/ImageDetails/ImageEditPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,22 @@ export const ImageEditPanel: React.FC<IProps> = ({
}

function renderPerformersField() {
const date = (() => {
try {
return schema.validateSyncAt("date", formik.values);
} catch (e) {
return undefined;
}
})();

const title = intl.formatMessage({ id: "performers" });
const control = (
<PerformerSelect isMulti onSelect={onSetPerformers} values={performers} />
<PerformerSelect
isMulti
onSelect={onSetPerformers}
values={performers}
ageFromDate={date}
/>
);

return renderField("performer_ids", title, control, fullWidthProps);
Expand Down
33 changes: 26 additions & 7 deletions ui/v2.5/src/components/Performers/PerformerSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const performerSelectSort = PatchFunction(
);

const _PerformerSelect: React.FC<
IFilterProps & IFilterValueProps<Performer>
IFilterProps & IFilterValueProps<Performer> & { ageFromDate?: string | null }
> = (props) => {
const [createPerformer] = usePerformerCreate();

Expand Down Expand Up @@ -117,6 +117,27 @@ const _PerformerSelect: React.FC<
);
}

const sceneAge = TextUtils.age(object.birthdate, props.ageFromDate);

const age =
sceneAge < 18
? TextUtils.age(object.birthdate, object.death_date)
: sceneAge;

const ageL10nId =
!props.ageFromDate || sceneAge < 18
? "media_info.performer_card.age"
: "age_on_date";

const ageL10String = intl.formatMessage({
id: "years_old",
defaultMessage: "years old",
});
const ageString = intl.formatMessage(
{ id: ageL10nId },
{ age, years_old: ageL10String }
);

thisOptionProps = {
...optionProps,
children: (
Expand Down Expand Up @@ -154,12 +175,10 @@ const _PerformerSelect: React.FC<
)}

{object.birthdate && (
<span className="performer-select-birthdate">{`${
object.birthdate
} (${TextUtils.age(
object.birthdate,
object.death_date
)})`}</span>
<span className="performer-select-birthdate">
{object.birthdate}
<span className="performer-select-age">{` (${ageString})`}</span>
</span>
)}
</span>
</span>
Expand Down
15 changes: 14 additions & 1 deletion ui/v2.5/src/components/Scenes/SceneDetails/SceneEditPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -623,9 +623,22 @@ export const SceneEditPanel: React.FC<IProps> = ({
}

function renderPerformersField() {
const date = (() => {
try {
return schema.validateSyncAt("date", formik.values);
} catch (e) {
return undefined;
}
})();

const title = intl.formatMessage({ id: "performers" });
const control = (
<PerformerSelect isMulti onSelect={onSetPerformers} values={performers} />
<PerformerSelect
isMulti
onSelect={onSetPerformers}
values={performers}
ageFromDate={date}
/>
);

return renderField("performer_ids", title, control, fullWidthProps);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ export const SceneScrapeDialog: React.FC<ISceneScrapeDialogProps> = ({
onChange={(value) => setPerformers(value)}
newObjects={newPerformers}
onCreateNew={createNewPerformer}
ageFromDate={date.useNewValue ? date.newValue : date.originalValue}
/>
<ScrapedGroupsRow
title={intl.formatMessage({ id: "groups" })}
Expand Down
1 change: 1 addition & 0 deletions ui/v2.5/src/components/Scenes/SceneMergeDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ const SceneMergeDetails: React.FC<ISceneMergeDetailsProps> = ({
title={intl.formatMessage({ id: "performers" })}
result={performers}
onChange={(value) => setPerformers(value)}
ageFromDate={date.useNewValue ? date.newValue : date.originalValue}
/>
<ScrapedGroupsRow
title={intl.formatMessage({ id: "groups" })}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ type IScrapedObjectRowImpl<T> = Omit<
>;

export const ScrapedPerformersRow: React.FC<
IScrapedObjectRowImpl<GQL.ScrapedPerformer>
> = ({ title, result, onChange, newObjects, onCreateNew }) => {
IScrapedObjectRowImpl<GQL.ScrapedPerformer> & { ageFromDate?: string | null }
> = ({ title, result, onChange, newObjects, onCreateNew, ageFromDate }) => {
const performersCopy = useMemo(() => {
return (
newObjects?.map((p) => {
Expand Down Expand Up @@ -179,6 +179,7 @@ export const ScrapedPerformersRow: React.FC<
}
}}
values={selectValue}
ageFromDate={ageFromDate}
/>
);
}
Expand Down
3 changes: 3 additions & 0 deletions ui/v2.5/src/components/Tagger/scenes/PerformerResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ interface IPerformerResultProps {
onCreate: () => void;
onLink?: () => Promise<void>;
endpoint?: string;
ageFromDate?: string | null;
}

const PerformerResult: React.FC<IPerformerResultProps> = ({
Expand All @@ -60,6 +61,7 @@ const PerformerResult: React.FC<IPerformerResultProps> = ({
onCreate,
onLink,
endpoint,
ageFromDate,
}) => {
const { data: performerData, loading: stashLoading } =
GQL.useFindPerformerQuery({
Expand Down Expand Up @@ -191,6 +193,7 @@ const PerformerResult: React.FC<IPerformerResultProps> = ({
onSelect={handleSelect}
active={selectedSource === "existing"}
isClearable={false}
ageFromDate={ageFromDate}
/>
{maybeRenderLinkButton()}
</ButtonGroup>
Expand Down
5 changes: 5 additions & 0 deletions ui/v2.5/src/components/Tagger/scenes/StashSearchResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,11 @@ const StashSearchResult: React.FC<IStashSearchResultProps> = ({
currentSource?.sourceInput.stash_box_endpoint ?? undefined
}
key={`${performer.name ?? performer.remote_site_id ?? ""}`}
ageFromDate={
!scene.date || excludedFields.date
? stashScene.date
: scene.date
}
/>
))}
</Form.Group>
Expand Down
2 changes: 1 addition & 1 deletion ui/v2.5/src/components/Tagger/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@

.performer-select,
.studio-select {
width: 14rem;
width: 18rem;

// stylelint-disable-next-line selector-class-pattern
&-active .react-select__control {
Expand Down
1 change: 1 addition & 0 deletions ui/v2.5/src/locales/en-GB.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
},
"actions_name": "Actions",
"age": "Age",
"age_on_date": "{age} on this date",
"aliases": "Aliases",
"all": "all",
"also_known_as": "Also known as",
Expand Down
Loading