How to use the formiojs/utils.default.eachComponent 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 / 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 / formio / src / middleware / addSubmissionResourceAccess.js View on Github external
router.formio.cache.loadForm(req, undefined, req.params.formId, function(err, form) {
      if (err || !form) {
        return next(`Cannot load form ${req.params.formId}`);
      }

      /* eslint-disable max-depth */
      util.eachComponent(form.components, (component, path) => {
        if (component && component.key && component.defaultPermission) {
          let value = _.get(req.body.data, path);
          if (value) {
            if (!(value instanceof Array)) {
              value = [value];
            }
            const ids = grabIds(value);
            if (ids.length) {
              const perm = _.find(req.body.access, {
                type: component.defaultPermission
              });
              if (perm) {
                if (!perm.resources) {
                  perm.resources = [];
                }
                perm.resources = perm.resources.concat(ids);
github formio / formio / src / actions / properties / reference.js View on Github external
router.formio.cache.loadForm(req, null, formId, function(err, form) {
          if (err) {
            return reject(err);
          }

          // Build the pipeline for the subdata.
          var queues = [];
          FormioUtils.eachComponent(form.components, (subcomp, subpath) => {
            if (subcomp.reference) {
              queues.push(buildPipeline(subcomp, `${path}.data.${subpath}`, req, res).then((subpipe) => {
                pipeline = pipeline.concat(subpipe);
              }));
            }
          });

          Promise.all(queues).then(() => resolve(pipeline)).catch((err) => reject(err));
        });
      });
github formio / formio / src / db / manual / 3.1.1.js View on Github external
getNext(formCursor, (form) => {
      if (!form) {
        hasNextForm = false;
        return nextForm();
      }
      const fields = [];
      utils.eachComponent(form.components, function(component, path) {
        // We only care about non-layout components, which are not unique, and have not been blacklisted.
        if (component.type === 'datetime') {
          fields.push(path);
        }
      }, true);

      if (!fields.length) {
        return nextForm();
      }

      const submissionCursor = submissionCollection.find({
        form: form._id,
        deleted: {$eq: null}
      });

      let hasNextSubmission = true;
github formio / ngFormio / src / components / editgrid.js View on Github external
angular.forEach(data, function(row) {
            view += '';
            formioUtils.eachComponent(options.component.components, function(component) {
              // Don't render disabled fields, or fields with undefined data.
              if (!component.tableView || !row || row[component.key] === undefined) {
                return;
              }

              // If the component has a defined tableView, use that, otherwise try and use the raw data as a string.
              var info = options.componentInfo.components.hasOwnProperty(component.type)
                ? options.componentInfo.components[component.type]
                : {};
              if (info.tableView) {
                // Reset the tableChild value for datagrids, so that components have headers.
                view += '' + info.tableView((row && row[component.key]) || '', {
                  component: component,
                  $interpolate: options.$interpolate,
                  componentInfo: options.componentInfo,
                  tableChild: false,
github formio / formio / src / db / updates / 3.1.2.js View on Github external
db.collection('forms').find({deleted: {$eq: null}}).forEach((form) => {
    utils.eachComponent(form.components, function(component, path) {
      if (component.reference) {
        submissions.find({form: form._id, deleted: {$eq: null}}).forEach((submission) => {
          const refId = _.get(submission, `data.${path}._id`);
          if (refId) {
            const update = {};
            update[`data.${path}._id`] = new ObjectID(refId);
            submissions.update({_id: submission._id}, {$set: update});
          }
        });
      }
    }, true);
  });
};
github formio / formio / src / util / swagger.js View on Github external
const getDefinition = function(components, name) {
    let definitions = {};
    definitions[name] = {
      properties: {},
      required: []
    };

    util.eachComponent(components, function(component) {
      if (component.key) {
        let property;
        switch (component.type) {
          case 'email':
          case 'textfield':
          case 'password':
          case 'phonenumber':
          case 'select':
          case 'radio':
          case 'textarea':
            property = {
              type: 'string'
            };
            break;
          case 'number':
            property = {