Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OpenConceptLab/ocl_issues#1348 | Source create new form
- Loading branch information
1 parent
6115822
commit cdc003d
Showing
20 changed files
with
1,001 additions
and
39 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,27 @@ | ||
import React from 'react'; | ||
import { Accordion, AccordionSummary, AccordionDetails, Typography } from '@mui/material'; | ||
import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; | ||
|
||
|
||
const CommonAccordion = ({title, subTitle, children, defaultStyle, ...accordionProps}) => { | ||
return ( | ||
<div className='col-xs-12 no-side-padding'> | ||
<Accordion style={defaultStyle ? {} : {borderTop: "1px solid rgba(0, 0, 0, 0.12)"}} {...(accordionProps || {})}> | ||
<AccordionSummary expandIcon={<ExpandMoreIcon />}> | ||
<div> | ||
<Typography>{title}</Typography> | ||
{ | ||
subTitle && | ||
<div className='form-text-gray'>{subTitle}</div> | ||
} | ||
</div> | ||
</AccordionSummary> | ||
<AccordionDetails style={{background: '#fafafa', display: 'inline-block', width: '100%'}}> | ||
{children} | ||
</AccordionDetails> | ||
</Accordion> | ||
</div> | ||
) | ||
} | ||
|
||
export default CommonAccordion; |
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,13 @@ | ||
import React from 'react'; | ||
import { Tooltip } from '@mui/material'; | ||
import { InfoOutlined as Icon } from '@mui/icons-material'; | ||
|
||
const FormTooltip = ({ title, placement, style }) => ( | ||
<span style={{display: 'flex', ...(style || {})}}> | ||
<Tooltip title={title} placement={placement || 'right'}> | ||
<Icon color='default' /> | ||
</Tooltip> | ||
</span> | ||
) | ||
|
||
export default FormTooltip; |
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,69 @@ | ||
import React from 'react'; | ||
import { Button, Menu, MenuItem, ListItemIcon, ListItemText } from '@mui/material'; | ||
import { ArrowDropDown as DownIcon } from '@mui/icons-material'; | ||
import { map } from 'lodash'; | ||
import APIService from '../../services/APIService'; | ||
import { getCurrentUser } from '../../common/utils'; | ||
import { ORANGE, WHITE } from '../../common/constants'; | ||
import DynamicConfigResourceIcon from './DynamicConfigResourceIcon'; | ||
|
||
const OwnerSelectorButton = props => { | ||
const getDefaultOwner = () => { | ||
let _owner = {type: props.owner.type, url: props.owner.url} | ||
if(_owner.type === 'User') | ||
_owner.username = props.owner.username | ||
else | ||
_owner.id = props.owner.id | ||
return _owner | ||
} | ||
const [anchorEl, setAnchorEl] = React.useState(null); | ||
const [selected, setSelected] = React.useState(getDefaultOwner) | ||
const [owners, setOwners] = React.useState([]) | ||
const user = getCurrentUser() | ||
const getOwners = () => APIService | ||
.user() | ||
.orgs() | ||
.get() | ||
.then(response => setOwners( | ||
[...map(response.data, org => ({id: org.id, type: org.type, url: org.url})), {username: user.username, type: 'User', url: user.url}] | ||
)) | ||
|
||
React.useEffect(() => !props.disabled && getOwners(), []) | ||
|
||
const onToggle = event => setAnchorEl(anchorEl ? null : event.currentTarget) | ||
|
||
const onSelect = owner => { | ||
setSelected(owner) | ||
setAnchorEl(null) | ||
|
||
props.onChange(owner) | ||
} | ||
|
||
return ( | ||
<React.Fragment> | ||
<Button | ||
startIcon={<DynamicConfigResourceIcon resource={selected.type.toLowerCase()} />} | ||
endIcon={<DownIcon />} | ||
variant='contained' | ||
style={{backgroundColor: ORANGE, color: WHITE, ...(props.style || {})}} | ||
onClick={props.disabled ? () => {} : onToggle} | ||
> | ||
{selected.username || selected.id} | ||
</Button> | ||
<Menu anchorEl={anchorEl} open={Boolean(anchorEl)} onClose={onToggle}> | ||
{ | ||
map(owners, (owner, index) => ( | ||
<MenuItem key={index} onClick={() => onSelect(owner)}> | ||
<ListItemIcon> | ||
<DynamicConfigResourceIcon resource={owner.type.toLowerCase()} /> | ||
</ListItemIcon> | ||
<ListItemText>{owner.username || owner.id}</ListItemText> | ||
</MenuItem> | ||
)) | ||
} | ||
</Menu> | ||
</React.Fragment> | ||
) | ||
} | ||
|
||
export default OwnerSelectorButton; |
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,26 @@ | ||
import React from 'react'; | ||
import CommonAccordion from '../../common/CommonAccordion'; | ||
import RTEditor from '../../common/RTEditor'; | ||
|
||
|
||
const AboutPage = props => { | ||
const configs = props.advanceSettings.about | ||
const [text, setText] = React.useState('') | ||
const onChange = value => { | ||
setText(value) | ||
props.onChange({text: value}) | ||
} | ||
return ( | ||
<CommonAccordion square title={configs.title} subTitle={configs.subTitle}> | ||
<div className='col-xs-12 no-side-padding' style={{marginTop: '10px'}}> | ||
<RTEditor | ||
onChange={onChange} | ||
defaultValue={text} | ||
placeholder={`About ${props.resource}`} | ||
/> | ||
</div> | ||
</CommonAccordion> | ||
) | ||
} | ||
|
||
export default AboutPage; |
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,22 @@ | ||
import React from 'react'; | ||
import FHIRSettings from './FHIRSettings'; | ||
import ResourceIDAssignmentSettings from './ResourceIDAssignmentSettings' | ||
import CustomAttributes from './CustomAttributes' | ||
import AboutPage from './AboutPage' | ||
|
||
const AdvanceSettings = props => { | ||
const configs = props.advanceSettings | ||
return ( | ||
<div className='col-xs-12 no-side-padding'> | ||
<div className='col-xs-12 no-side-padding'> | ||
<h2>{configs.title}</h2> | ||
</div> | ||
<FHIRSettings {...props} /> | ||
<ResourceIDAssignmentSettings {...props} /> | ||
<CustomAttributes {...props} /> | ||
<AboutPage {...props} /> | ||
</div> | ||
) | ||
} | ||
|
||
export default AdvanceSettings |
Oops, something went wrong.