Improved languages profile edit modal to clarify subtitles types.

pull/2078/head v1.1.5-beta.26
morpheus65535 2 years ago
parent 2e8203f0d4
commit ef46ab9261

@ -9,6 +9,7 @@ import {
Accordion, Accordion,
Button, Button,
Checkbox, Checkbox,
Select,
Stack, Stack,
Switch, Switch,
Text, Text,
@ -34,6 +35,21 @@ const defaultCutoffOptions: SelectorOption<Language.ProfileItem>[] = [
}, },
]; ];
const subtitlesTypeOptions: SelectorOption<string>[] = [
{
label: "Normal or hearing-impaired",
value: "normal",
},
{
label: "Hearing-impaired required",
value: "hi",
},
{
label: "Forced (foreign part only)",
value: "forced",
},
];
interface Props { interface Props {
onComplete?: (profile: Language.Profile) => void; onComplete?: (profile: Language.Profile) => void;
languages: readonly Language.Info[]; languages: readonly Language.Info[];
@ -157,43 +173,38 @@ const ProfileEditForm: FunctionComponent<Props> = ({
}, },
}, },
{ {
Header: "Forced", Header: "Subtitles Type",
accessor: "forced", accessor: "forced",
Cell: ({ row: { original: item, index }, value }) => { Cell: ({ row: { original: item, index }, value }) => {
const selectValue = useMemo(() => {
if (item.forced === "True") {
return "forced";
} else if (item.hi === "True") {
return "hi";
} else {
return "normal";
}
}, [item.forced, item.hi]);
return ( return (
<Checkbox <Select
checked={value === "True"} value={selectValue}
onChange={({ currentTarget: { checked } }) => { data={subtitlesTypeOptions}
action.mutate(index, { onChange={(value) => {
...item, if (value) {
forced: checked ? "True" : "False",
hi: checked ? "False" : item.hi,
});
}}
></Checkbox>
);
},
},
{
Header: "HI",
accessor: "hi",
Cell: ({ row: { original: item, index }, value }) => {
return (
<Checkbox
checked={value === "True"}
onChange={({ currentTarget: { checked } }) => {
action.mutate(index, { action.mutate(index, {
...item, ...item,
hi: checked ? "True" : "False", hi: value === "hi" ? "True" : "False",
forced: checked ? "False" : item.forced, forced: value === "forced" ? "True" : "False",
}); });
}
}} }}
></Checkbox> ></Select>
); );
}, },
}, },
{ {
Header: "Exclude Audio", Header: "Exclude If Matching Audio",
accessor: "audio_exclude", accessor: "audio_exclude",
Cell: ({ row: { original: item, index }, value }) => { Cell: ({ row: { original: item, index }, value }) => {
return ( return (
@ -317,8 +328,6 @@ export const ProfileEditModal = withModal(
"languages-profile-editor", "languages-profile-editor",
{ {
title: "Edit Languages Profile", title: "Edit Languages Profile",
size: "lg", size: "xl",
} }
); );
export default ProfileEditForm;

Loading…
Cancel
Save