-
Notifications
You must be signed in to change notification settings - Fork 55
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
11 changed files
with
215 additions
and
23 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
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
10 changes: 8 additions & 2 deletions
10
ui2/src/features/nodes/components/Commander/DocumentsByTypeCommander/ActionButtons.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 |
---|---|---|
@@ -1,10 +1,16 @@ | ||
import ToggleSecondaryPanel from "@/components/DualPanel/ToggleSecondaryPanel" | ||
import {Group} from "@mantine/core" | ||
import ViewOptionsMenu from "../ViewOptionsMenu" | ||
import DocumentTypeFilter from "./DocumentTypeFilter" | ||
|
||
export default function ActionButtons() { | ||
return ( | ||
<Group> | ||
<ViewOptionsMenu /> | ||
<Group justify="space-between"> | ||
<DocumentTypeFilter /> | ||
<Group> | ||
<ViewOptionsMenu /> | ||
<ToggleSecondaryPanel /> | ||
</Group> | ||
</Group> | ||
) | ||
} |
33 changes: 33 additions & 0 deletions
33
ui2/src/features/nodes/components/Commander/DocumentsByTypeCommander/DocumentRow.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,33 @@ | ||
import {Checkbox, Table} from "@mantine/core" | ||
import {useDispatch, useSelector} from "react-redux" | ||
import {Link} from "react-router-dom" | ||
|
||
import {selectSelectedIds} from "@/features/users/usersSlice" | ||
|
||
import type {DocumentCFV} from "@/types" | ||
|
||
type Args = { | ||
doc: DocumentCFV | ||
} | ||
|
||
export default function DocumentRow({doc}: Args) { | ||
const selectedIds = useSelector(selectSelectedIds) | ||
const dispatch = useDispatch() | ||
const customFieldsDataColumns = doc.custom_fields.map(cf => ( | ||
<Table.Td key={cf[0]}>{cf[1]}</Table.Td> | ||
)) | ||
|
||
const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {} | ||
|
||
return ( | ||
<Table.Tr> | ||
<Table.Td> | ||
<Checkbox checked={selectedIds.includes(doc.id)} onChange={onChange} /> | ||
</Table.Td> | ||
<Table.Td> | ||
<Link to={`/document/${doc.id}`}>{doc.title}</Link> | ||
</Table.Td> | ||
{customFieldsDataColumns} | ||
</Table.Tr> | ||
) | ||
} |
38 changes: 37 additions & 1 deletion
38
ui2/src/features/nodes/components/Commander/DocumentsByTypeCommander/DocumentTypeFilter.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 |
---|---|---|
@@ -1,11 +1,47 @@ | ||
import {useAppDispatch} from "@/app/hooks" | ||
import PanelContext from "@/contexts/PanelContext" | ||
import {useGetDocumentTypesQuery} from "@/features/document-types/apiSlice" | ||
import {commanderDocumentTypeIDUpdated} from "@/features/ui/uiSlice" | ||
import {Select} from "@mantine/core" | ||
import {useContext, useState} from "react" | ||
|
||
import type {PanelMode} from "@/types" | ||
|
||
export default function DocumentTypeFilter() { | ||
const mode: PanelMode = useContext(PanelContext) | ||
const dispatch = useAppDispatch() | ||
const {data: allDocumentTypes = []} = useGetDocumentTypesQuery() | ||
const [currentDocumentTypeID, setCurrentDocumentTypeID] = useState< | ||
string | undefined | ||
>("") | ||
const onDocumentTypeChanged = (value: string | null) => { | ||
let newValue | ||
|
||
if (!value) { | ||
newValue = undefined | ||
} else { | ||
newValue = value | ||
} | ||
|
||
setCurrentDocumentTypeID(newValue) | ||
|
||
dispatch( | ||
commanderDocumentTypeIDUpdated({ | ||
mode, | ||
documentTypeID: newValue | ||
}) | ||
) | ||
} | ||
|
||
return ( | ||
<Select | ||
searchable | ||
placeholder="Pick Document Type" | ||
data={["React", "Angular", "Vue", "Svelte"]} | ||
onChange={onDocumentTypeChanged} | ||
data={allDocumentTypes.map(i => { | ||
return {value: i.id, label: i.name} | ||
})} | ||
value={currentDocumentTypeID} | ||
/> | ||
) | ||
} |
82 changes: 71 additions & 11 deletions
82
...features/nodes/components/Commander/DocumentsByTypeCommander/DocumentsByTypeCommander.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 |
---|---|---|
@@ -1,19 +1,79 @@ | ||
import ToggleSecondaryPanel from "@/components/DualPanel/ToggleSecondaryPanel" | ||
import {Box, Group, Stack} from "@mantine/core" | ||
import {useAppSelector} from "@/app/hooks" | ||
import Breadcrumbs from "@/components/Breadcrumbs" | ||
import PanelContext from "@/contexts/PanelContext" | ||
import {useGetDocsByTypeQuery} from "@/features/document/apiSlice" | ||
import {useGetFolderQuery} from "@/features/nodes/apiSlice" | ||
import { | ||
selectCommanderDocumentTypeID, | ||
selectCurrentNodeID | ||
} from "@/features/ui/uiSlice" | ||
import type {NType, PanelMode} from "@/types" | ||
import {Box, Checkbox, Stack, Table} from "@mantine/core" | ||
import {skipToken} from "@reduxjs/toolkit/query" | ||
import {useContext} from "react" | ||
import ActionButtons from "./ActionButtons" | ||
import DocumentTypeFilter from "./DocumentTypeFilter" | ||
import DocumentRow from "./DocumentRow" | ||
|
||
export default function DocumentsByCategoryCommander() { | ||
const mode: PanelMode = useContext(PanelContext) | ||
const currentNodeID = useAppSelector(s => selectCurrentNodeID(s, mode)) | ||
const currentDocumentTypeID = useAppSelector(s => | ||
selectCommanderDocumentTypeID(s, mode) | ||
) | ||
const {data: currentFolder} = useGetFolderQuery(currentNodeID ?? skipToken) | ||
const {data: nodes} = useGetDocsByTypeQuery( | ||
currentNodeID && currentDocumentTypeID | ||
? {document_type_id: currentDocumentTypeID, ancestor_id: currentNodeID} | ||
: skipToken | ||
) | ||
|
||
const onClick = (node: NType) => {} | ||
|
||
if (!nodes || (nodes && nodes.length == 0)) { | ||
return ( | ||
<Box> | ||
<Stack> | ||
<ActionButtons /> | ||
<Breadcrumbs | ||
breadcrumb={currentFolder?.breadcrumb} | ||
onClick={onClick} | ||
isFetching={false} | ||
/> | ||
</Stack> | ||
<Stack>Empty</Stack> | ||
</Box> | ||
) | ||
} | ||
|
||
const rows = nodes.map(n => <DocumentRow key={n.id} doc={n} />) | ||
const customFieldsHeaderColumns = nodes[0].custom_fields.map(cf => ( | ||
<Table.Th key={cf[0]}>{cf[0]}</Table.Th> | ||
)) | ||
|
||
return ( | ||
<Box> | ||
<Group justify="space-between"> | ||
<DocumentTypeFilter /> | ||
<Group> | ||
<ActionButtons /> | ||
<ToggleSecondaryPanel /> | ||
</Group> | ||
</Group> | ||
<Stack>Empty</Stack> | ||
<Stack> | ||
<ActionButtons /> | ||
<Breadcrumbs | ||
breadcrumb={currentFolder?.breadcrumb} | ||
onClick={onClick} | ||
isFetching={false} | ||
/> | ||
</Stack> | ||
<Stack> | ||
<Table> | ||
<Table.Thead> | ||
<Table.Tr> | ||
<Table.Th> | ||
<Checkbox /> | ||
</Table.Th> | ||
<Table.Th>Title</Table.Th> | ||
{customFieldsHeaderColumns} | ||
</Table.Tr> | ||
</Table.Thead> | ||
<Table.Tbody>{rows}</Table.Tbody> | ||
</Table> | ||
</Stack> | ||
</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