How to use the formiojs/Formio function in formiojs

To help you get started, we’ve selected a few formiojs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github formio / react-formio / src / modules / form / actions.js View on Github external
return (dispatch, getState) => {
    // Check to see if the form is already loaded.
    const form = selectForm(name, getState());
    if (form.components && Array.isArray(form.components) && form.components.length && form._id === id) {
      return;
    }

    const path = `${Formiojs.getProjectUrl()}/${id ? `form/${id}` : name}`;
    const formio = new Formiojs(path);

    dispatch(requestForm(name, id, path));

    return formio.loadForm()
      .then((result) => {
        dispatch(receiveForm(name, result));
        done(null, result);
      })
      .catch((result) => {
        dispatch(failForm(name, result));
        done(result);
      });
  };
};
github formio / react-formio / src / modules / submission / actions.js View on Github external
export const getSubmission = (name, id, formId, done = () => {}) => (dispatch, getState) => {
  // Check to see if the submission is already loaded.
  if (getState().id === id) {
    return;
  }

  const url = `${Formiojs.getProjectUrl()}/${formId ? `form/${formId}` : name}/submission/${id}`;
  const formio = new Formiojs(url);

  dispatch(requestSubmission(name, id, formId, url));

  formio.loadSubmission()
    .then((result) => {
      dispatch(receiveSubmission(name, result));
      done(null, result);
    })
    .catch((error) => {
      dispatch(failSubmission(name, error));
      done(error);
    });
};
github formio / react-formio / src / modules / submission / actions.js View on Github external
export const saveSubmission = (name, data, formId, done = () => {}) => (dispatch) => {
  dispatch(sendSubmission(name, data));

  const id = data._id;

  const formio = new Formiojs(`${Formiojs.getProjectUrl()}/${formId ? `form/${formId}` : name}/submission${id ? `/${id}` : ''}`);

  formio.saveSubmission(data)
    .then((result) => {
      const url = `${Formiojs.getProjectUrl()}/${formId ? `form/${formId}` : name}/submission/${result._id}`;
      dispatch(receiveSubmission(name, result, url));
      done(null, result);
    })
    .catch((error) => {
      dispatch(failSubmission(name, error));
      done(error);
    });
};
github formio / react-formio / src / modules / form / actions.js View on Github external
return (dispatch) => {
    const path = `${Formiojs.getProjectUrl()}/form/${id}`;
    const formio = new Formiojs(path);

    return formio.deleteForm()
      .then(() => {
        dispatch(resetForm(name));
        done();
      })
      .catch((result) => {
        dispatch(failForm(name, result));
        done(result);
      });
  };
};
github formio / react-formio / src / modules / form / actions.js View on Github external
return (dispatch) => {
    dispatch(sendForm(name, form));

    const id = form._id;
    const path = `${Formiojs.getProjectUrl()}/form${id ? `/${id}` : ''}`;
    const formio = new Formiojs(path);

    formio.saveForm(form)
      .then((result) => {
        const url = `${Formiojs.getProjectUrl()}/form/${result._id}`;
        dispatch(receiveForm(name, result, url));
        done(null, result);
      })
      .catch((result) => {
        dispatch(failForm(name, result));
        done(result);
      });
  };
};