Skip to content
Snippets Groups Projects
Commit 0b1ce2d3 authored by James D'Alton's avatar James D'Alton
Browse files

added names to elements to help with robot testing. Also added delete...

added names to elements to help with robot testing. Also added delete functionality to submissions (only for the user's own)
parent 3448f0f9
No related branches found
No related tags found
1 merge request!3Robot
Showing
with 90 additions and 71 deletions
404.html,1586351207960,b7bab6b83fa074653ff28c8d2a64135d3434575f70a12ab3d3ba8080461b9537 404.html,1589741500917,b7bab6b83fa074653ff28c8d2a64135d3434575f70a12ab3d3ba8080461b9537
asset-manifest.json,1586351226513,9bdae63ab9813e4828dd4dd4b39c2c71ba8ebadbc23780ac8eb61a63a8ed5ee3 asset-manifest.json,1589741598579,0fe5c3517bbbed4723702690ef79121134824309d10137468a3160ed48743fbc
favicon.ico,1586351207967,a7f9959c242eab6cdf79ddb2d1d2a4112a7c7ba3ecc911ddf7bf7b1fff54a07d index.html,1589741598560,f9c210a8f876813acc565d76eb1006d795ebbb41ed6b86fcba5525f5688163ab
index.html,1586351226513,33e3b871cf77ab7078c0779dc9135fb0e19a7c1b05fb5ef53b4c82375d7fde50 precache-manifest.2d3ac30b3bbfa4e802a34120c1d73fe6.js,1589741598579,6afcdd1ed0d36c1b7f86da75683f128d6c34d8f81857f8f2db3f4961ef99024e
manifest.json,1586351207972,15492b46b805f4ba9408ae30685145c16c1fdd2163fe3934f1c8f6c6d0eb0800 static/css/main.6e34eb25.chunk.css,1589741598582,b099acc63a98e7798231bd04084ea7e1e5bf7d6b1798667b0c9b300439a516fb
precache-manifest.def63341b2b22b203538bbf1684d6536.js,1586351226540,d04d6a0f2339061ceb249d63e22bbb89663d5909eb421577c99beec3de614e27 manifest.json,1589741500935,ed7b98046be74c7d1476b73ebb8cd1f00c2b34443af1525af60b9dd20be9fb9a
robots.txt,1586351207977,2544ca049f223a42bff01f72ad930a5edba75bbb7199d0f8430a02ff5aca16ec service-worker.js,1589741598579,c8f1abb2061b4fa705064245a206146573094ad62e78c41d02c6931160877cbc
service-worker.js,1586351226513,95a9901b401055db71838ab85b04416f96ba7aed1c65eed7e193b89dd46a024b robots.txt,1589741500959,2544ca049f223a42bff01f72ad930a5edba75bbb7199d0f8430a02ff5aca16ec
static/css/main.5f361e03.chunk.css,1586351226551,1225945381892d813e90efe1c2bf85dad429fb1fce6829657a852a833b2081a3 static/css/main.6e34eb25.chunk.css.map,1589741598637,463248e53c58fd776db145fcd4af644e5fc706fd19bdcc132460068c3fcf7646
static/css/main.5f361e03.chunk.css.map,1586351226562,598f7972010d8f32c864cacf97d3770434b6aaf52e74a00c2e8b1b13faf78d9f static/js/2.c183699c.chunk.js.LICENSE.txt,1589741598645,32b777c978b6723e67c966318c313ffad088e946cb6d0aa81a614b3be78bbeb2
static/js/2.d615869a.chunk.js,1586351226562,6c42fbde1e3559adc87dded8956e7580a99f9f119a63df2e65265157d6f1a46f favicon.ico,1589741500919,a7f9959c242eab6cdf79ddb2d1d2a4112a7c7ba3ecc911ddf7bf7b1fff54a07d
static/js/2.d615869a.chunk.js.LICENSE.txt,1586351226562,74727db789fa0a696fe581244653adf4b10e75bb31caec1d6c628a68617665d6 static/js/runtime-main.607af0bd.js,1589741598638,9ac65e3334fa4069d5ff94c6167ebd3612e70694c6e7d5fee98e1f9147652f1e
static/js/2.d615869a.chunk.js.map,1586351226563,4fb34988f2a2d4b754ec7dcee758f847177b39609b5f60369933984dd381ad0d static/js/runtime-main.607af0bd.js.map,1589741598637,5a22a82da7b266b2fcce68dbfbbe24cb2fcfd1b5d2406381f6c09e02efb97ca2
static/js/main.cbe32a5b.chunk.js,1586351226818,ada07cabc83d1ea1e695c59f4846ad42f8680a022c3214d032d4b408ac8995d3 static/js/main.7ec9fa39.chunk.js,1589741598650,8b21c449e07e05a05224aa272d53770ed28b3c5959cb1bb5f0c696005b673cf1
static/js/main.cbe32a5b.chunk.js.map,1586351226793,e4404e164e38a7a8076a839f65b7896ae35591ab73d10af4ae2b02fb3d5444de static/js/main.7ec9fa39.chunk.js.map,1589741598638,1fb0211fbb70a43ae6fdbeed0efe42bc21ff211cb370b8b6877d538bf5a0c444
static/js/runtime-main.891cac52.js,1586351226557,04a216b52283a30877d0643e87a750a2157bec4e8843f4dfcc1f02a9933e12b5 static/js/2.c183699c.chunk.js,1589741598596,989a748d56c8d49bedd28db04de19815d51a505015169b57985662e7636b6e36
static/js/runtime-main.891cac52.js.map,1586351226562,f1d775d637848326834d9ade23e34251001fdc050497240daafa4838523816c8 static/js/2.c183699c.chunk.js.map,1589741598639,20044844c6522e4695680d000c627982b781fa7ff84bc3d4fa14ffc30a710a96
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
work correctly both with client-side routing and a non-root public URL. work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`. Learn how to configure a non-root public URL by running `npm run build`.
--> -->
<title> Automatically Generated Cyber Security Compliance Engine </title> <title> CompForge </title>
</head> </head>
<body> <body>
......
...@@ -51,22 +51,20 @@ const AppMenu = (props) => { ...@@ -51,22 +51,20 @@ const AppMenu = (props) => {
<div className={'menuitems'}> <div className={'menuitems'}>
{props.isAuthenticated && <h3> Navigation </h3>} {props.isAuthenticated && <h3> Navigation </h3>}
{props.isAuthenticated && <Link style={{ textDecoration: 'none', color: '#444' }} to={'/'}><MenuItem ><DashboardIcon style={iconStyle} /> DashBoard</MenuItem></Link>} {props.isAuthenticated && <Link style={{ textDecoration: 'none', color: '#444' }} to={'/'}><MenuItem name="dashboardButton"><DashboardIcon style={iconStyle} /> DashBoard</MenuItem></Link>}
{props.isAuthenticated && <MenuItem onClick={props.toggleModalState} > <AssignmentIcon style={iconStyle} /> Create Form </MenuItem>} {props.isAuthenticated && <MenuItem name="createFormButton" onClick={props.toggleModalState} > <AssignmentIcon style={iconStyle} /> Create Form </MenuItem>}
{props.isAuthenticated && <Link style={{ textDecoration: 'none', color: '#444' }} to={'/mysubmissions'}><MenuItem ><AccountCircleIcon style={iconStyle} />My Submissions</MenuItem></Link>} {props.isAuthenticated && <Link style={{ textDecoration: 'none', color: '#444' }} to={'/mysubmissions'}><MenuItem name="viewMySubmissionsButton" ><AccountCircleIcon style={iconStyle} />My Submissions</MenuItem></Link>}
{props.isAuthenticated && <Link style={{ textDecoration: 'none', color: '#444' }} to={'/partnerssubmissions'}><MenuItem ><PeopleIcon style={iconStyle} />Partner Submissions</MenuItem></Link>} {props.isAuthenticated && <Link style={{ textDecoration: 'none', color: '#444' }} to={'/partnerssubmissions'}><MenuItem name="viewPartnerSubmissionsButton"><PeopleIcon style={iconStyle} />Partner Submissions</MenuItem></Link>}
{props.isAuthenticated && <h3> Settings </h3>} {props.isAuthenticated && <h3> Settings </h3>}
{!props.isAuthenticated && <Link style={{ textDecoration: 'none', color: '#444' }} to={'/login'}><MenuItem > <AccountCircleIcon style={{marginRight: 8}} /> Log In</MenuItem></Link>} {!props.isAuthenticated && <Link style={{ textDecoration: 'none', color: '#444' }} to={'/login'}><MenuItem > <AccountCircleIcon style={{marginRight: 8}} /> Log In</MenuItem></Link>}
{!props.isAuthenticated && <Link style={{ textDecoration: 'none', color: '#444' }} to={'/signup'}><MenuItem > <PeopleIcon style={{marginRight: 8}} /> Sign Up</MenuItem></Link>} {!props.isAuthenticated && <Link style={{ textDecoration: 'none', color: '#444' }} to={'/signup'}><MenuItem > <PeopleIcon style={{marginRight: 8}} /> Sign Up</MenuItem></Link>}
{props.isAuthenticated && <Link style={{ textDecoration: 'none', color: '#444' }} to={'/account'}><MenuItem ><PeopleIcon style={iconStyle} />My Account</MenuItem></Link>}
{props.isAuthenticated && <MenuItem onClick={props.logout}> <PowerSettingsNewIcon style={iconStyle} /> Logout</MenuItem>} {props.isAuthenticated && <MenuItem name="logoutButton" onClick={props.logout}> <PowerSettingsNewIcon style={iconStyle} /> Logout</MenuItem>}
</div> </div>
<div style={{fontSize: 16}} onClick={props.handleClose} className='closemenu'> <div style={{fontSize: 16}} onClick={props.handleClose} className='closemenu'>
<KeyboardArrowUpIcon style={{position: 'relative', top: 7}} /> close menu <KeyboardArrowUpIcon style={{position: 'relative', top: 7}} /> <KeyboardArrowUpIcon style={{position: 'relative', top: 7}} /> close menu <KeyboardArrowUpIcon style={{position: 'relative', top: 7}} />
......
...@@ -19,14 +19,14 @@ function ConfirmDelete(props) { ...@@ -19,14 +19,14 @@ function ConfirmDelete(props) {
<DialogTitle id="alert-dialog-title">{"Confirm deletion"}</DialogTitle> <DialogTitle id="alert-dialog-title">{"Confirm deletion"}</DialogTitle>
<DialogContent> <DialogContent>
<DialogContentText id="alert-dialog-description"> <DialogContentText id="alert-dialog-description">
Are you sure you want to delete "{props.doc.title}"? Are you sure you want to delete this?
</DialogContentText> </DialogContentText>
</DialogContent> </DialogContent>
<DialogActions> <DialogActions>
<Button onClick={props.toggleConfirmModal} color="primary"> <Button name="cancelDelete" onClick={props.toggleConfirmModal} color="primary">
Cancel Cancel
</Button> </Button>
<Button onClick={()=>{ props.confirmDelete(props.type, props.doc) }} color="secondary" autoFocus> <Button name="confirmDelete" onClick={()=>{ props.confirmDelete(props.type, props.doc) }} color="secondary" autoFocus>
Confirm Confirm
</Button> </Button>
</DialogActions> </DialogActions>
......
...@@ -126,7 +126,7 @@ const Login = (props) => { ...@@ -126,7 +126,7 @@ const Login = (props) => {
<Typography component="p" className={classes.password}> <Typography component="p" className={classes.password}>
<span style={{ marginRight: 6 }}>Don't have an account? </span> <span style={{ marginRight: 6 }}>Don't have an account? </span>
<Button variant="outlined" size='small' style={{ fontSize: 10 }} color="primary" > <Link to={'/signup'}>Sign up</Link> </Button> <Button name="toSignUpButton" variant="outlined" size='small' style={{ fontSize: 10 }} color="primary" > <Link to={'/signup'}>Sign up</Link> </Button>
</Typography> </Typography>
<Typography component="p" className={classes.password}> <Typography component="p" className={classes.password}>
......
...@@ -70,7 +70,7 @@ const Signup = (props) => { ...@@ -70,7 +70,7 @@ const Signup = (props) => {
} }
if (isAuthenticated) { if (isAuthenticated) {
return <Redirect to="/userhome" />; return <Redirect to="/" />;
} }
return (<Container component="main" style={{ marginBottom: 100, marginTop: 100, paddingLeft: 0, paddingRight: 0 }} maxWidth="xs"> return (<Container component="main" style={{ marginBottom: 100, marginTop: 100, paddingLeft: 0, paddingRight: 0 }} maxWidth="xs">
...@@ -87,7 +87,7 @@ const Signup = (props) => { ...@@ -87,7 +87,7 @@ const Signup = (props) => {
fullWidth fullWidth
id="username" id="username"
label="Display Name" label="Display Name"
name="Display Name" name="displayName"
onChange={(ev) => { handleChange(ev, 'displayName') }} onChange={(ev) => { handleChange(ev, 'displayName') }}
/> />
<TextField <TextField
...@@ -118,7 +118,7 @@ const Signup = (props) => { ...@@ -118,7 +118,7 @@ const Signup = (props) => {
<Typography component="p" className={classes.password}> <Typography component="p" className={classes.password}>
<span style={{ marginRight: 6 }}>Already have an account? </span> <span style={{ marginRight: 6 }}>Already have an account? </span>
<Button variant="outlined" size='small' style={{ fontSize: 10 }} color="primary" > <Link to={'/login'}>Login</Link> </Button> <Button name="toSignInButton" variant="outlined" size='small' style={{ fontSize: 10 }} color="primary" > <Link to={'/login'}>Sign In</Link> </Button>
</Typography> </Typography>
{createError?.isError && ( {createError?.isError && (
...@@ -132,6 +132,7 @@ const Signup = (props) => { ...@@ -132,6 +132,7 @@ const Signup = (props) => {
</Typography> </Typography>
)} )}
<Button <Button
name="signUpButton"
disabled={false} disabled={false}
type="button" type="button"
fullWidth fullWidth
......
...@@ -69,15 +69,15 @@ function SubmitFormModal(props) { ...@@ -69,15 +69,15 @@ function SubmitFormModal(props) {
let az = a.trim(); let az = a.trim();
az = capitalize(az); az = capitalize(az);
return (<Button onClick={(e)=>{onSelectAnswer(e, q , qindex)}} style={{ marginRight: 8 }} return (<Button name="answer" onClick={(e)=>{onSelectAnswer(e, q , qindex)}} style={{ marginRight: 8 }}
variant={q?.selectedanswer !== az ? "outlined" : "contained"} variant={q?.selectedanswer !== az ? "outlined" : "contained"}
color={q?.selectedanswer == az ? "secondary" : "primary"} key={qindex + aindex + 4324}> {az} color={q?.selectedanswer == az ? "secondary" : "primary"} key={qindex + aindex + 4324}> {az}
</Button>) </Button>)
}); });
return (<div style={{ width: "60%", margin: 'auto', paddingBottom: 16, borderBottom: '1px solid #999' }} key={qindex}> return (<div style={{ width: "60%", margin: 'auto', paddingBottom: 16, borderBottom: '1px solid #999' }} key={qindex}>
<div style={{ marginTop: 16 }}> <span> Question {`${qindex + 1}`} : </span> {q.question} </div> <div name="submitQuestion" style={{ marginTop: 16 }}> <span> Question {`${qindex + 1}`} : </span> {q.question} </div>
<div style={{ marginTop: 8 }}> <span> Answers: </span> {answers} </div> <div name="submitAnswers" style={{ marginTop: 8 }}> <span> Answers: </span> {answers} </div>
<TextField <TextField
style={{width: '100%'}} style={{width: '100%'}}
variant="outlined" variant="outlined"
...@@ -110,6 +110,7 @@ function SubmitFormModal(props) { ...@@ -110,6 +110,7 @@ function SubmitFormModal(props) {
<Button style={{ textAlign: 'center' }} onClick={props.toggleModalState } > Cancel </Button> <Button style={{ textAlign: 'center' }} onClick={props.toggleModalState } > Cancel </Button>
<Button <Button
name="submitButton"
onClick={() => { props.submitFS(qForm) }} onClick={() => { props.submitFS(qForm) }}
style={{ color: 'green', marginLeft: 50, textAlign: 'center' }} > style={{ color: 'green', marginLeft: 50, textAlign: 'center' }} >
{`Submit`} {`Submit`}
......
...@@ -13,6 +13,7 @@ import TableRow from '@material-ui/core/TableRow'; ...@@ -13,6 +13,7 @@ import TableRow from '@material-ui/core/TableRow';
import Paper from '@material-ui/core/Paper'; import Paper from '@material-ui/core/Paper';
import moment from 'moment'; import moment from 'moment';
import ViewSubModal from './ViewSubModal.react'; import ViewSubModal from './ViewSubModal.react';
import ConfirmDeletion from './ConfirmDeletion.react';
import Loader from './Loader.react'; import Loader from './Loader.react';
//Icons //Icons
...@@ -34,8 +35,21 @@ const SubsScreen = (props) => { ...@@ -34,8 +35,21 @@ const SubsScreen = (props) => {
const classes = useStyles(); const classes = useStyles();
const [openModal, setOpenModal] = React.useState(false); const [openModal, setOpenModal] = React.useState(false);
const [openConfirmModal, setOpenConfirmModal] = React.useState(false);
const [selectedEl, setSelectedEl] = React.useState(false); const [selectedEl, setSelectedEl] = React.useState(false);
const confirmDelete = (type, doc) => {
dispatch(removeSubOrForm(type, doc.docid, true));
setOpenConfirmModal(!openConfirmModal)
}
const toggleConfirmModal = (doc) => {
if(doc) {
setSelectedEl(doc);
}
setOpenConfirmModal(!openConfirmModal);
}
const toggleModalState = (el) => { const toggleModalState = (el) => {
if (el && openModal === false) { if (el && openModal === false) {
setSelectedEl(el); setSelectedEl(el);
...@@ -66,14 +80,13 @@ const SubsScreen = (props) => { ...@@ -66,14 +80,13 @@ const SubsScreen = (props) => {
<TableCell align="left">{el.submittedbyname}</TableCell> <TableCell align="left">{el.submittedbyname}</TableCell>
<TableCell align="left">{el.submittedbyemail}</TableCell> <TableCell align="left">{el.submittedbyemail}</TableCell>
<TableCell align="right"><div style={{padding: 16, paddingRight: 0}}> <TableCell align="right"><div style={{padding: 16, paddingRight: 0}}>
<VisibilityIcon onClick={() => {toggleModalState(el)}} <VisibilityIcon name="viewSubmissionButton" onClick={() => {toggleModalState(el)}}
style={{ cursor: 'pointer', color: '#3498DB', fontSize: 16}} /> style={{ cursor: 'pointer', color: '#3498DB', fontSize: 16}} />
{/*/This is set to false to be disabled , you may enablde later if requires, make sure you import the correct action in dispatch*/} {userId === el.submittedbyid &&
{false && userId === el.createdbyid && <DeleteIcon name="deleteSubmissionButton" onClick={() => { toggleConfirmModal(el) }}
<DeleteIcon onClick={() => { dispatch(removeSubOrForm('submission', el.docid)) }}
style={{ fontSize: 16, marginLeft: 8, cursor: 'pointer', color: '#E74C3C' }} />} style={{ fontSize: 16, marginLeft: 8, cursor: 'pointer', color: '#E74C3C' }} />}
</div> </div>
</TableCell> </TableCell>
</TableRow>); </TableRow>);
});; });;
...@@ -81,7 +94,7 @@ const SubsScreen = (props) => { ...@@ -81,7 +94,7 @@ const SubsScreen = (props) => {
return (<> return (<>
<div className='dashboard dashboard--table' > {`${props.mySubs ? 'My' : 'Partners'}`} Form Submissions </div> <div className='dashboard dashboard--table' > {`${props.mySubs ? 'My' : 'Partners'}`} Form Submissions </div>
<TableContainer className={'udbpaper-mui'} component={Paper}> <TableContainer className={'udbpaper-mui'} component={Paper}>
<Table className={classes.table} size="small" aria-label="a dense table"> <Table name="formSubmissionsTable" className={classes.table} size="small" aria-label="a dense table">
<TableHead> <TableHead>
<TableRow> <TableRow>
<TableCell>Title</TableCell> <TableCell>Title</TableCell>
...@@ -97,24 +110,28 @@ const SubsScreen = (props) => { ...@@ -97,24 +110,28 @@ const SubsScreen = (props) => {
</TableBody> </TableBody>
</Table> </Table>
</TableContainer> </TableContainer>
{openModal && <ViewSubModal {openModal && <ViewSubModal
open={openModal} open={openModal}
selectedTemplate={selectedEl} selectedTemplate={selectedEl}
toggleModalState={toggleModalState} toggleModalState={toggleModalState}
/>} />}
</>);
{openConfirmModal && <ConfirmDeletion
open={openConfirmModal}
doc={selectedEl}
type={'submission'}
toggleConfirmModal={toggleConfirmModal}
confirmDelete={confirmDelete}
/>}
</>);
} }
if (!formsubs || formsubs.length === 0) { if (!formsubs || formsubs.length === 0) {
return (props.mySubs ? (<div className='dashboard dashboard--table' > You do not have any submissions to any forms yet. </div>) return (<div className='dashboard dashboard--table' > You have not {props.mySubs ? "made" : "received"} any submissions yet. </div>);
: (<div className='dashboard dashboard--table' > Partneres have not submitted any forms yet. </div>)
);
} }
}; };
function mapStateToProps(state) { function mapStateToProps(state) {
return { return {
formsubs: state.form.formsubs, formsubs: state.form.formsubs,
...@@ -125,6 +142,4 @@ function mapStateToProps(state) { ...@@ -125,6 +142,4 @@ function mapStateToProps(state) {
} }
} }
export default connect(mapStateToProps)(SubsScreen); export default connect(mapStateToProps)(SubsScreen);
\ No newline at end of file
...@@ -167,7 +167,7 @@ function TemplateModal(props) { ...@@ -167,7 +167,7 @@ function TemplateModal(props) {
id="Question" id="Question"
helperText={'Insert the question text here.'} helperText={'Insert the question text here.'}
label="Question" label="Question"
name="Question" name="question"
value={newQuestion.question} value={newQuestion.question}
onChange={(evt) => onQuestionChange('question', evt.target.value)} onChange={(evt) => onQuestionChange('question', evt.target.value)}
/> />
...@@ -182,13 +182,14 @@ function TemplateModal(props) { ...@@ -182,13 +182,14 @@ function TemplateModal(props) {
onChange={(evt) => onQuestionChange('answers', evt.target.value)} onChange={(evt) => onQuestionChange('answers', evt.target.value)}
/> />
<Button style={{ width: 100, color: 'green', display: 'block' }} onClick={addOption}> Add an entry </Button> <Button name="addEntry" style={{ width: 100, color: 'green', display: 'block' }} onClick={addOption}> Add an entry </Button>
</div> </div>
</Container> </Container>
<div>{renderedQuestions}</div> <div>{renderedQuestions}</div>
<div className='newformbuttons'> <div className='newformbuttons'>
<Button style={{ textAlign: 'center' }} onClick={() => { setNewQuestion({ question: '', answers: '' }); resetState(); props.toggleModalState() }} > Cancel </Button> <Button style={{ textAlign: 'center' }} onClick={() => { setNewQuestion({ question: '', answers: '' }); resetState(); props.toggleModalState() }} > Cancel </Button>
<Button <Button
name="submit"
onClick={() => { setNewQuestion({ question: '', answers: '' }); props.addNewForm(formState, 'template') }} onClick={() => { setNewQuestion({ question: '', answers: '' }); props.addNewForm(formState, 'template') }}
disabled={formState.title.length < 2 && formState.questions.length < 1} disabled={formState.title.length < 2 && formState.questions.length < 1}
style={{ color: 'green', marginLeft: 50, textAlign: 'center' }} > style={{ color: 'green', marginLeft: 50, textAlign: 'center' }} >
......
...@@ -38,7 +38,6 @@ const UserDashboard = (props) => { ...@@ -38,7 +38,6 @@ const UserDashboard = (props) => {
const [openModal, setOpenModal] = React.useState(false); const [openModal, setOpenModal] = React.useState(false);
const [openSubModal, setOpenSubModal] = React.useState(false); const [openSubModal, setOpenSubModal] = React.useState(false);
const [openConfirmModal, setOpenConfirmModal] = React.useState(false); const [openConfirmModal, setOpenConfirmModal] = React.useState(false);
const [selectedEl, setSelectedEl] = React.useState(false); const [selectedEl, setSelectedEl] = React.useState(false);
const submitFS = (sfObj, formDoc) => { const submitFS = (sfObj, formDoc) => {
...@@ -71,7 +70,7 @@ const UserDashboard = (props) => { ...@@ -71,7 +70,7 @@ const UserDashboard = (props) => {
setSelectedEl(doc); setSelectedEl(doc);
} }
setOpenConfirmModal(!openConfirmModal); setOpenConfirmModal(!openConfirmModal);
} }
const toggleSubModal = (el) => { const toggleSubModal = (el) => {
if (el && openSubModal === false) { if (el && openSubModal === false) {
...@@ -113,14 +112,14 @@ const UserDashboard = (props) => { ...@@ -113,14 +112,14 @@ const UserDashboard = (props) => {
{<TableCell align="left">{el.sharewith.length !== 0 ? el.sharewith.toString() : '-'}</TableCell>} {<TableCell align="left">{el.sharewith.length !== 0 ? el.sharewith.toString() : '-'}</TableCell>}
<TableCell style={{ minWidth: 90 }} align="right"> <TableCell style={{ minWidth: 90 }} align="right">
<div style={{padding: 16, paddingRight: 0}}> <div style={{padding: 16, paddingRight: 0}}>
<VisibilityIcon onClick={() => toggleModalState(el)} <VisibilityIcon name="viewFormButton" onClick={() => toggleModalState(el)}
style={{ cursor: 'pointer', color: '#3498DB', fontSize: 16}} /> style={{ cursor: 'pointer', color: '#3498DB', fontSize: 16}} />
<ContactMailIcon onClick={() => toggleSubModal(el)} <ContactMailIcon name="submitFormButton" onClick={() => toggleSubModal(el)}
style={{ fontSize: 16, cursor: 'pointer', color: '#138D75', marginLeft: 8 }} /> style={{ fontSize: 16, cursor: 'pointer', color: '#138D75', marginLeft: 8 }} />
{userId === el.createdbyid && {userId === el.createdbyid &&
<DeleteIcon onClick={() => { toggleConfirmModal(el) }} <DeleteIcon name="deleteFormButton" onClick={() => { toggleConfirmModal(el) }}
style={{ fontSize: 16, marginLeft: 8, cursor: 'pointer', color: '#E74C3C' }} />} style={{ fontSize: 16, marginLeft: 8, cursor: 'pointer', color: '#E74C3C' }} />}
</div> </div>
</TableCell> </TableCell>
...@@ -130,7 +129,7 @@ const UserDashboard = (props) => { ...@@ -130,7 +129,7 @@ const UserDashboard = (props) => {
return (<> return (<>
<div className='dashboard dashboard--table' >Form Templates DashBoard </div> <div className='dashboard dashboard--table' >Form Templates DashBoard </div>
<TableContainer className={'udbpaper-mui'} component={Paper}> <TableContainer className={'udbpaper-mui'} component={Paper}>
<Table className={classes.table} size="small" aria-label="a dense table"> <Table name="dashboardTable" className={classes.table} size="small" aria-label="a dense table">
<TableHead> <TableHead>
<TableRow> <TableRow>
<TableCell>Title</TableCell> <TableCell>Title</TableCell>
...@@ -153,6 +152,7 @@ const UserDashboard = (props) => { ...@@ -153,6 +152,7 @@ const UserDashboard = (props) => {
selectedTemplate={selectedEl} selectedTemplate={selectedEl}
toggleModalState={toggleModalState} toggleModalState={toggleModalState}
/>} />}
{openConfirmModal && <ConfirmDeletion {openConfirmModal && <ConfirmDeletion
open={openConfirmModal} open={openConfirmModal}
doc={selectedEl} doc={selectedEl}
...@@ -176,7 +176,6 @@ const UserDashboard = (props) => { ...@@ -176,7 +176,6 @@ const UserDashboard = (props) => {
}; };
function mapStateToProps(state) { function mapStateToProps(state) {
return { return {
loading: state.form.loading, loading: state.form.loading,
...@@ -187,6 +186,4 @@ function mapStateToProps(state) { ...@@ -187,6 +186,4 @@ function mapStateToProps(state) {
} }
} }
export default connect(mapStateToProps)(UserDashboard); export default connect(mapStateToProps)(UserDashboard);
\ No newline at end of file
...@@ -60,7 +60,7 @@ function ViewTemplateModal(props) { ...@@ -60,7 +60,7 @@ function ViewTemplateModal(props) {
</Container> </Container>
<div className='newformbuttons'> <div className='newformbuttons'>
<Button style={{ textAlign: 'center' }} onClick={ props.toggleModalState } > Done </Button> <Button name="doneButton" style={{ textAlign: 'center' }} onClick={ props.toggleModalState } > Done </Button>
</div> </div>
</div> </div>
); );
......
...@@ -33,23 +33,23 @@ function ViewTemplateModal(props) { ...@@ -33,23 +33,23 @@ function ViewTemplateModal(props) {
let renderedQuestions = formData.questions.map((el, i) => { let renderedQuestions = formData.questions.map((el, i) => {
let answers = el.answers.map((el, i) => { let answers = el.answers.map((el, i) => {
return (<Button style={{ marginRight: 8 }} variant="outlined" color="primary" key={i + 4324}> {el} </Button>) return (<Button name="answer" style={{ marginRight: 8 }} variant="outlined" color="primary" key={i + 4324}> {el} </Button>)
}); });
return (<div style={{ width: "60%", margin: 'auto', paddingBottom: 16, borderBottom: '1px solid #999' }} key={i}> return (<div style={{ width: "60%", margin: 'auto', paddingBottom: 16, borderBottom: '1px solid #999' }} key={i}>
<div style={{ marginTop: 16 }}> <span> Question: </span> {el.question} </div> <div name="viewQuestion" style={{ marginTop: 16 }}> <span> Question: </span> {el.question} </div>
<div style={{ marginTop: 8 }}> <span> Answers: </span> {answers} </div> <div name="viewAnswers" style={{ marginTop: 8 }}> <span> Answers: </span> {answers} </div>
</div>); </div>);
}); });
const body = ( const body = (
<div style={modalStyle} className={classes.paper}> <div style={modalStyle} className={classes.paper}>
<h2 style={{ textAlign: 'center', textDecoration: 'underline' }}>{formData.title}</h2> <h2 name="formTitle" style={{ textAlign: 'center', textDecoration: 'underline' }}>{formData.title}</h2>
<Container component="main" maxWidth="md"> <Container component="main" maxWidth="md">
<div> <div>
<h3>Description</h3> <h3 name="formDescription">Description</h3>
<p style={{borderBottom: '1px solid #999', padding: '16px 16px 32px 16px'}}> {formData.description} </p> <p style={{borderBottom: '1px solid #999', padding: '16px 16px 32px 16px'}}> {formData.description} </p>
</div> </div>
...@@ -58,7 +58,7 @@ function ViewTemplateModal(props) { ...@@ -58,7 +58,7 @@ function ViewTemplateModal(props) {
</Container> </Container>
<div className='newformbuttons'> <div className='newformbuttons'>
<Button style={{ textAlign: 'center' }} onClick={ props.toggleModalState } > Done </Button> <Button name="doneButton" style={{ textAlign: 'center' }} onClick={ props.toggleModalState } > Done </Button>
</div> </div>
</div> </div>
); );
......
...@@ -183,9 +183,15 @@ export const addFormSubsOrTemplate = (fbdoc, type) => dispatch => { ...@@ -183,9 +183,15 @@ export const addFormSubsOrTemplate = (fbdoc, type) => dispatch => {
}; };
export const removeSubOrForm = (type, docid) => dispatch => { export const removeSubOrForm = (type, docid, isSub = false) => dispatch => {
myFirebase.firestore().collection(type).doc(docid).delete().then(() => { myFirebase.firestore().collection(type).doc(docid).delete().then(() => {
dispatch(fetchForms(type, false)); if (isSub)
{
dispatch(fetchSub(true));
}
else {
dispatch(fetchForms(type, false));
}
}).catch((err) => { }).catch((err) => {
dispatch(formsError(err)); dispatch(formsError(err));
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment