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";
7 class SentimentAnalysis extends Component {
8 constructor(props, context) {
11 terms: new Map().set(0, ''),
15 this.camundaService = new CamundaService();
16 this.handleSubmit = this.handleSubmit.bind(this);
17 this.handleTermChange = this.handleTermChange.bind(this);
18 this.handleAddTerm = this.handleAddTerm.bind(this);
19 this.handleRemoveTerm = this.handleRemoveTerm.bind(this);
20 this.addEmptyTerm = this.addEmptyTerm.bind(this);
21 this.emptyTerms = this.emptyTerms.bind(this);
22 this.createPdf = this.createPdf.bind(this);
26 event.preventDefault();
27 const target = event.target;
29 const terms = this.state.terms;
30 terms.forEach((term) => {
37 handleTermChange(id, value) {
38 const terms = this.state.terms;
40 terms: terms.set(id, value),
44 handleAddTerm(event) {
48 handleRemoveTerm(id) {
49 const terms = this.state.terms;
51 terms: terms.delete(id),
56 const terms = this.state.terms;
57 const termId = this.state.nextTermId;
59 terms: terms.set(termId, ''),
60 nextTermId: termId + 1,
66 terms: new Map().set(0, ''),
72 this.camundaService.submitPdfForm(null);
77 <div className="sentiment-analysis">
78 <form onSubmit={this.handleSubmit}>
79 <label>Search Terms</label>
80 <SearchTermsInput terms={this.state.terms}
81 onTermChange={this.handleTermChange}
82 onAddTerm={this.handleAddTerm}
83 onRemoveTerm={this.handleRemoveTerm}/>
84 <input type="submit" value="Submit"/>
86 <PdfReport pdfLink={this.state.pdfLink}/>
92 SentimentAnalysis.propTypes = {};
94 export default SentimentAnalysis;