Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
setForm(form) {
// Create the form.
this._form = form;
// Allow the form to provide component overrides.
if (form && form.settings && form.settings.components) {
this.options.components = form.settings.components;
}
this.initialized = false;
const rebuild = this.rebuild() || NativePromise.resolve();
return rebuild.then(() => {
this.emit('formLoad', form);
this.triggerRecaptcha();
// Make sure to trigger onChange after a render event occurs to speed up form rendering.
setTimeout(() => {
this.onChange();
this.formReadyResolve();
}, 0);
return this.formReady;
});
}
parentComponent.saveChildComponent(submissionData);
}
const rebuild = parentComponent.rebuild() || NativePromise.resolve();
return rebuild.then(() => {
this.emit('saveComponent',
parentContainer ? parentContainer[index] : [],
originalComponent,
parentComponent.component,
path,
index,
isNew
);
this.emit('change', this.form);
});
}
return NativePromise.resolve();
}
localize() {
if (i18next.initialized) {
return Promise.resolve(i18next);
}
i18next.initialized = true;
return new Promise((resolve, reject) => {
i18next.init(this.options.i18n, (err, t) => {
if (err) {
return reject(err);
}
resolve(i18next);
});
});
}
Formio.createForm = (element, form, options) => {
if (typeof form === 'string') {
return (new Formio(form)).loadForm().then((formObj) => {
let instance = Formio.formFactory(element, formObj, options);
instance.url = form;
instance.nosubmit = false;
instance.loadSubmission();
return instance.ready.then(() => instance);
});
}
else {
return Promise.resolve(Formio.formFactory(element, form, options));
}
};
getProjectId() {
if (!this.projectId) {
return NativePromise.resolve('');
}
if (this.isObjectId(this.projectId)) {
return NativePromise.resolve(this.projectId);
}
else {
return this.loadProject().then((project) => {
return project._id;
});
}
}
attachNode(element, node) {
if (!element) {
return NativePromise.resolve();
}
let componentsPromise = NativePromise.resolve();
let childrenPromise = NativePromise.resolve();
node.refs = _.reduce(
element.children,
(refs, child) => (
child.hasAttribute('ref')
? {
...refs,
[child.getAttribute('ref')]: child,
}
: refs
),
{},
);
if (node.refs.content) {
attachComponents(node, ...args) {
if (this.builderMode) {
return super.attachComponents.call(this, node, ...args);
}
this.loadRefs.call(node, node.refs.content, {
nodeEdit: 'single',
});
return node.refs.nodeEdit
? super.attachComponents(node.refs.nodeEdit, node.components)
: NativePromise.resolve();
}
get ready() {
return NativePromise.resolve(this);
}
ready() {
const readyPromise = readyMap.get(this) || new Promise((resolve, reject) => {
reject(new Error('Unknown player. Probably unloaded.'));
});
return Promise.resolve(readyPromise);
}