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.getNonEmptyTerms = this.getNonEmptyTerms.bind(this);
24 this.createPdf = this.createPdf.bind(this);
28 event.preventDefault();
29 const target = event.target;
31 const terms = this.state.terms;
32 terms.forEach((term) => {
39 handleTermChange(id, value) {
40 const terms = this.state.terms;
42 terms: terms.set(id, value),
46 handleAddTerm(event) {
50 handleRemoveTerm(id) {
51 const terms = this.state.terms;
53 terms: terms.delete(id),
58 const terms = this.state.terms;
59 const termId = this.state.nextTermId;
61 terms: terms.set(termId, ''),
62 nextTermId: termId + 1,
68 terms: new Map().set(0, ''),
74 const terms = this.state.terms;
75 return terms.filter((value, key) => value.trim() !== '');
79 const terms = this.getNonEmptyTerms();
81 this.camundaService.submitPdfForm(terms);
87 <div className="sentiment-analysis">
88 <form onSubmit={this.handleSubmit}>
89 <Heading size={3} Style="margin-top:1em">Search Terms: </Heading>
90 <SearchTermsInput terms={this.state.terms}
91 onTermChange={this.handleTermChange}
92 onAddTerm={this.handleAddTerm}
93 onRemoveTerm={this.handleRemoveTerm}/>
94 <Form.Field kind="group">
95 <p className="control">
96 <Button color="info" type="submit" value="Submit">Submit</Button>
98 <p className="control">
99 <Button value="Reset" onClick={this.emptyTerms}>Reset</Button>
103 <PdfReport pdfLink={this.state.pdfLink}/>
109 SentimentAnalysis.propTypes = {};
111 export default SentimentAnalysis;