import React from 'react'; import { OverlayTrigger, Tooltip, Button } from 'react-bootstrap'; import { Profile, Fa, FormDialog, AutoheightInput } from '../../components'; import moment from 'moment'; import { app } from '../../core/app'; // definition of the form fields to edit tags const issueEditorDef = { controls: [ { property: 'text', type: 'text', required: true, label: __('Issue.answer'), size: { md: 12 } } ], title: __('Issue.edtanswer') }; export default class IssueFollowUpsBox extends React.Component { constructor(props) { super(props); this.addAnswer = this.addAnswer.bind(this); this.editClick = this.editClick.bind(this); this.modalClose = this.modalClose.bind(this); this.editConfirm = this.editConfirm.bind(this); this.textChange = this.textChange.bind(this); this.state = { disabled: true, doc: {} }; } /** * Called when user adds a new comment */ addAnswer() { const txt = this.refs.input.getText(); this.props.onEvent('add', txt); this.refs.input.setText(''); } /** * Return a function to be called when user clicks on the edit link * @param {[type]} item [description] * @return {[type]} [description] */ editClick(item) { const self = this; return () => { self.setState({ edtitem: item, doc: { text: item.text } }); }; } /** * Called when user clicks on the close link * @return {[type]} [description] */ modalClose() { this.setState({ edtitem: null }); } /** * Called when user confirms the changed text in the dialog box * @return {[type]} [description] */ editConfirm() { const item = this.state.edtitem; this.props.onEvent('edit', item, this.state.doc.text); this.modalClose(); } /** * Return a function to be called when user clicks on the remove link * @param {[type]} item [description] * @return {[type]} [description] */ removeClick(item) { return () => app.messageDlg({ message: __('form.confirm_remove'), style: 'warning', type: 'YesNo' }).then(res => { if (res === 'yes') { this.props.onEvent('remove', item); } }); } /** * Called when the text of the input box is changed. Enable or disable the add button */ textChange() { this.setState({ disabled: !this.refs.input.getText().trim() }); } followUpsRender(followups) { if (!followups || followups.length === 0) { return null; } return (followups.map(followup => (