fixed PR #15 comments
This commit is contained in:
57
web/src/components/helper/AnswerSourceForm.js
Normal file
57
web/src/components/helper/AnswerSourceForm.js
Normal file
@@ -0,0 +1,57 @@
|
||||
import React, {Component} from 'react';
|
||||
import {Button, SelectionControlGroup} from 'react-md';
|
||||
import Modal from './Modal';
|
||||
|
||||
class AnswerSourceForm extends Component{
|
||||
|
||||
render(){
|
||||
return(
|
||||
<Modal
|
||||
title="Answer type"
|
||||
actions={[
|
||||
<Button
|
||||
flat
|
||||
swapTheming
|
||||
onClick={this.props.onClose.bind (this)}
|
||||
key="cancel"
|
||||
>
|
||||
Cancel
|
||||
</Button>,
|
||||
<Button
|
||||
flat
|
||||
primary
|
||||
swapTheming
|
||||
key="save"
|
||||
onClick={this.props.onSave.bind(this)}
|
||||
>
|
||||
Save
|
||||
</Button>,
|
||||
]}
|
||||
>
|
||||
<SelectionControlGroup
|
||||
id="answer-source"
|
||||
name="answer-source"
|
||||
type="radio"
|
||||
label="Import answer from:"
|
||||
onChange={this.props.onSourceChange.bind(this)}
|
||||
controls={[
|
||||
{
|
||||
label: 'Predefined answer',
|
||||
value: '0'
|
||||
},
|
||||
{
|
||||
label: 'WordPress titles',
|
||||
value: '1',
|
||||
},
|
||||
{
|
||||
label: 'WordPress latest news',
|
||||
value: '2',
|
||||
},
|
||||
]}
|
||||
defaultValue={String(this.props.answerType)}
|
||||
/>
|
||||
</Modal>);
|
||||
}
|
||||
}
|
||||
|
||||
export default AnswerSourceForm;
|
||||
44
web/src/components/helper/AnswerTextBox.js
Normal file
44
web/src/components/helper/AnswerTextBox.js
Normal file
@@ -0,0 +1,44 @@
|
||||
import React, {Component} from 'react';
|
||||
import {TextField} from 'react-md';
|
||||
import '../../css/components/IntentDetails.css';
|
||||
import '../../css/Common.css';
|
||||
import {
|
||||
ANSWER_MAX_LENGTH,
|
||||
ANSWER_TYPE,
|
||||
} from '../../config/constants';
|
||||
|
||||
class AnswerTextBox extends Component {
|
||||
|
||||
render () {
|
||||
//theese are defaults for ANSWER_TYPE.PREDEFINED
|
||||
let labelText="Answer";
|
||||
let valueText=this.props.answer;
|
||||
let onChangeValue=this.props.handleAnswerEdit;
|
||||
switch(this.props.answerType){
|
||||
case ANSWER_TYPE.EXTERNAL_SOURCE_WP_TITLES:
|
||||
case ANSWER_TYPE.EXTERNAL_SOURCE_WP_NEWS:
|
||||
labelText="Answer source";
|
||||
valueText=this.props.externalAnswerSource;
|
||||
onChangeValue=this.props.handleAnswerSourceEdit
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return(
|
||||
<div className="QuestionBox">
|
||||
<TextField
|
||||
id="intent answer"
|
||||
lineDirection="center"
|
||||
label={labelText}
|
||||
placeholder={labelText}
|
||||
maxLength={ANSWER_MAX_LENGTH}
|
||||
className="md-cell md-cell--bottom IntentDetailsInputBoxes"
|
||||
onChange={onChangeValue}
|
||||
value={valueText}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default AnswerTextBox;
|
||||
23
web/src/components/helper/Modal.js
Normal file
23
web/src/components/helper/Modal.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import React, { Component } from 'react';
|
||||
import '../../css/components/Modal.css';
|
||||
|
||||
class Modal extends Component {
|
||||
render() {
|
||||
const { title, children, actions } = this.props;
|
||||
return (
|
||||
<div className="modal">
|
||||
<div className="modal-content">
|
||||
<h2 className="header">
|
||||
{title}
|
||||
</h2>
|
||||
{children}
|
||||
<div className="actions">
|
||||
{actions}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Modal;
|
||||
Reference in New Issue
Block a user