-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
160 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Box } from '@fower/react' | ||
import { | ||
Button, | ||
Modal, | ||
ModalClose, | ||
ModalCloseButton, | ||
ModalContent, | ||
ModalHeader, | ||
ModalOverlay, | ||
useModalContext, | ||
} from 'uikit' | ||
import { ModalNames } from '@penx/constants' | ||
import { RowForm } from '@penx/database-ui' | ||
import { Node } from '@penx/model' | ||
|
||
const Content = () => { | ||
const { data: node } = useModalContext<Node>() | ||
return ( | ||
<Box> | ||
<ModalHeader mb2># {node.tagName}</ModalHeader> | ||
<RowForm rowId={node.props.rowId} databaseId={node.parentId} /> | ||
</Box> | ||
) | ||
} | ||
|
||
export const RowModal = () => { | ||
return ( | ||
<Modal name={ModalNames.ROW}> | ||
<ModalOverlay /> | ||
<ModalContent w={['100%', 500]} column gap4> | ||
<ModalCloseButton /> | ||
|
||
<Content /> | ||
</ModalContent> | ||
</Modal> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { forwardRef } from 'react' | ||
import { Box } from '@fower/react' | ||
import { useDatabase } from '@penx/node-hooks' | ||
import { mappedByKey } from '@penx/shared' | ||
import { FieldIcon } from './shared/FieldIcon' | ||
import { CellField } from './tag/fields' | ||
|
||
interface Props { | ||
databaseId: string | ||
rowId: string | ||
} | ||
|
||
export const RowForm = forwardRef<HTMLDivElement, Props>(function TagForm( | ||
{ databaseId, rowId }, | ||
ref, | ||
) { | ||
const { columns, views, cells } = useDatabase(databaseId) | ||
|
||
const currentView = views[0] | ||
|
||
const columnMap = mappedByKey(columns, 'id') | ||
const { viewColumns = [] } = currentView.props | ||
const sortedColumns = viewColumns.map(({ columnId }) => columnMap[columnId]) | ||
|
||
const rowCells = sortedColumns.map((column) => { | ||
return cells.find( | ||
(cell) => cell.props.rowId === rowId && cell.props.columnId === column.id, | ||
)! | ||
}) | ||
|
||
return ( | ||
<Box ref={ref} column gap4> | ||
{rowCells.map((cell, index) => { | ||
const column = columns.find((col) => col.id === cell.props.columnId)! | ||
|
||
return ( | ||
<Box key={cell.id}> | ||
<Box mb2 toCenterY gap1 gray600> | ||
<FieldIcon fieldType={column.props.fieldType} /> | ||
<Box textXS>{column.props.displayName}</Box> | ||
</Box> | ||
|
||
<CellField index={index} cell={cell} columns={sortedColumns} /> | ||
</Box> | ||
) | ||
})} | ||
</Box> | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters