1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Fix role and type display on people cards

This commit is contained in:
Bill Thornton 2024-05-08 13:56:06 -04:00
parent ebeeaa2948
commit f002d540a2

View file

@ -4,6 +4,7 @@
* @module components/cardBuilder/cardBuilder * @module components/cardBuilder/cardBuilder
*/ */
import { PersonKind } from '@jellyfin/sdk/lib/generated-client/models/person-kind';
import escapeHtml from 'escape-html'; import escapeHtml from 'escape-html';
import browser from 'scripts/browser'; import browser from 'scripts/browser';
@ -698,8 +699,26 @@ function getCardFooterText(item, apiClient, options, footerClass, progressHtml,
} }
} }
if (options.showPersonRoleOrType && item.Role) { if (options.showPersonRoleOrType && item.Type) {
lines.push(globalize.translate('PersonRole', escapeHtml(item.Role))); if (item.Role) {
if ([ PersonKind.Actor, PersonKind.GuestStar ].includes(item.Type)) {
// List actor roles formatted like "as Character Name"
lines.push(globalize.translate('PersonRole', escapeHtml(item.Role)));
} else if (item.Role.toLowerCase() === item.Type.toLowerCase()) {
// Role and Type are the same so use the localized Type
lines.push(escapeHtml(globalize.translate(item.Type)));
} else if (item.Role.toLowerCase().includes(item.Type.toLowerCase())) {
// Avoid duplication if the Role includes the Type (i.e. Executive Producer)
lines.push(escapeHtml(item.Role));
} else {
// Type and Role are unique so list both (i.e. Writer | Novel)
lines.push(escapeHtml(globalize.translate(item.Type)));
lines.push(escapeHtml(item.Role));
}
} else {
// No Role so use the localized Type
lines.push(escapeHtml(globalize.translate(item.Type)));
}
} }
} }