How to use formiojs - 10 common examples

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 / formio / test / templates.js View on Github external
Object.keys(given).forEach(machineName => {
          let tempForm = given[machineName];
          // Convert all resources to point to the resource name;
          formioUtils.eachComponent(tempForm.components, (component) => {
            hook.alter('exportComponent', component);
            if (component.hasOwnProperty('resource') && project.resources && project.resources.hasOwnProperty(component.resource)) {
              component.resource = project.resources[component.resource].name;
            }
          }, true);
          given[machineName] = tempForm;
        });
github formio / angular-formio / src / resource / resource.service.ts View on Github external
init() {
    if (this.initialized) {
      return;
    }
    this.initialized = true;
    if (this.appConfig && this.appConfig.appUrl) {
      Formio.setBaseUrl(this.appConfig.apiUrl);
      Formio.setProjectUrl(this.appConfig.appUrl);
      Formio.formOnly = this.appConfig.formOnly;
    } else {
      console.error('You must provide an AppConfig within your application!');
    }

    // Create the form url and load the resources.
    this.formUrl = this.appConfig.appUrl + '/' + this.config.form;
    this.resource = { data: {} };

    // Add this resource service to the list of all resources in context.
    if (this.resourcesService) {
      this.resources = this.resourcesService.resources;
      this.resources[this.config.name] = this;
    }
github formio / angular-formio / src / resource / resource.service.ts View on Github external
init() {
    if (this.initialized) {
      return;
    }
    this.initialized = true;
    if (this.appConfig && this.appConfig.appUrl) {
      Formio.setBaseUrl(this.appConfig.apiUrl);
      Formio.setProjectUrl(this.appConfig.appUrl);
      Formio.formOnly = this.appConfig.formOnly;
    } else {
      console.error('You must provide an AppConfig within your application!');
    }

    // Create the form url and load the resources.
    this.formUrl = this.appConfig.appUrl + '/' + this.config.form;
    this.resource = { data: {} };

    // Add this resource service to the list of all resources in context.
    if (this.resourcesService) {
      this.resources = this.resourcesService.resources;
      this.resources[this.config.name] = this;
    }

    return this.loadForm();
github formio / angular-formio / dist / modules / auth / auth.service.js View on Github external
console.error('You must provide an AppConfig within your application!');
        }
        this.loginForm = this.appConfig.appUrl + '/' + this.config.login.form;
        this.registerForm = this.appConfig.appUrl + '/' + this.config.register.form;
        this.onLogin = new core_1.EventEmitter();
        this.onLogout = new core_1.EventEmitter();
        this.onRegister = new core_1.EventEmitter();
        this.onUser = new core_1.EventEmitter();
        this.onError = new core_1.EventEmitter();
        this.ready = new Promise(function (resolve, reject) {
            _this.readyResolve = resolve;
            _this.readyReject = reject;
        });
        // Register for the core events.
        Formio.events.on('formio.badToken', function () { return _this.logoutError(); });
        Formio.events.on('formio.sessionExpired', function () { return _this.logoutError(); });
        this.init();
    }
    FormioAuthService.prototype.onLoginSubmit = function (submission) {
github formio / angular-formio / dist / modules / auth / auth.service.js View on Github external
else {
            console.error('You must provide an AppConfig within your application!');
        }
        this.loginForm = this.appConfig.appUrl + '/' + this.config.login.form;
        this.registerForm = this.appConfig.appUrl + '/' + this.config.register.form;
        this.onLogin = new core_1.EventEmitter();
        this.onLogout = new core_1.EventEmitter();
        this.onRegister = new core_1.EventEmitter();
        this.onUser = new core_1.EventEmitter();
        this.onError = new core_1.EventEmitter();
        this.ready = new Promise(function (resolve, reject) {
            _this.readyResolve = resolve;
            _this.readyReject = reject;
        });
        // Register for the core events.
        Formio.events.on('formio.badToken', function () { return _this.logoutError(); });
        Formio.events.on('formio.sessionExpired', function () { return _this.logoutError(); });
        this.init();
    }
    FormioAuthService.prototype.onLoginSubmit = function (submission) {
github formio / react-formio / src / components / FormComponents / select.jsx View on Github external
}
          catch (error) {
            console.warn('Error calculating select components in ' + this.props.component.key, error);
            this.setState({
              selectItems: []
            });
          }
        };
        this.refreshItems();
        break;
      case 'resource':
      case 'url':
        if (this.props.component.dataSrc === 'url') {
          this.url = this.props.component.data.url;
          if (this.url.substr(0, 1) === '/') {
            this.url = formiojs.getBaseUrl() + this.props.component.data.url;
          }

          // Disable auth for outgoing requests.
          if (!this.props.component.authenticate && this.url.indexOf(formiojs.getBaseUrl()) === -1) {
            this.options = {
              disableJWT: true,
              headers: {
                Authorization: undefined,
                Pragma: undefined,
                'Cache-Control': undefined
              }
            };
          }
        }
        else {
          this.url = formiojs.getBaseUrl();
github formio / angular-formio / src / modules / auth / auth.service.ts View on Github external
init() {
    this.projectReady = Formio.makeStaticRequest(this.appConfig.appUrl).then((project: any) => {
      _each(project.access, (access: any) => {
        this.formAccess[access.type] = access.roles;
      });
    }, (err: any): any => {
      this.formAccess = {};
      return null;
    });


    // Get the access for this project.
    this.accessReady = Formio.makeStaticRequest(this.appConfig.appUrl + '/access').then((access: any) => {
      _each(access.forms, (form: any) => {
        this.submissionAccess[form.name] = {};
        form.submissionAccess.forEach((access: any) => {
          this.submissionAccess[form.name][access.type] = access.roles;
        });
      });
      this.roles = access.roles;
      return access;
    }, (err: any): any => {
      this.roles = {};
      return null;
    });

    this.userReady = Formio.currentUser().then((user: any) => {
      this.setUser(user);
      return user;
github formio / angular-formio / src / modules / auth / auth.service.ts View on Github external
init() {
    this.projectReady = Formio.makeStaticRequest(this.appConfig.appUrl).then((project: any) => {
      _each(project.access, (access: any) => {
        this.formAccess[access.type] = access.roles;
      });
    }, (err: any): any => {
      this.formAccess = {};
      return null;
    });


    // Get the access for this project.
    this.accessReady = Formio.makeStaticRequest(this.appConfig.appUrl + '/access').then((access: any) => {
      _each(access.forms, (form: any) => {
        this.submissionAccess[form.name] = {};
        form.submissionAccess.forEach((access: any) => {
          this.submissionAccess[form.name][access.type] = access.roles;
        });
github formio / react-formio / src / components / Formio.jsx View on Github external
return;
    }

    this.setState({
      alerts: [],
      isSubmitting: true
    });
    var sub = this.state.submission;
    sub.data = clone(this.data);

    var request;
    var method;
    // Do the submit here.
    if (this.state.form.action) {
      method = this.state.submission._id ? 'put' : 'post';
      request = Formiojs.request(this.state.form.action, method, sub);
    }
    else if (this.formio) {
      request = this.formio.saveSubmission(sub);
    }
    if (request) {
      request.then(function (submission) {
          if (typeof this.props.onFormSubmit === 'function') {
            this.props.onFormSubmit(submission);
          }
          this.setState({
            isSubmitting: false,
            alerts: [{
              type: 'success',
              message: 'Submission was ' + ((method === 'put') ? 'updated' : 'created')
            }]
          });
github formio / angular-formio / src / auth / auth.service.ts View on Github external
init() {
    this.projectReady = Formio.makeStaticRequest(this.appConfig.appUrl).then(
      (project: any) => {
        each(project.access, (access: any) => {
          this.formAccess[access.type] = access.roles;
        });
      },
      (): any => {
        this.formAccess = {};
        return null;
      }
    );

    // Get the access for this project.
    this.accessReady = Formio.makeStaticRequest(
      this.appConfig.appUrl + '/access'
    ).then(
      (access: any) => {
        each(access.forms, (form: any) => {
          this.submissionAccess[form.name] = {};
          form.submissionAccess.forEach((subAccess: any) => {
            this.submissionAccess[form.name][subAccess.type] = subAccess.roles;
          });
        });
        this.roles = access.roles;
        return access;
      },
      (): any => {
        this.roles = {};
        return null;
      }