From 881dba0311967d9c3503b3107a017fbb433a9012 Mon Sep 17 00:00:00 2001 From: Miriam Shams-Rainey Date: Thu, 27 Oct 2022 02:42:52 -0400 Subject: [PATCH] Editable Action Label (#895) * #513: Added Customizable Icons for Ratings Field * #513: Customizable Rating Icons Side Drawer Also updated formatting of custom rating icons to match default star sz * #513: Rating customization preview uses MUIRatings * #513: Using star icon outline for visibility * Added customization for action name/label * Update src/components/fields/Rating/Settings.tsx --- src/components/fields/Action/Settings.tsx | 28 ++++++++++++++++++- .../fields/Action/SideDrawerField.tsx | 3 +- src/components/fields/Action/TableCell.tsx | 10 ++++++- src/components/fields/Rating/Settings.tsx | 1 + 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/src/components/fields/Action/Settings.tsx b/src/components/fields/Action/Settings.tsx index 0c0655b1..74e64aaa 100644 --- a/src/components/fields/Action/Settings.tsx +++ b/src/components/fields/Action/Settings.tsx @@ -559,6 +559,32 @@ const Settings = ({ config, onChange, fieldName }: ISettingsProps) => { title: "Customization", content: ( <> + + + onChange("customName.enabled")(e.target.checked) + } + name="customName.enabled" + /> + } + label="Customize label for action" + style={{ marginLeft: -11 }} + /> + {config.customName?.enabled && ( + + onChange("customName.actionName")(e.target.value) + } + label="Action name:" + className="labelHorizontal" + inputProps={{ style: { width: "10ch" } }} + > + )} { label="Customize button icons with emoji" style={{ marginLeft: -11 }} /> - + {config.customIcons?.enabled && ( diff --git a/src/components/fields/Action/SideDrawerField.tsx b/src/components/fields/Action/SideDrawerField.tsx index a4d8a6dc..ed734b70 100644 --- a/src/components/fields/Action/SideDrawerField.tsx +++ b/src/components/fields/Action/SideDrawerField.tsx @@ -10,6 +10,7 @@ import ActionFab from "./ActionFab"; import { tableScope, tableRowsAtom } from "@src/atoms/tableScope"; import { fieldSx, getFieldId } from "@src/components/SideDrawer/utils"; import { sanitiseCallableName, isUrl } from "./utils"; +import { getActionName } from "./TableCell" export default function Action({ column, @@ -60,7 +61,7 @@ export default function Action({ ) : hasRan ? ( value.status ) : ( - sanitiseCallableName(column.key) + sanitiseCallableName(getActionName(column)) )} diff --git a/src/components/fields/Action/TableCell.tsx b/src/components/fields/Action/TableCell.tsx index d762d913..4c09fd61 100644 --- a/src/components/fields/Action/TableCell.tsx +++ b/src/components/fields/Action/TableCell.tsx @@ -4,6 +4,14 @@ import { Stack } from "@mui/material"; import ActionFab from "./ActionFab"; import { sanitiseCallableName, isUrl } from "./utils"; +import { get } from "lodash-es"; + + +export const getActionName = (column: any) => { + const config = get(column, "config") + if (!get(config, "customName.enabled")) { return get(column, "name") } + return get(config, "customName.actionName") || get(column, "name"); +}; export default function Action({ column, @@ -29,7 +37,7 @@ export default function Action({ ) : hasRan ? ( value.status ) : ( - sanitiseCallableName(column.key) + sanitiseCallableName(getActionName(column)) )} diff --git a/src/components/fields/Rating/Settings.tsx b/src/components/fields/Rating/Settings.tsx index 6134b530..3ca64483 100644 --- a/src/components/fields/Rating/Settings.tsx +++ b/src/components/fields/Rating/Settings.tsx @@ -22,6 +22,7 @@ export default function Settings({ onChange, config }: ISettingsProps) { if (input > 20) { input = 20 } onChange("max")(input); }} + inputProps={{ min: 1, max: 20 }} />