From 91a4aa1105998561ae5c8adc0aec73d86a1ac23e Mon Sep 17 00:00:00 2001 From: JT Date: Thu, 25 Oct 2018 20:43:04 -0400 Subject: [PATCH] Graph x-axis fix and slight modal edit --- web/src/components/Graph.jsx | 2 +- web/src/components/Modal.jsx | 164 +++++++++++++++++++++++------------ 2 files changed, 108 insertions(+), 58 deletions(-) diff --git a/web/src/components/Graph.jsx b/web/src/components/Graph.jsx index f3f0bdd..da1f5fc 100644 --- a/web/src/components/Graph.jsx +++ b/web/src/components/Graph.jsx @@ -77,7 +77,7 @@ export class Graph extends React.Component{ { // ajax resolved (could be bad/good request, but server responded) if(xhr.status === 200){ // good request - attempt to parse results json try{ - console.log("Text Received") + console.log("Text Received"); } catch(err){ // json parse error (should never happen) @@ -47,72 +54,115 @@ export class Modal extends React.Component{ console.log("Really bad Error");// request died signal }); }else{ - if(this.state.type == null){ - this.errorRef += "No Header Selected|" + + let textError = this.textRef.current.value; + + if(this.typeError == true && textError == ""){ + this.errorMsg = "No Header Selected|No Text Entered"; + }else if(this.typeError == true){ + this.errorMsg = "No Header Selected"; + }else if(textError == ""){ + this.errorMsg = "No Text Entered"; } - if(this.textRef.current.value == null){ - this.errorRef += "No Teaxt Entered" + + if(this.errorMsg != ""){ + this.errorTime = true; } + + console.log("Error Time: "+this.errorTime); + this.buildError(); + } } - getInputsDictionary(){ - let type = this.state.type, - text = this.textRef.current.value; + BuildArray(){ + let text = this.textRef.current.value; + let type = ""; + + if(this.state.other){ + type = this.headerRef.current.value; + }else{ + type = this.type; + } // MUST match API expectations! return {type,text}; } // on change of radio button set type - getType(type){ - this.state.type = type; + onTypeSelect(type){ + this.type = type; + + if(this.type == "other"){ + this.setState({other: true}); + }else{ + this.setState({other: false}); + } + + this.typeError = false; + } + + TypeOther(){ + if(!this.state.other){ + return null; + }else{ + return( +
+ +
+ ); + } } + buildError(){ + console.log("Error Message: "+this.errorMsg); + if(this.errorTime){ + return( + + {this.errorMsg} + + ); + }else{ + this.errorMsg = ""; + return null; + } + } + render(){ return ( -
+
- - - - - - -
- × -
- - - - - - - - - - - - - - - -
-

Contact Us

- -
- this.getType("problem")} name="type" value="problem"/>Have a problem? -   - this.getType("idea")} name="type" value="idea"/>Have an idea? -   - this.getType("other")} name="type" value="other"/>Other -
- -
- -
+
+ × +
+
+ +
+

Contact Us

+
+ {this.buildError()} +
+
+
+ this.onTypeSelect("Bug Report")} name="types" value="problem"/>Have a problem? +   + this.onTypeSelect("Feature Request")} name="types" value="idea"/>Have an idea? +   + this.onTypeSelect("other")} name="types" value="other"/>Other +
+
+ {this.TypeOther()} +
+
+ +
+
+ +
+ +
-
+ ); } -} +} \ No newline at end of file