-
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 #329 from RyanNerd/paperless
⛲ feat Document Management (upload/download files)
- Loading branch information
Showing
26 changed files
with
1,121 additions
and
121 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import Button from 'react-bootstrap/Button'; | ||
import Table, {TableProps} from 'react-bootstrap/Table'; | ||
import React from 'reactn'; | ||
import {FileRecord} from 'types/RecordTypes'; | ||
import {randomString} from 'utility/common'; | ||
|
||
interface IProps extends TableProps { | ||
[key: string]: unknown; | ||
onDownload: (fileRecord: FileRecord) => void; | ||
onDelete: (fileRecord: FileRecord) => void; | ||
onEdit: (fileRecord: FileRecord) => void; | ||
fileList: FileRecord[]; | ||
} | ||
|
||
interface ITableProps extends TableProps { | ||
onDownload: unknown; | ||
onDelete: unknown; | ||
fileList: unknown; | ||
onEdit: unknown; | ||
} | ||
|
||
/** | ||
* FileGrid | ||
* @param {IProps} props The props for this component | ||
*/ | ||
const FileGrid = (props: IProps): JSX.Element | null => { | ||
const {fileList, onDownload, onDelete, onEdit} = props; | ||
|
||
// No render if there isn't anything to render | ||
if (!fileList || fileList.length === 0) return null; | ||
|
||
/** | ||
* Child component for the table for each DocumentRecord object. | ||
* @param {FileRecord} file The Document row object | ||
*/ | ||
const FileRow = (file: FileRecord): JSX.Element | null => { | ||
const domId = file.Id ? file.Id : randomString(); | ||
|
||
return ( | ||
<tr key={`file-grid-row-${domId}`} id={`file-grid-row-${domId}`}> | ||
<td style={{verticalAlign: 'middle'}}>{file.FileName}</td> | ||
<td style={{verticalAlign: 'middle'}}>{file.Description}</td> | ||
<td style={{verticalAlign: 'middle'}}>{file.MediaType}</td> | ||
<td style={{verticalAlign: 'middle'}}>{file.Size}</td> | ||
<td style={{textAlign: 'center', verticalAlign: 'middle'}}> | ||
<Button id={`file-grid-edit-btn-${domId}`} onClick={() => onEdit(file)} size="sm" variant="info"> | ||
Edit | ||
</Button> | ||
</td> | ||
<td style={{textAlign: 'center', verticalAlign: 'middle'}}> | ||
<Button | ||
id={`file-grid-download-btn-${domId}`} | ||
onClick={() => onDownload(file)} | ||
size="sm" | ||
variant="info" | ||
> | ||
Download | ||
</Button> | ||
</td> | ||
<td style={{textAlign: 'center', verticalAlign: 'middle'}}> | ||
<Button | ||
id={`file-grid-delete-btn-${domId}`} | ||
onClick={() => onDelete(file)} | ||
size="sm" | ||
variant="outline-danger" | ||
> | ||
<span role="img" aria-label="delete"> | ||
🗑️ | ||
</span> | ||
</Button> | ||
</td> | ||
</tr> | ||
); | ||
}; | ||
|
||
const tableProps = {...props} as ITableProps; | ||
delete tableProps.onDelete; | ||
delete tableProps.onDownload; | ||
delete tableProps.onEdit; | ||
delete tableProps.fileList; | ||
|
||
return ( | ||
<Table style={{wordWrap: 'break-word'}} {...tableProps} bordered hover size="sm" striped> | ||
<thead> | ||
<tr> | ||
<th>Filename</th> | ||
<th>Description</th> | ||
<th>Type</th> | ||
<th>Size</th> | ||
<th></th> | ||
<th></th> | ||
<th></th> | ||
</tr> | ||
</thead> | ||
<tbody>{fileList.map((p) => FileRow(p))}</tbody> | ||
</Table> | ||
); | ||
}; | ||
|
||
export default FileGrid; |
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,64 @@ | ||
import ManageOtc from 'components/Pages/ManagementTabs/ManageOtc'; | ||
import Settings from 'components/Pages/ManagementTabs/Settings'; | ||
import Tab from 'react-bootstrap/Tab'; | ||
import Tabs from 'react-bootstrap/Tabs'; | ||
import ToggleButton from 'react-bootstrap/ToggleButton'; | ||
import React, {useState} from 'reactn'; | ||
|
||
const ManagementPage = () => { | ||
const [activeManagementKey, setActiveManagementKey] = useState('otc'); | ||
return ( | ||
<Tabs | ||
activeKey={activeManagementKey} | ||
defaultActiveKey="otc" | ||
onSelect={(s) => setActiveManagementKey(s || 'otc')} | ||
> | ||
<Tab | ||
eventKey="otc" | ||
title={ | ||
<ToggleButton | ||
checked={activeManagementKey === 'otc'} | ||
id="management-radio-btn-otc" | ||
key="management-radio-btn-otc" | ||
name="radio-management" | ||
onChange={() => setActiveManagementKey('otc')} | ||
size="sm" | ||
type="radio" | ||
value="otc" | ||
variant="outline-success" | ||
> | ||
<span className="ml-2">Manage OTC</span> | ||
</ToggleButton> | ||
} | ||
> | ||
<Tab.Content> | ||
<ManageOtc activeManagementKey={activeManagementKey} /> | ||
</Tab.Content> | ||
</Tab> | ||
<Tab | ||
eventKey="settings" | ||
title={ | ||
<ToggleButton | ||
checked={activeManagementKey === 'settings'} | ||
id="management-radio-btn-settings" | ||
key="management-radio-btn-settings" | ||
name="radio-management" | ||
onChange={() => setActiveManagementKey('settings')} | ||
size="sm" | ||
type="radio" | ||
value="settings" | ||
variant="outline-success" | ||
> | ||
<span className="ml-2">Settings</span> | ||
</ToggleButton> | ||
} | ||
> | ||
<Tab.Content> | ||
<Settings /> | ||
</Tab.Content> | ||
</Tab> | ||
</Tabs> | ||
); | ||
}; | ||
|
||
export default ManagementPage; |
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
Oops, something went wrong.