Guest User

Untitled

a guest
Dec 15th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. export default class IncidentDetailsCommentPanel extends React.Component {
  2.  
  3. constructor(props) {
  4. super(props);
  5. this.state = {
  6. showAddCommentPopup: false
  7. }
  8. }
  9.  
  10. componentDidMount() {
  11. this.addCommentSubmit = this.addCommentSubmit.bind(this);
  12. this.addCommentCancel = this.addCommentCancel.bind(this);
  13. this.addCommentClicked = this.addCommentClicked.bind(this);
  14. }
  15.  
  16. addCommentClicked(){
  17. this.setState({
  18. showAddCommentPopup: true,
  19. });
  20. }
  21.  
  22. addCommentSubmit(){
  23.  
  24. }
  25.  
  26. addCommentCancel(){
  27. this.setState({
  28. showAddCommentPopup: false,
  29. });
  30. }
  31.  
  32. componentWillReceiveProps(nextProps) {
  33.  
  34. }
  35.  
  36. render() {
  37. let commentTemplate = null;
  38. if (this.props.commentList.length > 0) {
  39. commentTemplate = this.props.commentList.map((comment, index) => {
  40. var commentByUsername = "";
  41. if (comment.userDetails && comment.userDetails.userName) {
  42. commentByUsername = comment.userDetails.userName;
  43. }
  44. var lineData = T.t(comment.line, { user: commentByUsername, date: Util.getDateFromTimeStamp(comment.createdAt), time: Util.getTimeFromTimeStamp(comment.createdAt) }) ?
  45. T.t(comment.line, { user: commentByUsername, date: Util.getDateFromTimeStamp(comment.createdAt), time: Util.getTimeFromTimeStamp(comment.createdAt) }) : comment.line;
  46. var line = (<label className="incident_comment__item__title">
  47. {lineData}
  48. </label>);
  49. var commentText = comment.comment;
  50. if (comment.userDetails && comment.userDetails.userName) {
  51. let arrLine = lineData.split(comment.userDetails.userName);
  52. if (arrLine.length == 2) {
  53. line = (<label className="incident_comment__item__title">{arrLine[0]}<strong>{comment.userDetails.userName}</strong>{arrLine[1]}</label>);
  54. }
  55. }
  56. return (
  57. <div className="incident_comment__item dui-margin-bottom-10" key={index}>
  58. <img className="incident_comment__img dui-margin-right-10" src={Config.assetPath('/images/hp.png')} />
  59. <div className="comment_text">
  60. {line}
  61. <div className="txt-pre_line">{Util.urlify(commentText)}</div>
  62. </div>
  63. </div>
  64. );
  65. })
  66. } else {
  67. commentTemplate = (
  68. <div className="incident_comment__item dui-margin-bottom-10">
  69. <div className="comment_text">
  70. TODO
  71. </div>
  72. </div>
  73. )
  74. }
  75. return (
  76. <Panel title={T.texts["incidents.comments"]} >
  77. {commentTemplate}
  78. <Button appearance="secondary" id="add-comment" onClick={this.addCommentClicked}>{T.texts["controls.add_comment"]}</Button>
  79. <AddComment showPopup={this.state.showAddCommentPopup} addCommentCancel={this.addCommentCancel} addCommentSubmit={this.addCommentSubmit} />
  80. </Panel>
  81. );
  82. }
  83. }
Add Comment
Please, Sign In to add comment