Ivan - Add custom response field [skip ci]
This commit is contained in:
parent
037f004d0c
commit
93366c02da
|
@ -17,7 +17,7 @@ class TicketEvent extends React.Component {
|
||||||
]),
|
]),
|
||||||
author: React.PropTypes.object,
|
author: React.PropTypes.object,
|
||||||
content: React.PropTypes.string,
|
content: React.PropTypes.string,
|
||||||
date: React.PropTypes.number
|
date: React.PropTypes.string
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
import RichTextEditor from 'react-rte-browserify';
|
||||||
|
|
||||||
import i18n from 'lib-app/i18n';
|
import i18n from 'lib-app/i18n';
|
||||||
import API from 'lib-app/api-call';
|
import API from 'lib-app/api-call';
|
||||||
import store from 'app/store';
|
|
||||||
import SessionStore from 'lib-app/session-store';
|
import SessionStore from 'lib-app/session-store';
|
||||||
import SessionActions from 'actions/session-actions';
|
|
||||||
|
|
||||||
import TicketEvent from 'app-components/ticket-event';
|
import TicketEvent from 'app-components/ticket-event';
|
||||||
import AreYouSure from 'app-components/are-you-sure';
|
import AreYouSure from 'app-components/are-you-sure';
|
||||||
|
@ -33,13 +32,11 @@ class TicketViewer extends React.Component {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(props) {
|
state = {
|
||||||
super(props);
|
loading: false,
|
||||||
|
commentValue: RichTextEditor.createEmptyValue(),
|
||||||
this.state = {
|
commentEdited: false
|
||||||
loading: false
|
};
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const ticket = this.props.ticket;
|
const ticket = this.props.ticket;
|
||||||
|
@ -61,7 +58,7 @@ class TicketViewer extends React.Component {
|
||||||
<div className="ticket-viewer__response-title row">{i18n('RESPOND')}</div>
|
<div className="ticket-viewer__response-title row">{i18n('RESPOND')}</div>
|
||||||
{this.renderCustomResponses()}
|
{this.renderCustomResponses()}
|
||||||
<div className="ticket-viewer__response-field row">
|
<div className="ticket-viewer__response-field row">
|
||||||
<Form onSubmit={this.onSubmit.bind(this)} loading={this.state.loading}>
|
<Form {...this.getCommentFormProps()}>
|
||||||
<FormField name="content" validation="TEXT_AREA" required field="textarea" />
|
<FormField name="content" validation="TEXT_AREA" required field="textarea" />
|
||||||
<SubmitButton>{i18n('RESPOND_TICKET')}</SubmitButton>
|
<SubmitButton>{i18n('RESPOND_TICKET')}</SubmitButton>
|
||||||
</Form>
|
</Form>
|
||||||
|
@ -204,7 +201,7 @@ class TicketViewer extends React.Component {
|
||||||
|
|
||||||
customResponsesNode = (
|
customResponsesNode = (
|
||||||
<div className="ticket-viewer__response-custom row">
|
<div className="ticket-viewer__response-custom row">
|
||||||
<DropDown items={customResponses} size="medium" />
|
<DropDown items={customResponses} size="medium" onChange={this.onCustomResponsesChanged.bind(this)}/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -212,6 +209,20 @@ class TicketViewer extends React.Component {
|
||||||
return customResponsesNode;
|
return customResponsesNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getCommentFormProps() {
|
||||||
|
return {
|
||||||
|
onSubmit: this.onSubmit.bind(this),
|
||||||
|
loading: this.state.loading,
|
||||||
|
onChange: (formState) => {this.setState({
|
||||||
|
commentValue: formState.content,
|
||||||
|
commentEdited: true
|
||||||
|
})},
|
||||||
|
values: {
|
||||||
|
'content': this.state.commentValue
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
onDepartmentDropdownChanged(event) {
|
onDepartmentDropdownChanged(event) {
|
||||||
AreYouSure.openModal(null, this.changeDepartment.bind(this, event.index));
|
AreYouSure.openModal(null, this.changeDepartment.bind(this, event.index));
|
||||||
}
|
}
|
||||||
|
@ -268,6 +279,21 @@ class TicketViewer extends React.Component {
|
||||||
}).then(this.onTicketModification.bind(this));
|
}).then(this.onTicketModification.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onCustomResponsesChanged({index}) {
|
||||||
|
let replaceContentWithCustomResponse = () => {
|
||||||
|
this.setState({
|
||||||
|
commentValue: RichTextEditor.createValueFromString(this.props.customResponses[index-1].content || '', 'html'),
|
||||||
|
commentEdited: false
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
if (this.state.commentEdited && index) {
|
||||||
|
AreYouSure.openModal(null, replaceContentWithCustomResponse);
|
||||||
|
} else {
|
||||||
|
replaceContentWithCustomResponse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onSubmit(formState) {
|
onSubmit(formState) {
|
||||||
this.setState({
|
this.setState({
|
||||||
loading: true
|
loading: true
|
||||||
|
|
|
@ -39,11 +39,11 @@ module.exports = [
|
||||||
return {
|
return {
|
||||||
status: 'success',
|
status: 'success',
|
||||||
data: [
|
data: [
|
||||||
{name: 'Common issue #1', language: 'en', content: 'some content'},
|
{name: 'Common issue #1', language: 'en', content: 'some content 1'},
|
||||||
{name: 'Common issue #2', language: 'en', content: 'some content'},
|
{name: 'Common issue #2', language: 'en', content: 'some content 2'},
|
||||||
{name: 'Common issue #3', language: 'en', content: 'some content'},
|
{name: 'Common issue #3', language: 'en', content: 'some content 3'},
|
||||||
{name: 'Häufiges Problem #1', language: 'de', content: 'einige Inhalte'},
|
{name: 'Häufiges Problem #1', language: 'de', content: 'einige Inhalte 1'},
|
||||||
{name: 'Häufiges Problem #2', language: 'de', content: 'einige Inhalte'}
|
{name: 'Häufiges Problem #2', language: 'de', content: 'einige Inhalte 2'}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue