From ec5714e3ec1a9e2be62eea3e87b24fae0ca1151d Mon Sep 17 00:00:00 2001 From: francisco aloi Date: Tue, 31 Dec 2024 18:49:32 +0100 Subject: [PATCH] more style changes, changelog and locale --- CHANGELOG.md | 1 + .../components/NameManager/NameManagerDialog.tsx | 11 ++++++----- .../components/NameManager/NamedRangeActive.tsx | 14 ++++++++++---- .../components/NameManager/NamedRangeInactive.tsx | 15 +++++++++------ webapp/src/locale/en_us.json | 3 ++- 5 files changed, 28 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f83f4c..8f2179b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - New function UNICODE ([#128](https://github.com/ironcalc/IronCalc/pull/128)) - New document server (Thanks Dani!) - New function FORMULATEXT +- Name Manager ([#212](https://github.com/ironcalc/IronCalc/pull/212) [#220](https://github.com/ironcalc/IronCalc/pull/220)) ### Fixed diff --git a/webapp/src/components/NameManager/NameManagerDialog.tsx b/webapp/src/components/NameManager/NameManagerDialog.tsx index 2f2e042..a10cec8 100644 --- a/webapp/src/components/NameManager/NameManagerDialog.tsx +++ b/webapp/src/components/NameManager/NameManagerDialog.tsx @@ -34,14 +34,12 @@ function NameManagerDialog(properties: NameManagerDialogProperties) { const worksheets = model.getWorksheetsProperties(); const definedNameList = model.getDefinedNameList(); - // reset modal state in case editing was in progress useEffect(() => { if (open) { setEditingNameIndex(-2); } }, [open]); - // enable/disable options while editing useEffect(() => { if (editingNameIndex !== -2) { setShowOptions(false); @@ -94,7 +92,7 @@ function NameManagerDialog(properties: NameManagerDialogProperties) { name={definedName.name} scope={definedName.scope} formula={definedName.formula} - key={definedName.name} + key={definedName.name + definedName.scope} onSave={handleSave} onCancel={() => setEditingNameIndex(-2)} /> @@ -107,7 +105,7 @@ function NameManagerDialog(properties: NameManagerDialogProperties) { name={definedName.name} scope={definedName.scope} formula={definedName.formula} - key={definedName.name} + key={definedName.name + definedName.scope} showOptions={showOptions} onEdit={() => setEditingNameIndex(index)} onDelete={handleDelete} @@ -151,12 +149,14 @@ function NameManagerDialog(properties: NameManagerDialogProperties) { const StyledDialog = styled(Dialog)(() => ({ "& .MuiPaper-root": { height: "380px", + minHeight: "200px", minWidth: "620px", }, })); const StyledDialogTitle = styled(DialogTitle)` padding: 12px 20px; +height: 20px; font-size: 14px; font-weight: 600; display: flex; @@ -170,7 +170,7 @@ const NameListWrapper = styled(Stack)` `; const StyledBox = styled(Box)` -width: 171px; +width: 161.67px; `; const StyledDialogContent = styled(DialogContent)` @@ -182,6 +182,7 @@ padding: 20px 12px 20px 20px; const StyledRangesHeader = styled(Stack)(({ theme }) => ({ flexDirection: "row", + padding: "0 8px", gap: "12px", fontFamily: theme.typography.fontFamily, fontSize: "12px", diff --git a/webapp/src/components/NameManager/NamedRangeActive.tsx b/webapp/src/components/NameManager/NamedRangeActive.tsx index 5df5c12..72b1b32 100644 --- a/webapp/src/components/NameManager/NamedRangeActive.tsx +++ b/webapp/src/components/NameManager/NamedRangeActive.tsx @@ -33,10 +33,11 @@ function NamedRangeActive(properties: NamedRangeProperties) { const [nameError, setNameError] = useState(false); const [formulaError, setFormulaError] = useState(false); + //todo: move logic to NameManagerDialog const handleSaveUpdate = () => { const definedNamesModel = model.getDefinedNameList(); - if (definedNamesModel.find((n) => n.name === name)) { + if (definedNamesModel.find((n) => n.name === name && n.scope === scope)) { try { model.updateDefinedName(name, scope, newName, newScope, newFormula); } catch (error) { @@ -84,7 +85,7 @@ function NamedRangeActive(properties: NamedRangeProperties) { }} > - {t("name_manager_dialog.workbook")} + {`${t("name_manager_dialog.workbook")} ${t("name_manager_dialog.global")}`} {worksheets.map((option, index) => ( @@ -106,14 +107,14 @@ function NamedRangeActive(properties: NamedRangeProperties) { }} onClick={(event) => event.stopPropagation()} /> - <> + - + @@ -129,6 +130,7 @@ width: 577px; const StyledTextField = styled(TextField)(() => ({ "& .MuiInputBase-root": { height: "28px", + width: "161.67px", margin: 0, fontFamily: "Inter", fontSize: "12px", @@ -150,4 +152,8 @@ const StyledCheck = styled(Check)(({ theme }) => ({ color: theme.palette.success.main, })); +const IconsWrapper = styled(Box)({ + display: "flex", +}); + export default NamedRangeActive; diff --git a/webapp/src/components/NameManager/NamedRangeInactive.tsx b/webapp/src/components/NameManager/NamedRangeInactive.tsx index 4f198ec..c8f8feb 100644 --- a/webapp/src/components/NameManager/NamedRangeInactive.tsx +++ b/webapp/src/components/NameManager/NamedRangeInactive.tsx @@ -26,6 +26,7 @@ function NamedRangeInactive(properties: NamedRangeInactiveProperties) { showOptions, } = properties; + //todo: move logic to NameManagerDialog const handleDelete = () => { try { model.deleteDefinedName(name, scope); @@ -35,9 +36,10 @@ function NamedRangeInactive(properties: NamedRangeInactiveProperties) { onDelete(); }; + //todo: pass the name, avoid logic const scopeName = worksheets.find((sheet, index) => index === scope)?.name || - t("name_manager_dialog.workbook"); + `${t("name_manager_dialog.workbook")} ${t("name_manager_dialog.global")}`; return ( <> @@ -45,14 +47,14 @@ function NamedRangeInactive(properties: NamedRangeInactiveProperties) { {name} {scopeName} {formula} - + - + @@ -75,6 +77,7 @@ const WrappedLine = styled(Box)({ display: "flex", height: "28px", alignItems: "center", + gap: "12px", }); const StyledDiv = styled("div")(({ theme }) => ({ @@ -82,12 +85,12 @@ const StyledDiv = styled("div")(({ theme }) => ({ fontSize: "12px", fontWeight: "400", color: theme.palette.common.black, - width: "171px", + width: "153.67px", + paddingLeft: "8px", })); -const WrappedIcons = styled(Box)({ +const IconsWrapper = styled(Box)({ display: "flex", - gap: "0px", }); export default NamedRangeInactive; diff --git a/webapp/src/locale/en_us.json b/webapp/src/locale/en_us.json index ee4d93c..172af24 100644 --- a/webapp/src/locale/en_us.json +++ b/webapp/src/locale/en_us.json @@ -84,6 +84,7 @@ "scope": "Range", "help": "Learn more about Named Ranges", "new": "Add new", - "workbook": "Workbook (Global)" + "workbook": "Workbook", + "global": "(Global)" } }