lib/impl/pdfGeneration/processForm.js
function(section, pageFields, submittedFields) {
  var thisSection = section;
  var fieldsInSection = sectionUtils.getFieldsInSection(section._id, pageFields);

  var renderData = [];
  var addedSectionBreaks = false;
  var idsOfFieldsInTheSection = [];

  _.each(fieldsInSection, function(field) {
    idsOfFieldsInTheSection.push(field._id);

    var thisFieldInSection = _.filter(submittedFields, function(subField) {
      return subField.fieldId._id === field._id;
    });

    if (!addedSectionBreaks) {
      _.each(thisFieldInSection, function(field, index) {
        var sectionForIndex = _.clone(thisSection);
        sectionForIndex.idx = index + 1;
        field.sectionIndex = field.sectionIndex || 0;
        renderData[field.sectionIndex] = [sectionForIndex];
      });
      addedSectionBreaks = true;
    }

    _.each(thisFieldInSection, function(field) {
      field.sectionIndex = field.sectionIndex || 0;
      renderData[field.sectionIndex].push(convertFieldToFormFormat(field));
    });
  });
  renderData = _.flatten(renderData);

  return {renderData: renderData, fieldsInSection: idsOfFieldsInTheSection};
}
function(section, pageFields, submittedFields) {
  var thisSection = section;
  var fieldsInSection = sectionUtils.getFieldsInSection(section._id, pageFields);

  var renderData = [];
  var addedSectionBreaks = false;
  var idsOfFieldsInTheSection = [];

  _.each(fieldsInSection, function(field) {
    idsOfFieldsInTheSection.push(field._id);

    var thisFieldInSection = _.filter(submittedFields, function(subField) {
      return subField.fieldId._id === field._id;
    });

    if (!addedSectionBreaks) {
      _.each(thisFieldInSection, function(field, index) {
        var sectionForIndex = _.clone(thisSection);
        sectionForIndex.idx = index + 1;
        field.sectionIndex = field.sectionIndex || 0;
        renderData[field.sectionIndex] = [sectionForIndex];
      });
      addedSectionBreaks = true;
    }

    _.each(thisFieldInSection, function(field) {
      field.sectionIndex = field.sectionIndex || 0;
      renderData[field.sectionIndex].push(convertFieldToFormFormat(field));
    });
  });
  renderData = _.flatten(renderData);

  return {renderData: renderData, fieldsInSection: idsOfFieldsInTheSection};
}
function ( section , pageFields , submittedFields ) { var thisSection = section ; var fieldsInSection = sectionUtils . getFieldsInSection ( section . _id , pageFields ) ; var renderData = [ ] ; var addedSectionBreaks = false ; var idsOfFieldsInTheSection = [ ] ; _ . each ( fieldsInSection , function ( field ) { idsOfFieldsInTheSection . push ( field . _id ) ; var thisFieldInSection = _ . filter ( submittedFields , function ( subField ) { return subField . fieldId . _id === field . _id ; } ) ; if ( ! addedSectionBreaks ) { _ . each ( thisFieldInSection , function ( field , index ) { var sectionForIndex = _ . clone ( thisSection ) ; sectionForIndex . idx = index + 1 ; field . sectionIndex = field . sectionIndex || 0 ; renderData [ field . sectionIndex ] = [ sectionForIndex ] ; } ) ; addedSectionBreaks = true ; } _ . each ( thisFieldInSection , function ( field ) { field . sectionIndex = field . sectionIndex || 0 ; renderData [ field . sectionIndex ] . push ( convertFieldToFormFormat ( field ) ) ; } ) ; } ) ; renderData = _ . flatten ( renderData ) ; return { renderData : renderData , fieldsInSection : idsOfFieldsInTheSection } ; }
Builds and returns data used to render repeating sections.
@param section
@param pageFields
@param submittedFields
@returns {{renderData: Array, fieldsInSection: Array}}
Builds and returns data used to render repeating sections .