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, Columns} from "react-bulma-components/full";
8 class SentimentAnalysis extends Component {
9 constructor(props, context) {
10 super(props, context);
12 terms: new Map().set(0, ''),
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);
25 this.setPdfLink = this.setPdfLink.bind(this);
26 this.camundaService = new CamundaService(this.setPdfLink);
30 event.preventDefault();
31 const target = event.target;
33 const terms = this.state.terms;
34 terms.forEach((term) => {
45 handleTermChange(id, value) {
46 const terms = this.state.terms;
48 terms: terms.set(id, value),
52 handleAddTerm(event) {
56 handleRemoveTerm(id) {
57 const terms = this.state.terms;
59 terms: terms.delete(id),
64 const terms = this.state.terms;
65 const termId = this.state.nextTermId;
67 terms: terms.set(termId, ''),
68 nextTermId: termId + 1,
74 terms: new Map().set(0, ''),
80 const terms = this.state.terms;
81 return terms.filter((value, key) => value.trim() !== '');
85 const terms = this.getNonEmptyTerms();
87 this.camundaService.submitPdfForm(terms);
99 <div className="sentiment-analysis">
102 <form onSubmit={this.handleSubmit}>
103 <Heading size={3} id="headerMargin">Search Terms: </Heading>
104 <SearchTermsInput terms={this.state.terms}
105 onTermChange={this.handleTermChange}
106 onAddTerm={this.handleAddTerm}
107 onRemoveTerm={this.handleRemoveTerm}/>
108 <Form.Field kind="group">
109 <p className="control">
110 <Button color="info" type="submit" value="Submit">Submit</Button>
112 <p className="control">
113 <Button value="Reset" onClick={this.emptyTerms}>Reset</Button>
119 <PdfReport pdfLink={this.state.pdfLink} loading={this.state.isLoading}/>
127 SentimentAnalysis.propTypes = {};
129 export default SentimentAnalysis;