Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Hotfix: getData #464

Merged
merged 1 commit into from
May 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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