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.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.getNonEmptyTerms = this.getNonEmptyTerms.bind(this);
23 this.createPdf = this.createPdf.bind(this);
24 this.setPdfLink = this.setPdfLink.bind(this);
25 this.camundaService = new CamundaService(this.setPdfLink);
29 event.preventDefault();
30 const target = event.target;
32 const terms = this.state.terms;
33 terms.forEach((term) => {
40 handleTermChange(id, value) {
41 const terms = this.state.terms;
43 terms: terms.set(id, value),
47 handleAddTerm(event) {
51 handleRemoveTerm(id) {
52 const terms = this.state.terms;
54 terms: terms.delete(id),
59 const terms = this.state.terms;
60 const termId = this.state.nextTermId;
62 terms: terms.set(termId, ''),
63 nextTermId: termId + 1,
69 terms: new Map().set(0, ''),
75 const terms = this.state.terms;
76 return terms.filter((value, key) => value.trim() !== '');
80 const terms = this.getNonEmptyTerms();
82 this.camundaService.submitPdfForm(terms);
94 <div className="sentiment-analysis">
95 <form onSubmit={this.handleSubmit}>
96 <Heading size={3} Style="margin-top:1em">Search Terms: </Heading>
97 <SearchTermsInput terms={this.state.terms}
98 onTermChange={this.handleTermChange}
99 onAddTerm={this.handleAddTerm}
100 onRemoveTerm={this.handleRemoveTerm}/>
101 <Form.Field kind="group">
102 <p className="control">
103 <Button color="info" type="submit" value="Submit">Submit</Button>
105 <p className="control">
106 <Button value="Reset" onClick={this.emptyTerms}>Reset</Button>
110 <PdfReport pdfLink={this.state.pdfLink}/>
116 SentimentAnalysis.propTypes = {};
118 export default SentimentAnalysis;