From ae7911625977235f371ee95ec4004ff6a6239719 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 18 Jul 2022 05:06:39 +0200 Subject: [PATCH] Change ToolToggleEditing behaviour to "Edit / Save" --- .../events/toolbar/toolToggleEditing.tsx | 20 +++++++------------ pages/events/[slug].tsx | 2 +- public/locales/it-IT/common.json | 4 +++- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/components/events/toolbar/toolToggleEditing.tsx b/components/events/toolbar/toolToggleEditing.tsx index b7fbb00..7910c41 100644 --- a/components/events/toolbar/toolToggleEditing.tsx +++ b/components/events/toolbar/toolToggleEditing.tsx @@ -1,4 +1,4 @@ -import { faBinoculars, faPencil } from "@fortawesome/free-solid-svg-icons" +import { faPencil, faSave } from "@fortawesome/free-solid-svg-icons" import { useTranslation } from "next-i18next" import { useDefinedContext } from "../../../utils/definedContext" import { EditingContext, EditingMode } from "../../generic/editable/base" @@ -7,42 +7,36 @@ import { Tool } from "../../generic/toolbar/tool" export type ToolToggleEditingProps = { - onViewStart?: () => void, - onViewEnd?: () => void, - onEditStart?: () => void, - onEditEnd?: () => void, + save: () => void, } /** * ToolBar {@link Tool} which switches between {@link EditingMode}s of the surrounding context. */ -export function ToolToggleEditing({ onViewStart, onViewEnd, onEditStart, onEditEnd }: ToolToggleEditingProps) { +export function ToolToggleEditing({ save }: ToolToggleEditingProps) { const { t } = useTranslation() const [editing, setEditing] = useDefinedContext(EditingContext) if (editing === EditingMode.EDIT) { return ( { - onEditEnd?.() + save() setEditing(EditingMode.VIEW) - onViewStart?.() }} > - + ) } else { return ( { - onViewEnd?.() setEditing(EditingMode.EDIT) - onEditStart?.() }} > diff --git a/pages/events/[slug].tsx b/pages/events/[slug].tsx index 80000e4..deace73 100644 --- a/pages/events/[slug].tsx +++ b/pages/events/[slug].tsx @@ -99,7 +99,7 @@ const PageEvent: NextPage = ({ slug }) => { {data && auth?.userId === data?.creatorId && } diff --git a/public/locales/it-IT/common.json b/public/locales/it-IT/common.json index be697b7..5963c79 100644 --- a/public/locales/it-IT/common.json +++ b/public/locales/it-IT/common.json @@ -15,5 +15,7 @@ "landingEventsCreateSubmitLabel": "Crea evento", "landingEventsCreatePending": "Creazione dell'evento in corso...", "landingEventsCreateRejected": "Creazione dell'evento fallita:", - "landingEventsCreateFulfilled": "Evento creato con successo! Trasferimento alla pagina dell'evento in corso..." + "landingEventsCreateFulfilled": "Evento creato con successo! Trasferimento alla pagina dell'evento in corso...", + "toolToggleEditingSave": "Salva modifiche", + "toolToggleEditingEdit": "Modifica" } \ No newline at end of file