How to use the formiojs/Formio.getProjectUrl 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 / submissions / actions.js View on Github external
export const getSubmissions = (name, page = 0, params = {}, formId, done = () => {}) => (dispatch, getState) => {
  dispatch(requestSubmissions(name, page, params, formId));

  const {
    limit,
    query,
    select,
    sort,
  } = selectRoot(name, getState());
  const formio = new Formiojs(`${Formiojs.getProjectUrl()}/${(formId ? `form/${formId}` : name)}/submission`);
  const requestParams = {...query, ...params};

  // Ten is the default so if set to 10, don't send.
  if (limit !== 10) {
    requestParams.limit = limit;
  }
  else {
    delete requestParams.limit;
  }

  if (page !== 1) {
    requestParams.skip = (page - 1) * limit;
  }
  else {
    delete requestParams.skip;
  }
github formio / react-formio / src / modules / forms / actions.js View on Github external
export const indexForms = (name, page = 1, params = {}, done = () => {}) => (dispatch, getState) => {
  dispatch(requestForms(name, page, params));

  const {
    limit,
    query,
    select,
    sort,
  } = selectRoot(name, getState());
  const formio = new Formiojs(`${Formiojs.getProjectUrl()}/form`);
  const requestParams = {...query, ...params};

  // Ten is the default so if set to 10, don't send.
  if (limit !== 10) {
    requestParams.limit = limit;
  }
  else {
    delete requestParams.limit;
  }

  if (page !== 1) {
    requestParams.skip = (page - 1) * limit;
  }
  else {
    delete requestParams.skip;
  }
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 deleteSubmission = (name, id, formId, done = () => {}) => (dispatch, getState) => {
  const formio = new Formiojs(`${Formiojs.getProjectUrl()}/${formId ? `form/${formId}` : name}/submission/${id}`);

  return formio.deleteSubmission()
    .then(() => {
      dispatch(resetSubmission(name));
      done(null, true);
    })
    .catch((error) => {
      dispatch(failSubmission(name, error));
      done(error);
    });
};
github formio / react-formio / src / modules / auth / actions.js View on Github external
export const initAuth = () => (dispatch) => {
  const projectUrl = formiojs.getProjectUrl();

  dispatch(requestUser());

  Promise.all([
    formiojs.currentUser(),
    formiojs.makeStaticRequest(`${projectUrl}/access`)
      .then((result) => {
        const submissionAccess = transformSubmissionAccess(result.forms);
        const formAccess = transformFormAccess(result.forms);

        dispatch(submissionAccessUser(submissionAccess));
        dispatch(formAccessUser(formAccess));
        dispatch(rolesUser(result.roles));
      })
      .catch(() => {}),
    formiojs.makeStaticRequest(projectUrl)