mirror of
https://github.com/morpheus65535/bazarr
synced 2024-12-25 17:17:12 +00:00
Bring back clear action to the mass editor
This commit is contained in:
parent
1106f78ec1
commit
839ce384c6
1 changed files with 27 additions and 7 deletions
|
@ -1,10 +1,10 @@
|
||||||
import { useIsAnyMutationRunning, useLanguageProfiles } from "@/apis/hooks";
|
import { useIsAnyMutationRunning, useLanguageProfiles } from "@/apis/hooks";
|
||||||
import { SimpleTable, Toolbox } from "@/components";
|
import { SimpleTable, Toolbox } from "@/components";
|
||||||
import { Selector } from "@/components/inputs";
|
import { Selector, SelectorOption } from "@/components/inputs";
|
||||||
import { useCustomSelection } from "@/components/tables/plugins";
|
import { useCustomSelection } from "@/components/tables/plugins";
|
||||||
import { GetItemId, useSelectorOptions } from "@/utilities";
|
import { GetItemId, useSelectorOptions } from "@/utilities";
|
||||||
import { faCheck, faUndo } from "@fortawesome/free-solid-svg-icons";
|
import { faCheck, faUndo } from "@fortawesome/free-solid-svg-icons";
|
||||||
import { Container } from "@mantine/core";
|
import { Box, Container } from "@mantine/core";
|
||||||
import { uniqBy } from "lodash";
|
import { uniqBy } from "lodash";
|
||||||
import { useCallback, useMemo, useState } from "react";
|
import { useCallback, useMemo, useState } from "react";
|
||||||
import { UseMutationResult } from "react-query";
|
import { UseMutationResult } from "react-query";
|
||||||
|
@ -36,6 +36,24 @@ function MassEditor<T extends Item.Base>(props: MassEditorProps<T>) {
|
||||||
|
|
||||||
const profileOptions = useSelectorOptions(profiles ?? [], (v) => v.name);
|
const profileOptions = useSelectorOptions(profiles ?? [], (v) => v.name);
|
||||||
|
|
||||||
|
const profileOptionsWithAction = useMemo<
|
||||||
|
SelectorOption<Language.Profile | null>[]
|
||||||
|
>(
|
||||||
|
() => [
|
||||||
|
{ label: "Clear", value: null, group: "Action" },
|
||||||
|
...profileOptions.options,
|
||||||
|
],
|
||||||
|
[profileOptions.options]
|
||||||
|
);
|
||||||
|
|
||||||
|
const getKey = useCallback((value: Language.Profile | null) => {
|
||||||
|
if (value) {
|
||||||
|
return value.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return "Clear";
|
||||||
|
}, []);
|
||||||
|
|
||||||
const { mutateAsync } = mutation;
|
const { mutateAsync } = mutation;
|
||||||
|
|
||||||
const save = useCallback(() => {
|
const save = useCallback(() => {
|
||||||
|
@ -67,15 +85,17 @@ function MassEditor<T extends Item.Base>(props: MassEditorProps<T>) {
|
||||||
return (
|
return (
|
||||||
<Container fluid px={0}>
|
<Container fluid px={0}>
|
||||||
<Toolbox>
|
<Toolbox>
|
||||||
<div>
|
<Box>
|
||||||
<Selector
|
<Selector
|
||||||
|
allowDeselect
|
||||||
placeholder="Change Profile"
|
placeholder="Change Profile"
|
||||||
{...profileOptions}
|
options={profileOptionsWithAction}
|
||||||
|
getkey={getKey}
|
||||||
disabled={selections.length === 0}
|
disabled={selections.length === 0}
|
||||||
onChange={setProfiles}
|
onChange={setProfiles}
|
||||||
></Selector>
|
></Selector>
|
||||||
</div>
|
</Box>
|
||||||
<div>
|
<Box>
|
||||||
<Toolbox.Button icon={faUndo} onClick={onEnded}>
|
<Toolbox.Button icon={faUndo} onClick={onEnded}>
|
||||||
Cancel
|
Cancel
|
||||||
</Toolbox.Button>
|
</Toolbox.Button>
|
||||||
|
@ -87,7 +107,7 @@ function MassEditor<T extends Item.Base>(props: MassEditorProps<T>) {
|
||||||
>
|
>
|
||||||
Save
|
Save
|
||||||
</Toolbox.MutateButton>
|
</Toolbox.MutateButton>
|
||||||
</div>
|
</Box>
|
||||||
</Toolbox>
|
</Toolbox>
|
||||||
<SimpleTable
|
<SimpleTable
|
||||||
columns={columns}
|
columns={columns}
|
||||||
|
|
Loading…
Reference in a new issue