Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
chore: save and get checkbox cell
ascarbek2f2736df20c4
diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/_shared/EditRow/EditCellWrapper.tsx b/frontend/appflowy_tauri/src/appflowy_app/components/_shared/EditRow/EditCellWrapper.tsxindex 64dcebf98a..3e50839f77 100644--- a/frontend/appflowy_tauri/src/appflowy_app/components/_shared/EditRow/EditCellWrapper.tsx+++ b/frontend/appflowy_tauri/src/appflowy_app/components/_shared/EditRow/EditCellWrapper.tsx@@ -76,7 +76,10 @@ export const EditCellWrapper = ({)}{cellIdentifier.fieldType === FieldType.Checkbox && cellController && (- <EditCheckboxCell data={data as boolean | undefined} cellController={cellController}></EditCheckboxCell>+ <EditCheckboxCell+ data={data as 'Yes' | 'No' | undefined}+ cellController={cellController}+ ></EditCheckboxCell>)}{cellIdentifier.fieldType === FieldType.DateTime && (diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/_shared/EditRow/EditCheckboxCell.tsx b/frontend/appflowy_tauri/src/appflowy_app/components/_shared/EditRow/EditCheckboxCell.tsxindex 25b3a50ff5..6ea688af54 100644--- a/frontend/appflowy_tauri/src/appflowy_app/components/_shared/EditRow/EditCheckboxCell.tsx+++ b/frontend/appflowy_tauri/src/appflowy_app/components/_shared/EditRow/EditCheckboxCell.tsx@@ -1,22 +1,26 @@import { EditorCheckSvg } from '$app/components/_shared/svg/EditorCheckSvg';import { EditorUncheckSvg } from '$app/components/_shared/svg/EditorUncheckSvg';-import { CellController } from '$app/stores/effects/database/cell/cell_controller';+import { CheckboxCellController } from '$app/stores/effects/database/cell/controller_builder';export const EditCheckboxCell = ({data,cellController,}: {- data: boolean | undefined;- cellController: CellController<any, any>;+ data: 'Yes' | 'No' | undefined;+ cellController: CheckboxCellController;}) => {const toggleValue = async () => {- await cellController?.saveCellData(!data);+ if (data === 'Yes') {+ await cellController?.saveCellData('No');+ } else {+ await cellController?.saveCellData('Yes');+ }};return (<div onClick={() => toggleValue()} className={'block px-4 py-2'}><button className={'h-5 w-5'}>- {data ? <EditorCheckSvg></EditorCheckSvg> : <EditorUncheckSvg></EditorUncheckSvg>}+ {data === 'Yes' ? <EditorCheckSvg></EditorCheckSvg> : <EditorUncheckSvg></EditorUncheckSvg>}</button></div>);diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/board/BoardCell.tsx b/frontend/appflowy_tauri/src/appflowy_app/components/board/BoardCell.tsxindex e478e27955..5ba97345dd 100644--- a/frontend/appflowy_tauri/src/appflowy_app/components/board/BoardCell.tsx+++ b/frontend/appflowy_tauri/src/appflowy_app/components/board/BoardCell.tsx@@ -6,6 +6,7 @@ import { BoardOptionsCell } from './BoardOptionsCell';import { BoardDateCell } from './BoardDateCell';import { BoardTextCell } from './BoardTextCell';import { BoardUrlCell } from '$app/components/board/BoardUrlCell';+import { BoardCheckboxCell } from '$app/components/board/BoardCheckboxCell';export const BoardCell = ({cellIdentifier,@@ -38,6 +39,12 @@ export const BoardCell = ({cellCache={cellCache}fieldController={fieldController}></BoardUrlCell>+ ) : cellIdentifier.fieldType === FieldType.Checkbox ? (+ <BoardCheckboxCell+ cellIdentifier={cellIdentifier}+ cellCache={cellCache}+ fieldController={fieldController}+ ></BoardCheckboxCell>) : (<BoardTextCellcellIdentifier={cellIdentifier}diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/board/BoardCheckboxCell.tsx b/frontend/appflowy_tauri/src/appflowy_app/components/board/BoardCheckboxCell.tsxnew file mode 100644index 0000000000..6df65344d3--- /dev/null+++ b/frontend/appflowy_tauri/src/appflowy_app/components/board/BoardCheckboxCell.tsx@@ -0,0 +1,23 @@+import { EditorCheckSvg } from '$app/components/_shared/svg/EditorCheckSvg';+import { EditorUncheckSvg } from '$app/components/_shared/svg/EditorUncheckSvg';+import { CellIdentifier } from '$app/stores/effects/database/cell/cell_bd_svc';+import { CellCache } from '$app/stores/effects/database/cell/cell_cache';+import { FieldController } from '$app/stores/effects/database/field/field_controller';+import { useCell } from '$app/components/_shared/database-hooks/useCell';++export const BoardCheckboxCell = ({+ cellIdentifier,+ cellCache,+ fieldController,+}: {+ cellIdentifier: CellIdentifier;+ cellCache: CellCache;+ fieldController: FieldController;+}) => {+ const { data } = useCell(cellIdentifier, cellCache, fieldController);+ return (+ <i className={'h-5 w-5'}>+ {data === 'Yes' ? <EditorCheckSvg></EditorCheckSvg> : <EditorUncheckSvg></EditorUncheckSvg>}+ </i>+ );+};