فهرست منبع

feat/integrate number to grid

Mike Abebe 2 سال پیش
والد
کامیت
764ec73e94

+ 6 - 3
frontend/appflowy_tauri/src/appflowy_app/components/grid/GridCell/GridCell.tsx

@@ -10,6 +10,7 @@ import GridTextCell from './GridTextCell';
 import { GridCheckBox } from './GridCheckBox';
 import { GridDate } from './GridDate';
 import { GridUrl } from './GridUrl';
+import { GridNumberCell } from './GridNumberCell';
 
 export const GridCell = ({
   cellIdentifier,
@@ -22,9 +23,9 @@ export const GridCell = ({
 }) => {
   return (
     <>
-      {cellIdentifier.fieldType === FieldType.MultiSelect || cellIdentifier.fieldType === FieldType.Checklist ? (
-        <p> Select solutions</p>
-      ) : cellIdentifier.fieldType === FieldType.SingleSelect ? (
+      {cellIdentifier.fieldType === FieldType.MultiSelect ||
+      cellIdentifier.fieldType === FieldType.Checklist ||
+      cellIdentifier.fieldType === FieldType.SingleSelect ? (
         <GridSingleSelectOptions
           cellIdentifier={cellIdentifier}
           cellCache={cellCache}
@@ -36,6 +37,8 @@ export const GridCell = ({
         <GridDate cellIdentifier={cellIdentifier} cellCache={cellCache} fieldController={fieldController}></GridDate>
       ) : cellIdentifier.fieldType === FieldType.URL ? (
         <GridUrl cellIdentifier={cellIdentifier} cellCache={cellCache} fieldController={fieldController}></GridUrl>
+      ) : cellIdentifier.fieldType === FieldType.Number ? (
+        <GridNumberCell cellIdentifier={cellIdentifier} cellCache={cellCache} fieldController={fieldController} />
       ) : (
         <GridTextCell cellIdentifier={cellIdentifier} cellCache={cellCache} fieldController={fieldController} />
       )}

+ 25 - 0
frontend/appflowy_tauri/src/appflowy_app/components/grid/GridCell/GridNumberCell.tsx

@@ -0,0 +1,25 @@
+import { CellIdentifier } from '@/appflowy_app/stores/effects/database/cell/cell_bd_svc';
+import { CellCache } from '@/appflowy_app/stores/effects/database/cell/cell_cache';
+import { FieldController } from '@/appflowy_app/stores/effects/database/field/field_controller';
+import { useCell } from '../../_shared/database-hooks/useCell';
+import { EditCellNumber } from '../../_shared/EditRow/EditCellNumber';
+
+export const GridNumberCell = ({
+  cellIdentifier,
+  cellCache,
+  fieldController,
+}: {
+  cellIdentifier: CellIdentifier;
+  cellCache: CellCache;
+  fieldController: FieldController;
+}) => {
+  const { data, cellController } = useCell(cellIdentifier, cellCache, fieldController);
+
+  return (
+    <div className='w-full'>
+      {cellController && (
+        <EditCellNumber data={data as string | undefined} cellController={cellController}></EditCellNumber>
+      )}
+    </div>
+  );
+};

+ 0 - 1
frontend/appflowy_tauri/src/appflowy_app/components/grid/GridCell/GridTextCell.tsx

@@ -1,7 +1,6 @@
 import { CellIdentifier } from '@/appflowy_app/stores/effects/database/cell/cell_bd_svc';
 import { CellCache } from '@/appflowy_app/stores/effects/database/cell/cell_cache';
 import { FieldController } from '@/appflowy_app/stores/effects/database/field/field_controller';
-import { useState, useEffect } from 'react';
 import { useCell } from '../../_shared/database-hooks/useCell';
 import { EditCellText } from '../../_shared/EditRow/EditCellText';