From 962fd60eb6dae281d9a2eedf94daa658c8038d87 Mon Sep 17 00:00:00 2001 From: Andrew Crowther Date: Wed, 20 Nov 2024 13:34:37 -0500 Subject: [PATCH 1/2] CARDS-2606: Improve delete dialog with long names - Remove entry name from delete dialog title - Split the entry name onto a new line for the first delete dialog - Add quotations around the entry name in the recursive deletion dialog - Add capitalization to enty label/type when it is the first word in a sentence --- .../frontend/src/dataHomepage/DeleteButton.jsx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/modules/data-entry/src/main/frontend/src/dataHomepage/DeleteButton.jsx b/modules/data-entry/src/main/frontend/src/dataHomepage/DeleteButton.jsx index 470dc3dcfb..fa4e103ba9 100644 --- a/modules/data-entry/src/main/frontend/src/dataHomepage/DeleteButton.jsx +++ b/modules/data-entry/src/main/frontend/src/dataHomepage/DeleteButton.jsx @@ -45,7 +45,8 @@ function DeleteButton(props) { const [ deletionInProgress, setDeletionInProgress ] = useState(false); const buttonText = label || ("Delete " + (entryType?.toLowerCase() || '')).trim(); - const defaultDialogAction = `Are you sure you want to delete ${entryType} ${entryName}?`; + const defaultDialogMessage = `Are you sure you want to delete the following ${entryType}:`; + const defaultDialogAction = entryName; const defaultErrorMessage = `${entryName || "The item"} could not be removed.`; const history = useHistory(); @@ -98,6 +99,10 @@ function DeleteButton(props) { } } + let capitalize = (text) => { + return text.charAt(0).toUpperCase() + text.slice(1); + } + let handleJsonError = (status, json) => { if (status === 409) { if (deleteRecursive) { @@ -106,8 +111,8 @@ function DeleteButton(props) { openError(); } else { let label = entryLabel ? entryLabel.concat(' ') : entryType ? entryType.concat(' ') : ''; - setDialogMessage(`${json["status.message"].replace("This item", label + entryName)}`); - setDialogAction(`Would you like to delete ${entryName} and all items that reference it?`); + setDialogMessage(`${json["status.message"].replace("This item", capitalize(label) + '"' + entryName + '"')}`); + setDialogAction(`Would you like to delete this ${label.toLowerCase()} and all items that reference it?`); setDeleteRecursive(true); openDialog(); } @@ -150,7 +155,7 @@ function DeleteButton(props) { let handleClick = () => { onClick?.(); - setDialogMessage(null); + setDialogMessage(defaultDialogMessage); setDialogAction(defaultDialogAction); setDeleteRecursive(false); openDialog(); @@ -171,7 +176,7 @@ function DeleteButton(props) { - Delete {entryLabel ? entryLabel.concat(' ') : ''}{entryName}{deleteRecursive ? " and dependent items": null } + Delete {entryLabel ? entryLabel.concat(' ') : entryType.concat(' ')}{deleteRecursive ? " and dependent items": null } {dialogMessage} From effaf9086ec38d21f6ecaf9f1c92c4ca8fca96d5 Mon Sep 17 00:00:00 2001 From: Andrew Crowther Date: Tue, 26 Nov 2024 10:08:02 -0500 Subject: [PATCH 2/2] CARDS-2606: Improve delete dialog with long names - Minor improvement to error text --- .../src/main/frontend/src/dataHomepage/DeleteButton.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/data-entry/src/main/frontend/src/dataHomepage/DeleteButton.jsx b/modules/data-entry/src/main/frontend/src/dataHomepage/DeleteButton.jsx index fa4e103ba9..272b893bfd 100644 --- a/modules/data-entry/src/main/frontend/src/dataHomepage/DeleteButton.jsx +++ b/modules/data-entry/src/main/frontend/src/dataHomepage/DeleteButton.jsx @@ -47,7 +47,7 @@ function DeleteButton(props) { const buttonText = label || ("Delete " + (entryType?.toLowerCase() || '')).trim(); const defaultDialogMessage = `Are you sure you want to delete the following ${entryType}:`; const defaultDialogAction = entryName; - const defaultErrorMessage = `${entryName || "The item"} could not be removed.`; + const defaultErrorMessage = `The ${entryType?.toLowerCase() || "item"} could not be removed.`; const history = useHistory(); const globalLoginDisplay = useContext(GlobalLoginContext);