-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mu irte for action item form #16
base: development
Are you sure you want to change the base?
Changes from 3 commits
1134197
00f62a2
4eb7281
de74000
f7111ab
298d5fa
79e35dc
8772ad0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import React, { useState, useRef } from 'react'; | ||
import { withStyles, ThemeProvider } from '@material-ui/core/styles'; | ||
import { withStyles, ThemeProvider, MuiThemeProvider } from '@material-ui/core/styles'; | ||
import Grid from '@material-ui/core/Grid'; | ||
import TextField from '@material-ui/core/TextField'; | ||
import Typography from '@material-ui/core/Typography'; | ||
|
@@ -9,7 +9,9 @@ import Button from '@material-ui/core/Button'; | |
import Paper from '@material-ui/core/Paper'; | ||
import ActionItemCategoryTag from 'components/ActionItemCategoryTag'; | ||
import theme from 'utils/theme'; | ||
import styles from './styles'; | ||
import { styles, defaultTheme } from './styles'; | ||
import MUIRichTextEditor from 'mui-rte'; | ||
import { convertToRaw } from 'draft-js'; | ||
|
||
function ActionItemForm({ | ||
classes, | ||
|
@@ -36,6 +38,11 @@ function ActionItemForm({ | |
setCategory({ target: { value: newCategory } }); | ||
}; | ||
|
||
const handleDescriptionChange = state => { | ||
const value = JSON.stringify(convertToRaw(state.getCurrentContent())); | ||
setDescription({ target: {value} }) | ||
}; | ||
|
||
const categoryList = categories.map(category => { | ||
const isSelectedCategory = | ||
categorySelected && categorySelected === category; | ||
|
@@ -51,7 +58,6 @@ function ActionItemForm({ | |
}); | ||
|
||
const allFieldsFilled = title && description && categorySelected; | ||
|
||
return ( | ||
<ThemeProvider theme={theme}> | ||
<Paper elevation={0} className={classes.formStyle}> | ||
|
@@ -102,7 +108,26 @@ function ActionItemForm({ | |
> | ||
<Typography variant="body1">Assignment Description</Typography> | ||
</div> | ||
<TextField | ||
<MuiThemeProvider theme={defaultTheme}> | ||
<MUIRichTextEditor | ||
name="description" | ||
className={classes.searchBar} | ||
value={description} | ||
onChange={handleDescriptionChange} | ||
variant="outlined" | ||
label="Assignment description" | ||
controls={[ | ||
'bold', | ||
'italic', | ||
'underline', | ||
'numberList', | ||
'bulletList', | ||
'link', | ||
'code', | ||
]} | ||
/> | ||
</MuiThemeProvider> | ||
{/* <TextField | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can take out the old commented code now that the new code works! |
||
variant="outlined" | ||
className={classes.searchBar} | ||
onChange={e => setDescription(e)} | ||
|
@@ -113,7 +138,7 @@ function ActionItemForm({ | |
required | ||
error={failedSubmit && !description} | ||
rows={2} | ||
/> | ||
/> */} | ||
</Grid> | ||
<Grid item> | ||
<Typography variant="body1">Due Date (Optional)</Typography> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,9 +11,12 @@ import { | |
DialogContentText, | ||
Grid, | ||
} from '@material-ui/core'; | ||
import { withStyles, ThemeProvider } from '@material-ui/core/styles'; | ||
import { withStyles, ThemeProvider, MuiThemeProvider } from '@material-ui/core/styles'; | ||
import ActionItemCategoryTag from 'components/ActionItemCategoryTag'; | ||
import styles from './styles'; | ||
import { styles, defaultTheme } from './styles'; | ||
import MUIRichTextEditor from 'mui-rte'; | ||
import { convertToRaw } from 'draft-js'; | ||
|
||
class ActionItemModal extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
|
@@ -34,6 +37,11 @@ class ActionItemModal extends React.Component { | |
this.setState({ [name]: value }); | ||
}; | ||
|
||
handleDescriptionChange = name => state => { | ||
const value = JSON.stringify(convertToRaw(state.getCurrentContent())); | ||
this.setState({ [name]: value }); | ||
}; | ||
|
||
handleFileChange = event => { | ||
const file = event.target.files[0] ? event.target.files[0] : null; | ||
const fileURL = file ? window.URL.createObjectURL(file) : null; | ||
|
@@ -101,7 +109,6 @@ class ActionItemModal extends React.Component { | |
</Grid> | ||
); | ||
}); | ||
|
||
return ( | ||
<ThemeProvider theme={theme}> | ||
<Dialog | ||
|
@@ -161,20 +168,26 @@ class ActionItemModal extends React.Component { | |
> | ||
Description | ||
</DialogContentText> | ||
<TextField | ||
value={this.state.description} | ||
className={classes.dialogContentTextFieldStyle} | ||
name="description" | ||
onChange={this.handleChange('description')} | ||
variant="outlined" | ||
margin="dense" | ||
id="description" | ||
label="Assignment description" | ||
type="text" | ||
fullWidth | ||
multiline | ||
rows={4} | ||
/> | ||
<MuiThemeProvider theme={defaultTheme}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we want to make this backwards compatible as well? if so, can do the ternary here too |
||
<MUIRichTextEditor | ||
name="description" | ||
value={description} | ||
onChange={this.handleDescriptionChange('description')} | ||
variant="outlined" | ||
id="description" | ||
label="Assignment description" | ||
className={classes.MUIRichTextEditorStyle} | ||
controls={[ | ||
'bold', | ||
'italic', | ||
'underline', | ||
'numberList', | ||
'bulletList', | ||
'link', | ||
'code', | ||
]} | ||
/> | ||
</MuiThemeProvider> | ||
</DialogContent> | ||
<DialogContent className={classes.dialogContentStyle}> | ||
<DialogContentText className={classes.dialogContentTextStyle}> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would add a code comment above, just saying that this is for backwards compatibility