forked from EarthWindandJS/help-desk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request EarthWindandJS#20 from wpcarro/master
Attaches Marcus's and Chelsea's Components to backend
- Loading branch information
Showing
9 changed files
with
252 additions
and
8,577 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
(function() { | ||
var _formData = { | ||
author: 'William Carroll', | ||
content: '', | ||
tags: [], | ||
timesubmitted: '' | ||
} | ||
|
||
var HelpRequestTab = React.createClass({ | ||
sendRequest: function(e) { | ||
_formData.content = this.refs.content.value.trim() | ||
_formData.timesubmitted = new Date(); | ||
//EDIT THIS WILL!!!!!!!!!!!!!! v | ||
e.preventDefault(); | ||
$.post('/', _formData, function(data) { | ||
console.log('successfully posted! data: ' + JSON.stringify(data)); | ||
}); | ||
}, | ||
render: function() { | ||
return ( | ||
<div className="help"> | ||
<input type="text" className="request-text" placeholder="Input your question here" ref='content'/> | ||
<SubmitTags /><br/> | ||
<button id='request-submit' onClick={this.sendRequest}>Submit Help Request</button> | ||
</div> | ||
); | ||
} | ||
}); | ||
|
||
var SubmitTags = React.createClass({ | ||
getInitialState: function() { | ||
return { | ||
inputData: [], | ||
}; | ||
}, | ||
handleSubmit: function (event) { | ||
event.preventDefault(); | ||
console.log('pushing'); | ||
|
||
this.state.inputData.push({key:this.refs.tag.value.trim(), text: this.refs.tag.value.trim()}); | ||
_formData.tags.push(this.refs.tag.value.trim()); | ||
console.log('formData is: ' + _formData); | ||
this.setState({ | ||
inputData: this.state.inputData | ||
}); | ||
|
||
console.log(this.state.inputData) | ||
this.refs.tag.value = ''; | ||
}, | ||
render: function () { | ||
return ( | ||
<div className='submit-tags'> | ||
<form className="submit-tag" onSubmit={this.handleSubmit} > | ||
<input type="text" id='input' autoComplete="on" placeholder="Enter tags" ref="tag"/> | ||
<input type="submit" value="Add Tags" /> | ||
</form> | ||
<RenderTags data={this.state.inputData} /> | ||
</div> | ||
); | ||
} | ||
}); | ||
|
||
var RenderTags = React.createClass({ | ||
closeTag: function (e) { | ||
$(e.target).closest('div').remove(); | ||
//remove from the database as well | ||
}, | ||
render: function () { | ||
var tagNodes = this.props.data.map(function(tag, idx) { | ||
return ( | ||
<div className='chip' onClick={this.closeTag} key={idx}>{tag.text} | ||
<i className='material-icons'>close</i> | ||
</div> | ||
); | ||
}.bind(this)) | ||
return ( | ||
<div className="taglist">{tagNodes}</div> | ||
); | ||
} | ||
}); | ||
|
||
ReactDOM.render( | ||
<HelpRequestTab className='help-request' />, document.getElementById('help-request') | ||
); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.