src/common/mapper.js
function mappingToTable(mapping) {
  const mp = mapping.hasOwnProperty('field') ? singleToMulti(mapping) : mapping;
  const keyField = {key: mp.key, format: 'text'};
  const data = {
    fields: [keyField].concat(mp.fields),
    records: Object.entries(mp.mapping).map(entry => {
      const rcd = {};
      rcd[mp.key] = entry[0];
      mp.fields.forEach((f, i) => {
        rcd[f.key] = entry[1][i];
      });
      return rcd;
    })
  };
  return data;
}
function mappingToTable(mapping) {
  const mp = mapping.hasOwnProperty('field') ? singleToMulti(mapping) : mapping;
  const keyField = {key: mp.key, format: 'text'};
  const data = {
    fields: [keyField].concat(mp.fields),
    records: Object.entries(mp.mapping).map(entry => {
      const rcd = {};
      rcd[mp.key] = entry[0];
      mp.fields.forEach((f, i) => {
        rcd[f.key] = entry[1][i];
      });
      return rcd;
    })
  };
  return data;
}
function mappingToTable ( mapping ) { const mp = mapping . hasOwnProperty ( 'field' ) ? singleToMulti ( mapping ) : mapping ; const keyField = { key : mp . key , format : 'text' } ; const data = { fields : [ keyField ] . concat ( mp . fields ) , records : Object . entries ( mp . mapping ) . map ( entry => { const rcd = { } ; rcd [ mp . key ] = entry [ 0 ] ; mp . fields . forEach ( ( f , i ) => { rcd [ f . key ] = entry [ 1 ] [ i ] ; } ) ; return rcd ; } ) } ; return data ; }
Convert field mapping to table
@param {object} mapping - field mapping
@return {object} table object
Convert field mapping to table