Skip to content

Commit

Permalink
tag sort_name frontend
Browse files Browse the repository at this point in the history
adds `data-sort-name` attribute to tag links prioritizes sort_name value but will default to tag name if not present in the same way that COALESCE will prioritize the same values in the same way
  • Loading branch information
stg-annon committed Dec 4, 2024
1 parent cf31393 commit e627391
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 2 deletions.
1 change: 1 addition & 0 deletions ui/v2.5/graphql/data/tag-slim.graphql
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
fragment SlimTagData on Tag {
id
name
sort_name
aliases
image_path
parent_count
Expand Down
3 changes: 3 additions & 0 deletions ui/v2.5/graphql/data/tag.graphql
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
fragment TagData on Tag {
id
name
sort_name
description
aliases
ignore_auto_tag
Expand Down Expand Up @@ -33,6 +34,7 @@ fragment TagData on Tag {
fragment SelectTagData on Tag {
id
name
sort_name
favorite
description
aliases
Expand All @@ -41,5 +43,6 @@ fragment SelectTagData on Tag {
parents {
id
name
sort_name
}
}
23 changes: 21 additions & 2 deletions ui/v2.5/src/components/Shared/TagLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,25 @@ type SceneMarkerFragment = Pick<GQL.SceneMarker, "id" | "title" | "seconds"> & {
primary_tag: Pick<GQL.Tag, "id" | "name">;
};

interface ISortNameLinkProps{
link: string
className?: string;
sortName?: string;
}

const SortNameLinkComponent: React.FC<ISortNameLinkProps> = ({
link,
sortName,
className,
children,
}) => {
return (
<Badge data-name={className} data-sort-name={sortName} className={cx("tag-item", className)} variant="secondary">
<Link to={link}>{children}</Link>
</Badge>
);
};

interface ICommonLinkProps {
link: string;
className?: string;
Expand Down Expand Up @@ -263,7 +282,7 @@ export const TagLink: React.FC<ITagLinkProps> = ({
}, [hierarchyTooltipID]);

return (
<CommonLinkComponent link={link} className={className}>
<SortNameLinkComponent sortName={tag.sort_name || title} link={link} className={className}>
<TagPopover id={tag.id ?? ""} placement={hoverPlacement}>
{title}
{showHierarchyIcon && (
Expand All @@ -275,6 +294,6 @@ export const TagLink: React.FC<ITagLinkProps> = ({
</OverlayTrigger>
)}
</TagPopover>
</CommonLinkComponent>
</SortNameLinkComponent>
);
};
3 changes: 3 additions & 0 deletions ui/v2.5/src/components/Tags/TagDetails/TagEditPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const TagEditPanel: React.FC<ITagEditPanel> = ({

const schema = yup.object({
name: yup.string().required(),
sort_name: yup.string().ensure(),
aliases: yupUniqueAliases(intl, "name"),
description: yup.string().ensure(),
parent_ids: yup.array(yup.string().required()).defined(),
Expand All @@ -56,6 +57,7 @@ export const TagEditPanel: React.FC<ITagEditPanel> = ({

const initialValues = {
name: tag?.name ?? "",
sort_name: tag?.sort_name ?? "",
aliases: tag?.aliases ?? [],
description: tag?.description ?? "",
parent_ids: (tag?.parents ?? []).map((t) => t.id),
Expand Down Expand Up @@ -203,6 +205,7 @@ export const TagEditPanel: React.FC<ITagEditPanel> = ({

<Form noValidate onSubmit={formik.handleSubmit} id="tag-edit">
{renderInputField("name")}
{renderInputField("sort_name", "text")}
{renderStringListField("aliases")}
{renderInputField("description", "textarea")}
{renderParentTagsField()}
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 @@ -1158,6 +1158,7 @@
"megabits_per_second": "{value} mbps",
"metadata": "Metadata",
"name": "Name",
"sort_name": "Sort Name",
"new": "New",
"none": "None",
"o_count": "O Count",
Expand Down
1 change: 1 addition & 0 deletions ui/v2.5/src/utils/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ const makePerformerImagesUrl = (
export interface INamedObject {
id: string;
name?: string;
sort_name?: string;
}

const makePerformerGalleriesUrl = (
Expand Down

0 comments on commit e627391

Please sign in to comment.