1 import React, {Component} from "react";
2 import {Map} from "immutable";
3 import PdfReport from "./PdfReport";
4 import SearchTermsInput from "./SearchTermsInput";
5 import CamundaService from "../services/CamundaService";
6 import {Button, Heading, Form} from "react-bulma-components/full";
8 class SentimentAnalysis extends Component {
9 constructor(props, context) {
10 super(props, context);
12 terms: new Map().set(0, ''),
16 this.camundaService = new CamundaService();
17 this.handleSubmit = this.handleSubmit.bind(this);
18 this.handleTermChange = this.handleTermChange.bind(this);
19 this.handleAddTerm = this.handleAddTerm.bind(this);
20 this.handleRemoveTerm = this.handleRemoveTerm.bind(this);
21 this.addEmptyTerm = this.addEmptyTerm.bind(this);
22 this.emptyTerms = this.emptyTerms.bind(this);
23 this.createPdf = this.createPdf.bind(this);
27 event.preventDefault();
28 const target = event.target;
30 const terms = this.state.terms;
31 terms.forEach((term) => {
38 handleTermChange(id, value) {
39 const terms = this.state.terms;
41 terms: terms.set(id, value),
45 handleAddTerm(event) {
49 handleRemoveTerm(id) {
50 const terms = this.state.terms;
52 terms: terms.delete(id),
57 const terms = this.state.terms;
58 const termId = this.state.nextTermId;
60 terms: terms.set(termId, ''),
61 nextTermId: termId + 1,
67 terms: new Map().set(0, ''),
73 this.camundaService.submitPdfForm(null);
78 <div className="sentiment-analysis">
79 <form onSubmit={this.handleSubmit}>
80 <Heading size={3} Style="margin-top:1em">Search Terms: </Heading>
81 <SearchTermsInput terms={this.state.terms}
82 onTermChange={this.handleTermChange}
83 onAddTerm={this.handleAddTerm}
84 onRemoveTerm={this.handleRemoveTerm}/>
85 <Form.Field kind="group">
86 <p className="control">
87 <Button color="info" type="submit" value="Submit">Submit</Button>
89 <p className="control">
90 <Button value="Reset" onClick={this.emptyTerms}>Reset</Button>
94 <PdfReport pdfLink={this.state.pdfLink}/>
100 SentimentAnalysis.propTypes = {};
102 export default SentimentAnalysis;