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.handleReset = this.handleReset.bind(this);
22 this.addEmptyTerm = this.addEmptyTerm.bind(this);
23 this.emptyTerms = this.emptyTerms.bind(this);
24 this.getNonEmptyTerms = this.getNonEmptyTerms.bind(this);
25 this.createPdf = this.createPdf.bind(this);
26 this.setPdfLink = this.setPdfLink.bind(this);
27 this.camundaService = new CamundaService(this.setPdfLink);
31 event.preventDefault();
41 handleTermChange(id, value) {
42 const terms = this.state.terms;
44 terms: terms.set(id, value),
48 handleAddTerm(event) {
52 handleRemoveTerm(id) {
53 const terms = this.state.terms;
55 terms: terms.delete(id),
60 event.preventDefault();
62 terms: new Map().set(0, ''),
70 const terms = this.state.terms;
71 const termId = this.state.nextTermId;
73 terms: terms.set(termId, ''),
74 nextTermId: termId + 1,
80 terms: new Map().set(0, ''),
86 const terms = this.state.terms;
87 return terms.filter((value, key) => value.trim() !== '');
91 const terms = this.getNonEmptyTerms();
93 this.camundaService.submitPdfForm(terms);
106 <div className="sentiment-analysis">
109 <form onSubmit={this.handleSubmit}>
110 <Heading size={3} id="headerMargin">Search Terms:</Heading>
111 <SearchTermsInput terms={this.state.terms}
112 onTermChange={this.handleTermChange}
113 onAddTerm={this.handleAddTerm}
114 onRemoveTerm={this.handleRemoveTerm}/>
115 <Form.Field kind="group">
116 <p className="control">
117 <Button color="info" type="submit" value="Submit">Submit</Button>
119 <p className="control">
120 <Button value="Reset" onClick={this.handleReset}>Reset</Button>
126 <PdfReport pdfLink={this.state.pdfLink} loading={this.state.isLoading}/>
134 SentimentAnalysis.propTypes = {};
136 export default SentimentAnalysis;