Skip to content

Commit

Permalink
Hotfix: getData (#464)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinchappell committed May 17, 2017
1 parent bf233a9 commit bece95b
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion demo/assets/js/form-builder.min.js

Large diffs are not rendered by default.

Binary file modified demo/assets/js/form-builder.min.js.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion dist/form-builder.min.js

Large diffs are not rendered by default.

Binary file modified dist/form-builder.min.js.gz
Binary file not shown.
12 changes: 1 addition & 11 deletions src/js/form-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -1424,17 +1424,7 @@ let stageOnChangeSelectors = [
document.dispatchEvent(events.fieldAdded);
},
removeField: h.removeField.bind(h),
getData: (type = 'js') => {
const stage = d.stage;
const h = h;
const data = {
js: () => h.prepData(stage),
xml: () => h.xmlSave(stage),
json: () => window.JSON.stringify(h.prepData(stage), null, '\t')
};

return data[type]();
},
getData: h.getFormData.bind(h),
setData: formData => {
h.stopIndex = undefined;
h.removeAllFields(d.stage, false);
Expand Down
18 changes: 18 additions & 0 deletions src/js/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -670,9 +670,11 @@ export default class Helpers {
fields[0].style.marginTop = `${-outerHeight}px`;
setTimeout(() => {
empty(stage).classList.remove('removing');
this.save();
}, 400);
} else {
empty(stage);
this.save();
}
}

Expand Down Expand Up @@ -1028,6 +1030,22 @@ export default class Helpers {
return m('input', null, attrs);
}

/**
* Gets the data for current instance of formBuilder
* @param {String} type
* @return {Array|String} formData
*/
getFormData(type = 'js') {
const h = this;
const data = {
js: () => h.prepData(h.d.stage),
xml: () => h.xmlSave(h.d.stage),
json: () => window.JSON.stringify(h.prepData(h.d.stage), null, '\t')
};

return data[type]();
}

// end class
}

Expand Down

0 comments on commit bece95b

Please sign in to comment.