From c632c32871887ac950c7b0fde485218b08bca7f7 Mon Sep 17 00:00:00 2001 From: JacobHaimes <42851286+JacobHaimes@users.noreply.github.com> Date: Thu, 24 Jun 2021 18:44:21 -0400 Subject: [PATCH 1/6] Created warning box when finding and reaplacing characters --- .../FindAndReplace/CharacterReplaceDialog.tsx | 54 +++++++++++++++++++ .../FindAndReplaceComponent.tsx | 34 +++++++++--- 2 files changed, 82 insertions(+), 6 deletions(-) create mode 100644 src/goals/CharInventoryCreation/components/CharacterDetail/FindAndReplace/CharacterReplaceDialog.tsx diff --git a/src/goals/CharInventoryCreation/components/CharacterDetail/FindAndReplace/CharacterReplaceDialog.tsx b/src/goals/CharInventoryCreation/components/CharacterDetail/FindAndReplace/CharacterReplaceDialog.tsx new file mode 100644 index 0000000000..acb2835b63 --- /dev/null +++ b/src/goals/CharInventoryCreation/components/CharacterDetail/FindAndReplace/CharacterReplaceDialog.tsx @@ -0,0 +1,54 @@ +import { + Button, + Dialog, + DialogActions, + DialogContent, + DialogContentText, + DialogTitle, +} from "@material-ui/core"; +import { Translate } from "react-localize-redux"; + +interface ReplaceDialogProps { + open: boolean; + textId?: string; + dialogFindValue: string; + dialogReplaceValue: string; + handleAccept: () => void; + handleCancel: () => void; +} + +/** + * Dialog to confirm replacement + */ +export default function CharacterReplaceDialog(props: ReplaceDialogProps) { + return ( + + + + + + + Replace all occurrences of "{props.dialogFindValue}" + with "{props.dialogReplaceValue}" ? + + + + + + + + ); +} diff --git a/src/goals/CharInventoryCreation/components/CharacterDetail/FindAndReplace/FindAndReplaceComponent.tsx b/src/goals/CharInventoryCreation/components/CharacterDetail/FindAndReplace/FindAndReplaceComponent.tsx index 656137a19e..8725227a12 100644 --- a/src/goals/CharInventoryCreation/components/CharacterDetail/FindAndReplace/FindAndReplaceComponent.tsx +++ b/src/goals/CharInventoryCreation/components/CharacterDetail/FindAndReplace/FindAndReplaceComponent.tsx @@ -1,6 +1,8 @@ import { Button, TextField, Typography } from "@material-ui/core"; import React from "react"; import { LocalizeContextProps, withLocalize } from "react-localize-redux"; +import CharacterReplaceDialog from "goals/CharInventoryCreation/components/CharacterDetail/FindAndReplace/CharacterReplaceDialog"; +import CharacterInfo from "goals/CharInventoryCreation/components/CharacterDetail/CharacterInfo"; interface FindAndReplaceProps { initialFindValue: string; @@ -11,6 +13,7 @@ interface FindAndReplaceProps { interface FindAndReplaceState { findValue: string; replaceValue: string; + warningDialogOpen: boolean; } export class FindAndReplace extends React.Component< @@ -20,6 +23,7 @@ export class FindAndReplace extends React.Component< constructor(props: FindAndReplaceProps & LocalizeContextProps) { super(props); this.state = { + warningDialogOpen: false, findValue: props.initialFindValue, replaceValue: "", }; @@ -74,15 +78,33 @@ export class FindAndReplace extends React.Component< /> + { + this.setState(() => ({ + warningDialogOpen: false, + })); + }} + handleAccept={() => { + this.setState(() => ({ + warningDialogOpen: false, + })); + this.props.findAndReplace( + this.state.findValue, + this.state.replaceValue + ); + }} + > ); } From c2bdade69863fc2e3f7dd1a560f80f3a3fe2f168 Mon Sep 17 00:00:00 2001 From: JacobHaimes <42851286+JacobHaimes@users.noreply.github.com> Date: Thu, 24 Jun 2021 18:55:09 -0400 Subject: [PATCH 2/6] fixed lint issues --- .../CharacterDetail/FindAndReplace/FindAndReplaceComponent.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/goals/CharInventoryCreation/components/CharacterDetail/FindAndReplace/FindAndReplaceComponent.tsx b/src/goals/CharInventoryCreation/components/CharacterDetail/FindAndReplace/FindAndReplaceComponent.tsx index 8725227a12..f00466b2b6 100644 --- a/src/goals/CharInventoryCreation/components/CharacterDetail/FindAndReplace/FindAndReplaceComponent.tsx +++ b/src/goals/CharInventoryCreation/components/CharacterDetail/FindAndReplace/FindAndReplaceComponent.tsx @@ -2,7 +2,6 @@ import { Button, TextField, Typography } from "@material-ui/core"; import React from "react"; import { LocalizeContextProps, withLocalize } from "react-localize-redux"; import CharacterReplaceDialog from "goals/CharInventoryCreation/components/CharacterDetail/FindAndReplace/CharacterReplaceDialog"; -import CharacterInfo from "goals/CharInventoryCreation/components/CharacterDetail/CharacterInfo"; interface FindAndReplaceProps { initialFindValue: string; From 4e9f0c860981b23143c783c25e438565a2c69749 Mon Sep 17 00:00:00 2001 From: JacobHaimes <42851286+JacobHaimes@users.noreply.github.com> Date: Fri, 25 Jun 2021 16:35:11 -0400 Subject: [PATCH 3/6] simplified tag --- .../CharacterDetail/FindAndReplace/FindAndReplaceComponent.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/goals/CharInventoryCreation/components/CharacterDetail/FindAndReplace/FindAndReplaceComponent.tsx b/src/goals/CharInventoryCreation/components/CharacterDetail/FindAndReplace/FindAndReplaceComponent.tsx index f00466b2b6..cca9a284a7 100644 --- a/src/goals/CharInventoryCreation/components/CharacterDetail/FindAndReplace/FindAndReplaceComponent.tsx +++ b/src/goals/CharInventoryCreation/components/CharacterDetail/FindAndReplace/FindAndReplaceComponent.tsx @@ -103,7 +103,7 @@ export class FindAndReplace extends React.Component< this.state.replaceValue ); }} - > + /> ); } From 470708bd130e63261d6fd3c0307ae6f6191ce779 Mon Sep 17 00:00:00 2001 From: JacobHaimes <42851286+JacobHaimes@users.noreply.github.com> Date: Mon, 28 Jun 2021 15:44:52 -0400 Subject: [PATCH 4/6] Solution for localization --- .../FindAndReplace/CharacterReplaceDialog.tsx | 6 ++++-- .../FindAndReplace/FindAndReplaceComponent.tsx | 2 +- src/resources/translations.json | 8 +++++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/goals/CharInventoryCreation/components/CharacterDetail/FindAndReplace/CharacterReplaceDialog.tsx b/src/goals/CharInventoryCreation/components/CharacterDetail/FindAndReplace/CharacterReplaceDialog.tsx index acb2835b63..0ad59f2d57 100644 --- a/src/goals/CharInventoryCreation/components/CharacterDetail/FindAndReplace/CharacterReplaceDialog.tsx +++ b/src/goals/CharInventoryCreation/components/CharacterDetail/FindAndReplace/CharacterReplaceDialog.tsx @@ -33,8 +33,10 @@ export default function CharacterReplaceDialog(props: ReplaceDialogProps) { - Replace all occurrences of "{props.dialogFindValue}" - with "{props.dialogReplaceValue}" ? + : " + {props.dialogFindValue}"
+ : " + {props.dialogReplaceValue}" ?
diff --git a/src/goals/CharInventoryCreation/components/CharacterDetail/FindAndReplace/FindAndReplaceComponent.tsx b/src/goals/CharInventoryCreation/components/CharacterDetail/FindAndReplace/FindAndReplaceComponent.tsx index cca9a284a7..3629ece899 100644 --- a/src/goals/CharInventoryCreation/components/CharacterDetail/FindAndReplace/FindAndReplaceComponent.tsx +++ b/src/goals/CharInventoryCreation/components/CharacterDetail/FindAndReplace/FindAndReplaceComponent.tsx @@ -67,7 +67,7 @@ export class FindAndReplace extends React.Component< inputProps={{ maxLength: 100 }} /> this.updateField(e, "replaceValue")} variant="outlined" diff --git a/src/resources/translations.json b/src/resources/translations.json index 8b5c493f67..4ab8c7b57d 100644 --- a/src/resources/translations.json +++ b/src/resources/translations.json @@ -613,7 +613,13 @@ "advanced": ["Advanced", "Avanzado", "Avancé"], "occurrences": ["occurrences", "ocurrencias", "occurrences"], "find": ["Find", "Encontrar", "Rechercher"], - "replace": ["Replace with", "Reemplazar con", "Remplacer avec"], + "replace": ["Replace", "Replace", "Replace"], + "replaceWith": ["Replace with", "Reemplazar con", "Remplacer avec"], + "replaceAll": [ + "Replace all occurences of", + "Replace all occurences of", + "Replace all occurences of" + ], "findAndReplace": ["Find & Replace", "Find & Replace", "Find & Replace"], "apply": ["apply", "aplicar", "appliquer"], "charDetails": [ From 441637c3208cf4d2660bfa2f8515ad3bbba67a82 Mon Sep 17 00:00:00 2001 From: JacobHaimes <42851286+JacobHaimes@users.noreply.github.com> Date: Mon, 28 Jun 2021 16:21:37 -0400 Subject: [PATCH 5/6] Deleted unused property --- .../CharacterDetail/FindAndReplace/CharacterReplaceDialog.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/goals/CharInventoryCreation/components/CharacterDetail/FindAndReplace/CharacterReplaceDialog.tsx b/src/goals/CharInventoryCreation/components/CharacterDetail/FindAndReplace/CharacterReplaceDialog.tsx index 0ad59f2d57..762f1ff973 100644 --- a/src/goals/CharInventoryCreation/components/CharacterDetail/FindAndReplace/CharacterReplaceDialog.tsx +++ b/src/goals/CharInventoryCreation/components/CharacterDetail/FindAndReplace/CharacterReplaceDialog.tsx @@ -10,7 +10,6 @@ import { Translate } from "react-localize-redux"; interface ReplaceDialogProps { open: boolean; - textId?: string; dialogFindValue: string; dialogReplaceValue: string; handleAccept: () => void; From f2103a8bf8176c2b995f0ca473f832174e85c766 Mon Sep 17 00:00:00 2001 From: JacobHaimes <42851286+JacobHaimes@users.noreply.github.com> Date: Mon, 28 Jun 2021 16:42:29 -0400 Subject: [PATCH 6/6] Simplified state change functions --- .../FindAndReplace/FindAndReplaceComponent.tsx | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/goals/CharInventoryCreation/components/CharacterDetail/FindAndReplace/FindAndReplaceComponent.tsx b/src/goals/CharInventoryCreation/components/CharacterDetail/FindAndReplace/FindAndReplaceComponent.tsx index 3629ece899..54478219b7 100644 --- a/src/goals/CharInventoryCreation/components/CharacterDetail/FindAndReplace/FindAndReplaceComponent.tsx +++ b/src/goals/CharInventoryCreation/components/CharacterDetail/FindAndReplace/FindAndReplaceComponent.tsx @@ -78,9 +78,7 @@ export class FindAndReplace extends React.Component<