From e3e8aa55057db6786a8ecb4d8e49a0728d809e9c Mon Sep 17 00:00:00 2001 From: Michael Winsauer Date: Sun, 20 Jan 2019 00:32:54 +0100 Subject: [PATCH] Convert terms to camunda format --- service-website/src/components/SentimentAnalysis.js | 11 ++++++++++- service-website/src/services/CamundaService.js | 8 ++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/service-website/src/components/SentimentAnalysis.js b/service-website/src/components/SentimentAnalysis.js index 644d69d..11b789c 100644 --- a/service-website/src/components/SentimentAnalysis.js +++ b/service-website/src/components/SentimentAnalysis.js @@ -20,6 +20,7 @@ class SentimentAnalysis extends Component { this.handleRemoveTerm = this.handleRemoveTerm.bind(this); this.addEmptyTerm = this.addEmptyTerm.bind(this); this.emptyTerms = this.emptyTerms.bind(this); + this.getNonEmptyTerms = this.getNonEmptyTerms.bind(this); this.createPdf = this.createPdf.bind(this); } @@ -69,8 +70,16 @@ class SentimentAnalysis extends Component { }); } + getNonEmptyTerms() { + const terms = this.state.terms; + return terms.map(term => term.trim() !== ''); + } + createPdf() { - this.camundaService.submitPdfForm(null); + const terms = this.getNonEmptyTerms(); + if (terms.length > 0) { + this.camundaService.submitPdfForm(terms); + } } render() { diff --git a/service-website/src/services/CamundaService.js b/service-website/src/services/CamundaService.js index c2010c6..133139c 100644 --- a/service-website/src/services/CamundaService.js +++ b/service-website/src/services/CamundaService.js @@ -12,12 +12,16 @@ class CamundaService { } submitPdfForm(terms) { - terms = [{term: "abc"}, {term: "def"}]; + const termsValue = []; + terms.forEach(term => { + termsValue.push({term}); + }); + console.log('termsValue: ', termsValue); const submitFormUrl = 'process-definition/key/sentiment-analysis/submit-form'; const data = { variables: { terms: { - value: JSON.stringify(terms), + value: JSON.stringify(termsValue), type: "Json" } } -- 2.43.0