From f86254c8ef74e5e6da71b2c21338a7cd24b80b92 Mon Sep 17 00:00:00 2001 From: ascarbek Date: Mon, 27 Mar 2023 18:42:23 +0600 Subject: [PATCH] chore: edit url cell --- .../_shared/EditRow/EditCellNumber.tsx | 29 +++++++++++++ .../_shared/EditRow/EditCellText.tsx | 15 +++++-- .../_shared/EditRow/EditCellUrl.tsx | 43 +++++++++++++++++++ .../_shared/EditRow/EditCellWrapper.tsx | 29 +++++++------ .../_shared/EditRow/EditCheckboxCell.tsx | 23 ++++++++++ .../components/board/BoardCell.tsx | 7 +++ .../components/board/BoardUrlCell.tsx | 29 +++++++++++++ 7 files changed, 159 insertions(+), 16 deletions(-) create mode 100644 frontend/appflowy_tauri/src/appflowy_app/components/_shared/EditRow/EditCellNumber.tsx create mode 100644 frontend/appflowy_tauri/src/appflowy_app/components/_shared/EditRow/EditCellUrl.tsx create mode 100644 frontend/appflowy_tauri/src/appflowy_app/components/_shared/EditRow/EditCheckboxCell.tsx create mode 100644 frontend/appflowy_tauri/src/appflowy_app/components/board/BoardUrlCell.tsx diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/_shared/EditRow/EditCellNumber.tsx b/frontend/appflowy_tauri/src/appflowy_app/components/_shared/EditRow/EditCellNumber.tsx new file mode 100644 index 0000000000..205ddd9257 --- /dev/null +++ b/frontend/appflowy_tauri/src/appflowy_app/components/_shared/EditRow/EditCellNumber.tsx @@ -0,0 +1,29 @@ +import { CellController } from '$app/stores/effects/database/cell/cell_controller'; +import { useEffect, useState } from 'react'; + +export const EditCellNumber = ({ + data, + cellController, +}: { + data: string | undefined; + cellController: CellController; +}) => { + const [value, setValue] = useState(''); + + useEffect(() => { + setValue(data || ''); + }, [data]); + + const save = async () => { + await cellController?.saveCellData(value); + }; + + return ( + setValue(e.target.value)} + onBlur={() => save()} + className={'w-full px-4 py-2'} + > + ); +}; diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/_shared/EditRow/EditCellText.tsx b/frontend/appflowy_tauri/src/appflowy_app/components/_shared/EditRow/EditCellText.tsx index 357fbac9d7..65c09e9880 100644 --- a/frontend/appflowy_tauri/src/appflowy_app/components/_shared/EditRow/EditCellText.tsx +++ b/frontend/appflowy_tauri/src/appflowy_app/components/_shared/EditRow/EditCellText.tsx @@ -1,11 +1,18 @@ import { CellController } from '$app/stores/effects/database/cell/cell_controller'; import { useEffect, useState, KeyboardEvent, useMemo } from 'react'; -export const EditCellText = ({ data, cellController }: { data: string; cellController: CellController }) => { +export const EditCellText = ({ + data, + cellController, +}: { + data: string | undefined; + cellController: CellController; +}) => { const [value, setValue] = useState(''); const [contentRows, setContentRows] = useState(1); + useEffect(() => { - setValue(data); + setValue(data || ''); }, [data]); useEffect(() => { @@ -21,9 +28,9 @@ export const EditCellText = ({ data, cellController }: { data: string; cellContr }; return ( -
+