-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from axonivy/XIVY-12288/basic-master-view
XIVY-12288 basic master view
- Loading branch information
Showing
11 changed files
with
209 additions
and
29 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
46 changes: 46 additions & 0 deletions
46
packages/dataclass-editor/src/components/dataclass/data/dataclass.ts
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,46 @@ | ||
export interface DataClass { | ||
$schema: string; | ||
simpleName: string; | ||
namespace: string; | ||
comment: string; | ||
annotations: Array<string>; | ||
isBusinessCaseData: boolean; | ||
entity?: DataClassEntity; | ||
fields: Array<DataClassField>; | ||
} | ||
|
||
export interface DataClassEntity { | ||
tableName: string; | ||
} | ||
|
||
export interface DataClassField { | ||
name: string; | ||
type: string; | ||
comment: string; | ||
modifiers: Array<DataClassFieldModifier>; | ||
annotations: Array<string>; | ||
entity?: DataClassFieldEntity; | ||
} | ||
|
||
export interface DataClassFieldEntity { | ||
databaseName: string; | ||
databaseFieldLength: string; | ||
association?: DataClassFieldEntityAssociation; | ||
cascadeTypes: Array<DataClassFieldEntityCascadeType>; | ||
mappedByFieldName: string; | ||
orphanRemoval: boolean; | ||
} | ||
|
||
export type DataClassFieldModifier = | ||
| 'PERSISTENT' | ||
| 'ID' | ||
| 'GENERATED' | ||
| 'NOT_NULLABLE' | ||
| 'UNIQUE' | ||
| 'NOT_UPDATEABLE' | ||
| 'NOT_INSERTABLE' | ||
| 'VERSION'; | ||
|
||
export type DataClassFieldEntityAssociation = 'ONE_TO_ONE' | 'ONE_TO_MANY' | 'MANY_TO_ONE'; | ||
|
||
export type DataClassFieldEntityCascadeType = 'ALL' | 'PERSIST' | 'MERGE' | 'REMOVE' | 'REFRESH'; |
6 changes: 6 additions & 0 deletions
6
packages/dataclass-editor/src/components/dataclass/master/DataClassMaster.css
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,6 @@ | ||
.dataclass-wrapper { | ||
flex: 1; | ||
flex-basis: 0; | ||
min-height: 0; | ||
height: 100%; | ||
} |
94 changes: 94 additions & 0 deletions
94
packages/dataclass-editor/src/components/dataclass/master/DataClassMaster.tsx
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,94 @@ | ||
import { | ||
BasicField, | ||
Button, | ||
Flex, | ||
selectRow, | ||
SelectRow, | ||
Separator, | ||
Table, | ||
TableBody, | ||
TableCell, | ||
TableResizableHeader, | ||
useReadonly, | ||
useTableSelect | ||
} from '@axonivy/ui-components'; | ||
import { IvyIcons } from '@axonivy/ui-icons'; | ||
import { flexRender, getCoreRowModel, useReactTable, type ColumnDef } from '@tanstack/react-table'; | ||
import { type DataClassField } from '../data/dataclass'; | ||
import './DataClassMaster.css'; | ||
|
||
type DataClassMasterProps = { | ||
dataClassFields: Array<DataClassField>; | ||
}; | ||
|
||
export const DataClassMaster = ({ dataClassFields }: DataClassMasterProps) => { | ||
const selection = useTableSelect<DataClassField>(); | ||
const columns: Array<ColumnDef<DataClassField, string>> = [ | ||
{ | ||
accessorKey: 'name', | ||
header: 'Name', | ||
cell: cell => <div>{cell.getValue()}</div>, | ||
minSize: 50 | ||
}, | ||
{ | ||
accessorKey: 'type', | ||
header: 'Type', | ||
cell: cell => <div>{cell.getValue()}</div> | ||
}, | ||
{ | ||
accessorFn: (dataClassField: DataClassField) => String(dataClassField.modifiers.includes('PERSISTENT')), | ||
header: 'Persistent', | ||
cell: cell => <div>{cell.getValue()}</div> | ||
}, | ||
{ | ||
accessorKey: 'comment', | ||
header: 'Comment', | ||
cell: cell => <div>{cell.getValue()}</div> | ||
} | ||
]; | ||
const table = useReactTable({ | ||
...selection.options, | ||
data: dataClassFields, | ||
columns, | ||
getCoreRowModel: getCoreRowModel(), | ||
state: { | ||
...selection.tableState | ||
} | ||
}); | ||
|
||
const resetSelection = () => { | ||
selectRow(table); | ||
}; | ||
|
||
const readonly = useReadonly(); | ||
const control = readonly ? null : ( | ||
<Flex gap={2}> | ||
<Button key='addButton' icon={IvyIcons.Plus} onClick={() => {}} aria-label='Add data class field' /> | ||
<Separator decorative orientation='vertical' style={{ height: '20px', margin: 0 }} /> | ||
<Button | ||
key='deleteButton' | ||
icon={IvyIcons.Trash} | ||
onClick={() => {}} | ||
disabled={table.getSelectedRowModel().rows.length === 0} | ||
aria-label='Delete data class field' | ||
/> | ||
</Flex> | ||
); | ||
|
||
return ( | ||
<BasicField className='dataclass-wrapper' label='Attributes' control={control}> | ||
<Table> | ||
<TableResizableHeader headerGroups={table.getHeaderGroups()} onClick={resetSelection} /> | ||
<TableBody> | ||
{table.getRowModel().rows.map(row => ( | ||
<SelectRow key={row.id} row={row}> | ||
{row.getVisibleCells().map(cell => ( | ||
<TableCell key={cell.id}>{flexRender(cell.column.columnDef.cell, cell.getContext())}</TableCell> | ||
))} | ||
</SelectRow> | ||
))} | ||
</TableBody> | ||
</Table> | ||
</BasicField> | ||
); | ||
}; |
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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
export * from './components/dataclass/data/dataclass'; | ||
export { default as DataClassEditor } from './DataClassEditor'; | ||
export * from './protocol'; | ||
export * from './query'; | ||
export * from './protocol/client-json-rpc'; | ||
export * from './protocol/ClientContextProvider'; | ||
export * from './query/query-client'; | ||
export * from './query/QueryProvider'; |
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.