fix purpose dropdown
This commit is contained in:
parent
71aa9c128e
commit
e1276a60e1
|
@ -35,8 +35,7 @@ const CommentWidget = props => {
|
||||||
// Last draft comment without a creator field goes into the reply field
|
// Last draft comment without a creator field goes into the reply field
|
||||||
const draftReply = getDraftReply(all.slice().reverse().find(b => b.draft && !b.creator), all.length > 1);
|
const draftReply = getDraftReply(all.slice().reverse().find(b => b.draft && !b.creator), all.length > 1);
|
||||||
// All except draft reply
|
// All except draft reply
|
||||||
let comments = all.filter(b => b != draftReply);
|
const comments = all.filter(b => b != draftReply);
|
||||||
comments = comments.map(elem => getDraftReply(elem));
|
|
||||||
const onEditReply = evt => {
|
const onEditReply = evt => {
|
||||||
const prev = draftReply.value;
|
const prev = draftReply.value;
|
||||||
const updated = evt.target.value;
|
const updated = evt.target.value;
|
||||||
|
@ -55,7 +54,6 @@ const CommentWidget = props => {
|
||||||
const updated = evt.value.trim();
|
const updated = evt.value.trim();
|
||||||
if (draftReply.value == '' && updated.length > 0) {
|
if (draftReply.value == '' && updated.length > 0) {
|
||||||
draftReply.purpose = updated;
|
draftReply.purpose = updated;
|
||||||
this.setState({purpose: updated});
|
|
||||||
} else {
|
} else {
|
||||||
props.onUpdateBody(draftReply, { ...draftReply, purpose: updated });
|
props.onUpdateBody(draftReply, { ...draftReply, purpose: updated });
|
||||||
}
|
}
|
||||||
|
@ -109,12 +107,12 @@ const CommentWidget = props => {
|
||||||
onChange={onEditReply}
|
onChange={onEditReply}
|
||||||
onSaveAndClose={() => props.onSaveAndClose()}
|
onSaveAndClose={() => props.onSaveAndClose()}
|
||||||
/>
|
/>
|
||||||
{ props.purpose == true &&
|
{ props.purpose == true && draftReply.value.length > 0 &&
|
||||||
<TypeDropdown
|
<TypeDropdown
|
||||||
editable={true}
|
editable={true}
|
||||||
content={draftReply.purpose}
|
content={draftReply.purpose}
|
||||||
onChange={onUpdatePurpose}
|
onChange={onUpdatePurpose}
|
||||||
onSaveAndClose={props.onSaveAndClose}
|
onSaveAndClose={() => props.onSaveAndClose()}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -8,12 +8,14 @@ export default class TypeDropdown extends Component {
|
||||||
render() {
|
render() {
|
||||||
const selectedOption = this.props.content ? {'value': this.props.content, 'label': this.props.content.charAt(0).toUpperCase() + this.props.content.slice(1) } : undefined;
|
const selectedOption = this.props.content ? {'value': this.props.content, 'label': this.props.content.charAt(0).toUpperCase() + this.props.content.slice(1) } : undefined;
|
||||||
return (
|
return (
|
||||||
|
<div class="purposedropdown">
|
||||||
<Select
|
<Select
|
||||||
value={selectedOption}
|
value={selectedOption}
|
||||||
onChange={this.props.onChange}
|
onChange={this.props.onChange}
|
||||||
options={purposes}
|
options={purposes}
|
||||||
isDisabled={!this.props.editable}
|
isDisabled={!this.props.editable}
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue