mirror of
https://github.com/AppFlowy-IO/AppFlowy-Web.git
synced 2025-11-30 11:27:55 +08:00
feat: support database (#2)
* chore: support drag row * chore: support drag column * chore: modified board virtual list * chore: support drag board column * chore: support drag card * chore: support fix grid header * chore: support fix board header * chore: disabled drag and drop on readonly * chore: adjust padding start and end on document * chore: support new row * chore: support create view * chore: hide or show the property * chore: lint * chore: add card at the top * chore: support text cell editing * chore: support swicth property type and checkbox editing * chore: support number cell editing * chore: support select cell editing * chore: support date cell editing * chore: support relation and checklist * chore: support calculation * chore: support filters and sorts * chore: support edit row modal * chore: support files&media * chore: pull origin main * chore: modified border width * chore: fixed some issues * chore: modified active cell style * chore: add switch language to AI Translate * chore: modified upload color * chore: support board group * chore: support board * chore: update database filter and board column components * chore: update download * chore: update components and pages, optimize UI and functionality * chore: update component and update key bind * chore: update filters * chore: add copy button to date cell * chore: board * chore: replace some old token to new one * chore: add hidden item menu * chore: show the checkbox on card * chore: adjust resize row * chore: update sorts * chore: fix issues of database on document * chore: fix checkbox data * chore: modified test
This commit is contained in:
@@ -1,45 +1,30 @@
|
||||
import { useDatabase, useDatabaseViewId } from '@/application/database-yjs';
|
||||
import { useRenderFields, GridHeader, GridTable } from '@/components/database/components/grid';
|
||||
import { CircularProgress } from '@mui/material';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { useDatabaseContext, useDatabaseViewId } from '@/application/database-yjs';
|
||||
import { useRenderFields } from '@/components/database/components/grid/grid-column';
|
||||
import GridVirtualizer from '@/components/database/components/grid/grid-table/GridVirtualizer';
|
||||
import { GridProvider } from '@/components/database/grid/GridProvider';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
export function Grid () {
|
||||
const database = useDatabase();
|
||||
const viewId = useDatabaseViewId() || '';
|
||||
const [scrollLeft, setScrollLeft] = useState(0);
|
||||
const { fields } = useRenderFields();
|
||||
const viewId = useDatabaseViewId();
|
||||
|
||||
const { fields, columnWidth } = useRenderFields();
|
||||
const { onRendered } = useDatabaseContext();
|
||||
|
||||
useEffect(() => {
|
||||
setScrollLeft(0);
|
||||
}, [viewId]);
|
||||
|
||||
if (!database) {
|
||||
return (
|
||||
<div className={'flex w-full flex-1 flex-col items-center justify-center'}>
|
||||
<CircularProgress />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
if (fields) {
|
||||
onRendered?.();
|
||||
}
|
||||
}, [fields, onRendered]);
|
||||
|
||||
return (
|
||||
<div className={'database-grid flex w-full flex-1 flex-col'}>
|
||||
<GridHeader
|
||||
scrollLeft={scrollLeft}
|
||||
columnWidth={columnWidth}
|
||||
columns={fields}
|
||||
onScrollLeft={setScrollLeft}
|
||||
/>
|
||||
<div className={'grid-scroll-table w-full flex-1'}>
|
||||
<GridTable
|
||||
viewId={viewId}
|
||||
scrollLeft={scrollLeft}
|
||||
columnWidth={columnWidth}
|
||||
<GridProvider>
|
||||
<div className={`database-grid relative grid-table-${viewId} flex w-full flex-1 flex-col`}>
|
||||
<GridVirtualizer
|
||||
columns={fields}
|
||||
onScrollLeft={setScrollLeft}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</GridProvider>
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user