mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
feat/show edit popup on expand icon click
This commit is contained in:
parent
7970e7fae3
commit
da45531801
@ -0,0 +1,10 @@
|
|||||||
|
export const FullView = () => {
|
||||||
|
return (
|
||||||
|
<svg width='100%' height='100%' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'>
|
||||||
|
<path d='M6 13H3V10' stroke='#333333' strokeLinecap='round' strokeLinejoin='round' />
|
||||||
|
<path d='M10 3H13V6' stroke='#333333' strokeLinecap='round' strokeLinejoin='round' />
|
||||||
|
<path d='M3 13L7 9' stroke='#333333' strokeLinecap='round' strokeLinejoin='round' />
|
||||||
|
<path d='M13 3L9 7' stroke='#333333' strokeLinecap='round' strokeLinejoin='round' />
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
};
|
@ -1,11 +1,13 @@
|
|||||||
import { CellIdentifier } from '../../stores/effects/database/cell/cell_bd_svc';
|
import { CellIdentifier } from '../../stores/effects/database/cell/cell_bd_svc';
|
||||||
import { CellCache } from '../../stores/effects/database/cell/cell_cache';
|
import { CellCache } from '../../stores/effects/database/cell/cell_cache';
|
||||||
import { FieldController } from '../../stores/effects/database/field/field_controller';
|
import { FieldController } from '../../stores/effects/database/field/field_controller';
|
||||||
import { FieldType } from '../../../services/backend';
|
import { FieldType, SelectOptionCellDataPB } from '../../../services/backend';
|
||||||
import { BoardOptionsCell } from './BoardOptionsCell';
|
import { BoardOptionsCell } from './BoardOptionsCell';
|
||||||
import { BoardDateCell } from './BoardDateCell';
|
import { BoardDateCell } from './BoardDateCell';
|
||||||
import { BoardTextCell } from './BoardTextCell';
|
import { BoardTextCell } from './BoardTextCell';
|
||||||
import { BoardUrlCell } from '$app/components/board/BoardUrlCell';
|
import { BoardUrlCell } from '$app/components/board/BoardUrlCell';
|
||||||
|
import { useCell } from '../_shared/database-hooks/useCell';
|
||||||
|
import { CellOptions } from '../_shared/EditRow/CellOptions';
|
||||||
|
|
||||||
export const BoardCell = ({
|
export const BoardCell = ({
|
||||||
cellIdentifier,
|
cellIdentifier,
|
||||||
@ -16,16 +18,19 @@ export const BoardCell = ({
|
|||||||
cellCache: CellCache;
|
cellCache: CellCache;
|
||||||
fieldController: FieldController;
|
fieldController: FieldController;
|
||||||
}) => {
|
}) => {
|
||||||
|
const { data, cellController } = useCell(cellIdentifier, cellCache, fieldController);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{cellIdentifier.fieldType === FieldType.SingleSelect ||
|
{cellIdentifier.fieldType === FieldType.SingleSelect ||
|
||||||
cellIdentifier.fieldType === FieldType.MultiSelect ||
|
cellIdentifier.fieldType === FieldType.MultiSelect ||
|
||||||
cellIdentifier.fieldType === FieldType.Checklist ? (
|
cellIdentifier.fieldType === FieldType.Checklist ? (
|
||||||
<BoardOptionsCell
|
<CellOptions
|
||||||
cellIdentifier={cellIdentifier}
|
data={data as SelectOptionCellDataPB}
|
||||||
cellCache={cellCache}
|
onEditClick={(top: number, left: number) => {
|
||||||
fieldController={fieldController}
|
console.log(top, left);
|
||||||
></BoardOptionsCell>
|
}}
|
||||||
|
/>
|
||||||
) : cellIdentifier.fieldType === FieldType.DateTime ? (
|
) : cellIdentifier.fieldType === FieldType.DateTime ? (
|
||||||
<BoardDateCell
|
<BoardDateCell
|
||||||
cellIdentifier={cellIdentifier}
|
cellIdentifier={cellIdentifier}
|
||||||
|
@ -0,0 +1,47 @@
|
|||||||
|
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 { FieldType } from '@/services/backend';
|
||||||
|
import { BoardDateCell } from '../../board/BoardDateCell';
|
||||||
|
import { BoardUrlCell } from '../../board/BoardUrlCell';
|
||||||
|
|
||||||
|
import GridSingleSelectOptions from './GridSingleSelectOptions';
|
||||||
|
import GridTextCell from './GridTextCell';
|
||||||
|
|
||||||
|
export const GridCell = ({
|
||||||
|
cellIdentifier,
|
||||||
|
cellCache,
|
||||||
|
fieldController,
|
||||||
|
}: {
|
||||||
|
cellIdentifier: CellIdentifier;
|
||||||
|
cellCache: CellCache;
|
||||||
|
fieldController: FieldController;
|
||||||
|
}) => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{cellIdentifier.fieldType === FieldType.MultiSelect || cellIdentifier.fieldType === FieldType.Checklist ? (
|
||||||
|
<p> Select solutions</p>
|
||||||
|
) : cellIdentifier.fieldType === FieldType.SingleSelect ? (
|
||||||
|
<GridSingleSelectOptions
|
||||||
|
cellIdentifier={cellIdentifier}
|
||||||
|
cellCache={cellCache}
|
||||||
|
fieldController={fieldController}
|
||||||
|
/>
|
||||||
|
) : cellIdentifier.fieldType === FieldType.DateTime ? (
|
||||||
|
<BoardDateCell
|
||||||
|
cellIdentifier={cellIdentifier}
|
||||||
|
cellCache={cellCache}
|
||||||
|
fieldController={fieldController}
|
||||||
|
></BoardDateCell>
|
||||||
|
) : cellIdentifier.fieldType === FieldType.URL ? (
|
||||||
|
<BoardUrlCell
|
||||||
|
cellIdentifier={cellIdentifier}
|
||||||
|
cellCache={cellCache}
|
||||||
|
fieldController={fieldController}
|
||||||
|
></BoardUrlCell>
|
||||||
|
) : (
|
||||||
|
<GridTextCell cellIdentifier={cellIdentifier} cellCache={cellCache} fieldController={fieldController} />
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
@ -0,0 +1,35 @@
|
|||||||
|
import { useState, useEffect, useRef } from 'react';
|
||||||
|
import { CellOptions } from '../../_shared/EditRow/CellOptions';
|
||||||
|
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 { SelectOptionCellDataPB } from '@/services/backend/models/flowy-database/select_type_option';
|
||||||
|
|
||||||
|
export default function GridSingleSelectOptions({
|
||||||
|
cellIdentifier,
|
||||||
|
cellCache,
|
||||||
|
fieldController,
|
||||||
|
}: {
|
||||||
|
cellIdentifier: CellIdentifier;
|
||||||
|
cellCache: CellCache;
|
||||||
|
fieldController: FieldController;
|
||||||
|
}) {
|
||||||
|
const ref = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
|
const { data, cellController } = useCell(cellIdentifier, cellCache, fieldController);
|
||||||
|
|
||||||
|
const [value, setValue] = useState((data as SelectOptionCellDataPB) || '');
|
||||||
|
const [showOptionsPopup, setShowOptionsPopup] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (data) setValue(data as SelectOptionCellDataPB);
|
||||||
|
}, [data]);
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className='flex w-full justify-start' ref={ref}>
|
||||||
|
<CellOptions data={data as SelectOptionCellDataPB} onEditClick={() => setShowOptionsPopup(!showOptionsPopup)} />
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
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';
|
||||||
|
|
||||||
|
export default function GridTextCell({
|
||||||
|
cellIdentifier,
|
||||||
|
cellCache,
|
||||||
|
fieldController,
|
||||||
|
}: {
|
||||||
|
cellIdentifier: CellIdentifier;
|
||||||
|
cellCache: CellCache;
|
||||||
|
fieldController: FieldController;
|
||||||
|
}) {
|
||||||
|
const { data, cellController } = useCell(cellIdentifier, cellCache, fieldController);
|
||||||
|
|
||||||
|
const [value, setValue] = useState((data as string) || '');
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (data) setValue(data as string);
|
||||||
|
}, [data]);
|
||||||
|
return (
|
||||||
|
<input
|
||||||
|
value={value}
|
||||||
|
onChange={(e) => {
|
||||||
|
setValue(e.target.value);
|
||||||
|
}}
|
||||||
|
onBlur={async () => {
|
||||||
|
await cellController?.saveCellData(value);
|
||||||
|
}}
|
||||||
|
className='min-h-[32px] w-full p-2 focus:border focus:border-main-accent focus:outline-none '
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
@ -1,22 +1,16 @@
|
|||||||
import { CellIdentifier } from '@/appflowy_app/stores/effects/database/cell/cell_bd_svc';
|
import { CellIdentifier } from '@/appflowy_app/stores/effects/database/cell/cell_bd_svc';
|
||||||
import { CellCache } from '@/appflowy_app/stores/effects/database/cell/cell_cache';
|
import { CellCache } from '@/appflowy_app/stores/effects/database/cell/cell_cache';
|
||||||
import { FieldController } from '@/appflowy_app/stores/effects/database/field/field_controller';
|
import { FieldController } from '@/appflowy_app/stores/effects/database/field/field_controller';
|
||||||
import { BoardCell } from '../../board/BoardCell';
|
import { GridCell } from '../GridCell/GridCell';
|
||||||
|
|
||||||
export const GridTableCell = ({
|
export const GridTableCell = ({
|
||||||
cellIdentifier,
|
cellIdentifier,
|
||||||
cellCache,
|
cellCache,
|
||||||
fieldController,
|
fieldController,
|
||||||
onClick,
|
|
||||||
}: {
|
}: {
|
||||||
cellIdentifier: CellIdentifier;
|
cellIdentifier: CellIdentifier;
|
||||||
cellCache: CellCache;
|
cellCache: CellCache;
|
||||||
fieldController: FieldController;
|
fieldController: FieldController;
|
||||||
onClick: () => void;
|
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return <GridCell cellIdentifier={cellIdentifier} cellCache={cellCache} fieldController={fieldController} />;
|
||||||
<div onClick={() => onClick()} className='w-full rounded-lg border border-transparent group-active:bg-main-accent'>
|
|
||||||
<BoardCell cellIdentifier={cellIdentifier} cellCache={cellCache} fieldController={fieldController} />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import { DatabaseController } from '@/appflowy_app/stores/effects/database/database_controller';
|
import { DatabaseController } from '@/appflowy_app/stores/effects/database/database_controller';
|
||||||
import { RowInfo } from '@/appflowy_app/stores/effects/database/row/row_cache';
|
import { RowInfo } from '@/appflowy_app/stores/effects/database/row/row_cache';
|
||||||
import { useRow } from '../../_shared/database-hooks/useRow';
|
import { useRow } from '../../_shared/database-hooks/useRow';
|
||||||
import { GridTableCell } from './GridTableCell';
|
import { FullView } from '../../_shared/svg/FullView';
|
||||||
|
import { GridCell } from '../GridCell/GridCell';
|
||||||
|
|
||||||
export const GridTableRow = ({
|
export const GridTableRow = ({
|
||||||
viewId,
|
viewId,
|
||||||
@ -18,17 +19,26 @@ export const GridTableRow = ({
|
|||||||
|
|
||||||
console.log({ cells });
|
console.log({ cells });
|
||||||
return (
|
return (
|
||||||
<tr>
|
<tr className='group'>
|
||||||
{cells.map((cell, cellIndex) => {
|
{cells.map((cell, cellIndex) => {
|
||||||
return (
|
return (
|
||||||
<td className='m-0 border border-l-0 border-shade-6 p-0 ' key={cellIndex}>
|
<td className='m-0 border border-l-0 border-shade-6 p-0 ' key={cellIndex}>
|
||||||
<GridTableCell
|
<div className='flex w-full justify-end'>
|
||||||
onClick={() => onOpenRow(row)}
|
<GridCell
|
||||||
key={cellIndex}
|
cellIdentifier={cell.cellIdentifier}
|
||||||
cellIdentifier={cell.cellIdentifier}
|
cellCache={controller.databaseViewCache.getRowCache().getCellCache()}
|
||||||
cellCache={controller.databaseViewCache.getRowCache().getCellCache()}
|
fieldController={controller.fieldController}
|
||||||
fieldController={controller.fieldController}
|
/>
|
||||||
/>
|
|
||||||
|
{cellIndex === 0 && (
|
||||||
|
<div
|
||||||
|
onClick={() => onOpenRow(row)}
|
||||||
|
className='hidden h-9 w-9 cursor-pointer rounded p-2 hover:bg-slate-200 group-hover:block '
|
||||||
|
>
|
||||||
|
<FullView />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
Loading…
Reference in New Issue
Block a user