Skip to content

Commit

Permalink
fixed bug: getTextArray getting an empty array
Browse files Browse the repository at this point in the history
  • Loading branch information
tocttou committed Jun 30, 2016
1 parent 3dba83d commit eab5105
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class NGHDemoPage extends React.Component {
$("#appbar-progress").progress({
percent: "0%"
});
}, 1000);
}, 1000);
});
getDeployed(this.props.params.repoId).then(data => {
this.setState({demoModel: JSON.parse(data)[0]});
Expand Down
20 changes: 13 additions & 7 deletions src/components/inputcomponents/ImageInput/ImageInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,24 @@ import toastr from 'toastr';
class ImageInput extends React.Component {
constructor(props) {
super(props);
this.formData = '';
this.state = {
files: []
};
this.sendRequest = this.sendRequest.bind(this);
this.updateFormData = this.updateFormData.bind(this);
}

componentDidMount() {
this.formData = new FormData($('#send-text')[0]);
}

shouldComponentUpdate() {
return false;
}

sendRequest(sendAddr, calling_context) {

let formData = new FormData($('#send-text')[0]);
this.state.files.map(file => {
formData.set(file.newfilename, file.newfile, file.newfilename);
});

if (calling_context === "demo") {
let timeout1 = '';
let timeout2 = '';
Expand Down Expand Up @@ -48,7 +52,7 @@ class ImageInput extends React.Component {
$.ajax({
type: 'POST',
url: sendAddr,
data: this.formData,
data: formData,
contentType: false,
cache: false,
processData: false,
Expand All @@ -70,7 +74,9 @@ class ImageInput extends React.Component {
}

updateFormData(newfile, newfilename) {
this.formData.set(newfilename, newfile, newfilename);
this.setState({
files: [...this.state.files, {newfilename, newfile}]
});
}

render() {
Expand Down
19 changes: 13 additions & 6 deletions src/components/inputcomponents/TextImageInput/TextImageInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,24 @@ import toastr from 'toastr';
class TextImageInput extends React.Component {
constructor(props) {
super(props);
this.state = {
files: []
};
this.sendRequest = this.sendRequest.bind(this);
this.updateFormData = this.updateFormData.bind(this);
}

componentDidMount() {
this.formData = new FormData($('#send-text')[0]);
}

shouldComponentUpdate() {
return false;
}

sendRequest(sendAddr, calling_context) {

let formData = new FormData($('#send-text')[0]);
this.state.files.map(file => {
formData.set(file.newfilename, file.newfile, file.newfilename);
});

if (calling_context === "demo") {
let timeout1 = '';
let timeout2 = '';
Expand Down Expand Up @@ -47,7 +52,7 @@ class TextImageInput extends React.Component {
$.ajax({
type: 'POST',
url: sendAddr,
data: this.formData,
data: formData,
contentType: false,
cache: false,
processData: false,
Expand Down Expand Up @@ -78,7 +83,9 @@ class TextImageInput extends React.Component {
}

updateFormData(newfile, newfilename) {
this.formData.set(newfilename, newfile, newfilename);
this.setState({
files: [...this.state.files, {newfilename, newfile}]
});
}

render() {
Expand Down
2 changes: 2 additions & 0 deletions src/components/inputcomponents/TextInput/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ class TextInput extends React.Component {
}

sendRequest(sendAddr, calling_context) {

const form_data = new FormData($('#send-text')[0]);

if (calling_context === "demo") {
let timeout1 = '';
let timeout2 = '';
Expand Down

0 comments on commit eab5105

Please sign in to comment.