This file contains hidden or 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
| // --methods above here -- | |
| render(){ | |
| let { _id, fileName, createdAt, src, deleteDate, } = this.props; | |
| return( | |
| <tr key={_id}> | |
| <td><img src={src}{fileName} height=50" /> {fileName}</td> | |
| <td>{src}</td> | |
| <td>{createdAt}</td> | |
| <td>{deleteDate} |
This file contains hidden or 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
| handleRemove(imageId){ | |
| if ( confirm('Are you sure? This is permanent!') ) { | |
| // send `imageId` to database to be deleted. Framework dependent | |
| } | |
| } | |
| changeFontAwesome() { | |
| this.setState({ editDate: !this.state.editDate }); | |
| } | |
This file contains hidden or 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
| class CustomRow extends React.Component { | |
| constructor(props) { | |
| super(props); | |
| this.state = { | |
| startDate: moment(props.deleteDate), | |
| editDate: true, | |
| } | |
| this.handleDateChange = this.handleDateChange.bind(this); | |
| this.handleRemove = this.handleRemove.bind(this); | |
| this.changeFontAwesome = this.changeFontAwesome.bind(this); |
This file contains hidden or 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
| Class Images extends React.Component { | |
| constructor(props) { | |
| super(props); | |
| } | |
| render(){ | |
| // deconstruct props to get access to individual params | |
| let { loading, images, } = this.props; | |
| return( |
This file contains hidden or 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
| const handleDelete = (imageId) => { | |
| if (confirm('Are you sure? This is permanent!') ) { | |
| // call to database to delete and catch any errors | |
| try { | |
| images: ImagesCollection.remove(imageId); | |
| } catch (exception) { | |
| throw new Error('500', exception); | |
| } | |
| } | |
| } |
This file contains hidden or 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
| {images.map( ({_id, fileName, size, src, }) => ( | |
| <tr key={_id}> | |
| <td><img src={src}{fileName} /></td> | |
| <td>{fileName}</td> | |
| <td>{size}</td> | |
| <td><Button onClick={() => handleDelete(_id)} > Delete </Button></td> | |
| </tr> | |
| ) } |
This file contains hidden or 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
| {images.map( ({_id, fileName, size, src, }) => { | |
| counter++; | |
| (<tr key={_id}> | |
| <td>{counter}.</td> | |
| <td><img src={src}{fileName} /></td> | |
| <td>{fileName}</td> | |
| <td>{size}</td> | |
| </tr> | |
| ) } | |
| } |
This file contains hidden or 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
| {images.map( ({_id, fileName, size, src, }) => () | |
| // HTML/JSX here | |
| )}; |
This file contains hidden or 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
| // Old ES5 syntax | |
| if( loading === false ) { | |
| return ( | |
| // HTML/JSX output here with database contents | |
| ) | |
| } else { | |
| return <Loading /> | |
| } |
This file contains hidden or 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
| !loading ? ( |