loadSheet_()

in marketing-analytics/activation/sheets-based-installer/src/apps_script/2_base/mojo.js [567:616]


  loadSheet_() {
    const mojoSheetRows = this.enhancedSheet.loadArrayOfEntity(
      { fields: MOJO_FIELDS }
    );
    const result = [];
    let category;
    let index = 0;
    do {
      const line = mojoSheetRows[index];
      if (line.category && line.category !== category) {
        category = line.category;
      } else {
        line.category = category;
      }
      const values = [];
      result.push(values);
      do {
        const mojoSheetRow = Object.assign(
          { rowIndex: index + ROW_INDEX_SHIFT }, mojoSheetRows[index]);
        this.loadProperty_(mojoSheetRows[index]);
        index++;
        // Push mulitple attributes of the same 'value' into an array
        while (index < mojoSheetRows.length
          && mojoSheetRows[index].resource === ''
          && mojoSheetRows[index].value === '') {
          if (!mojoSheetRow.attributes) {
            mojoSheetRow.attributes = [{
              attributeName: mojoSheetRow.attributeName,
              attributeValue: mojoSheetRow.attributeValue,
            }];
          }
          mojoSheetRow.attributes.push({
            attributeName: mojoSheetRows[index].attributeName,
            attributeValue: mojoSheetRows[index].attributeValue,
          });
          index++;
        }
        if (mojoSheetRow.attributes) {
          mojoSheetRow.attributesMap = {};
          mojoSheetRow.attributes.forEach((attribute) => {
            mojoSheetRow.attributesMap[attribute.attributeName] = attribute;
          })
        }
        values.push(mojoSheetRow);
      } while (index < mojoSheetRows.length && mojoSheetRows[index].resource === '')
    } while (index < mojoSheetRows.length)
    console.log('Properties in Sheet',
      PropertiesService.getDocumentProperties().getProperties());
    return result;
  }