@builttocreate/engine-utils 1.8.1-rc.1.2.8 → 1.8.1-rc.1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -116,9 +116,9 @@ var addDocumentDataToActivities = function addDocumentDataToActivities(activitie
116
116
  * Added as a fix for table bug that did not display proper output for formula cells
117
117
  * as rowIndex was messy
118
118
  */
119
- var nextDocFieldValue = docFieldValue.filter(function (item) {
120
- return !item.deleted;
121
- });
119
+ console.log('tableDoc field value', docFieldValue);
120
+ var nextDocFieldValue = (0, _tableHelper.getRows)(docFieldValue);
121
+ console.log('nextDocFiedlValues', nextDocFieldValue);
122
122
 
123
123
  if (!fieldRowsLookup[templateField._id]) {
124
124
  fieldRowsLookup[templateField._id] = (0, _tableHelper.getTableRowLookupWithPopulatedDropdownCells)(templateField.tableColumns, nextDocFieldValue);
@@ -168,10 +168,9 @@ var addDocumentDataToActivities = function addDocumentDataToActivities(activitie
168
168
  var option = templateField.optionsLookup[item];
169
169
  _nextDocFieldValue = _nextDocFieldValue.concat(' ', option.value);
170
170
  });
171
- nextActivity.document.value = _nextDocFieldValue;
172
- } else {
173
- nextActivity.document.value = 'No Option Selected';
174
171
  }
172
+
173
+ nextActivity.document.value = _nextDocFieldValue;
175
174
  } //This should handle adding the display value for selection and regular input fields
176
175
  else {
177
176
  var option = templateField.optionsLookup[docFieldValue];
@@ -182,6 +182,28 @@ var getImportFieldValues = function getImportFieldValues(template, importSource,
182
182
  * @param {} template
183
183
  * @returns
184
184
  */
185
+ // export const getTemplateWithLookups = (template) => {
186
+ // const nextTemplate = { ...template };
187
+ // nextTemplate.fields = template.fields.map((field) => {
188
+ // const nextField = { ...field };
189
+ // nextField.optionsLookup = {};
190
+ // if (nextField.options) {
191
+ // nextField.options.forEach((option) => nextField.optionsLookup[option._id] = option);
192
+ // }
193
+ // if (nextField.tableColumns) {
194
+ // nextField.tableColumnsLookup = {};
195
+ // nextField.tableColumns.forEach((column, index) => {
196
+ // const nextColumn = { ...column, optionsLookup: {} }
197
+ // if (nextColumn.options) {
198
+ // nextColumn.options.forEach((option) => nextColumn.optionsLookup[option._id] = option);
199
+ // }
200
+ // nextField.tableColumns[index] = nextColumn
201
+ // });
202
+ // }
203
+ // return nextField;
204
+ // });
205
+ // return nextTemplate;
206
+ // }
185
207
 
186
208
 
187
209
  exports.getImportFieldValues = getImportFieldValues;
@@ -189,7 +211,9 @@ exports.getImportFieldValues = getImportFieldValues;
189
211
  var getTemplateWithLookups = function getTemplateWithLookups(template) {
190
212
  var nextTemplate = _objectSpread({}, template);
191
213
 
192
- nextTemplate.fields = template.fields.map(function (field) {
214
+ nextTemplate.fields = [];
215
+ nextTemplate.fieldLookup = {};
216
+ template.fields.forEach(function (field) {
193
217
  var nextField = _objectSpread({}, field);
194
218
 
195
219
  nextField.optionsLookup = {};
@@ -212,30 +236,15 @@ var getTemplateWithLookups = function getTemplateWithLookups(template) {
212
236
  return nextColumn.optionsLookup[option._id] = option;
213
237
  });
214
238
  }
215
- /** -------------Remove this comment before merge-------------------------------
216
- * What do we do here
217
- * We are adding optionsLookup to the template.tableColumns to fetch the dropdown cell values inside
218
- * getRowlookupWithPopulatedDropdownCells
219
- *
220
- * Why can't we use the tableColumnsLookup object that gets added to the template?
221
- * We can use it but i will have map through table columns and add the optionsLookup
222
- * to them within activity helper. Without options lookup we will not be able to fetch
223
- * dropdown cell values
224
- *
225
- * * TableHelper logic to fetch values of drodpown cells
226
- if (optionId && column.type === FieldTableColumnTypes.dropdown) {
227
- nextRow.cells[column._id] = column.optionsLookup[optionId] ? column.optionsLookup[optionId].value : optionId;
228
- }
229
- */
230
- // column.optionsLookup = nextColumn.optionsLookup;
231
-
232
-
233
- nextField.tableColumns[index] = nextColumn; // nextField.tableColumnsLookup[nextColumn._id] = nextColumn;
239
+
240
+ nextField.tableColumns[index] = nextColumn;
234
241
  });
235
242
  }
236
243
 
237
- return nextField;
244
+ nextTemplate.fields.push(nextField);
245
+ nextTemplate.fieldLookup[nextField._id] = nextField;
238
246
  });
247
+ console.log('nextTemplate', nextTemplate);
239
248
  return nextTemplate;
240
249
  };
241
250
 
@@ -731,7 +731,7 @@ exports.generateInputGroupFields = generateInputGroupFields;
731
731
  var getTableRowLookupWithPopulatedDropdownCells = function getTableRowLookupWithPopulatedDropdownCells(columns, rows) {
732
732
  var rowsLookup = {};
733
733
  var tableLookup = generateTableLookup(rows, columns);
734
- var validRows = typeof row === 'string' ? JSON.parse(rows) : rows; //Removing deleted columns so column operand doesn't look messy
734
+ var validRows = getRows(rows); //Removing deleted columns so column operand doesn't look messy
735
735
 
736
736
  var validColumns = columns.filter(function (column) {
737
737
  return !column.deleted;
@@ -742,19 +742,34 @@ var getTableRowLookupWithPopulatedDropdownCells = function getTableRowLookupWith
742
742
  });
743
743
 
744
744
  validColumns.forEach(function (column, i) {
745
- var optionId = nextRow.cells[column._id];
745
+ var columnOperand = getColumnOperand(i);
746
+ var cellOperand = getCellOperand(columnOperand, rowIndex + 1);
747
+ var value = tableLookup[cellOperand];
746
748
 
747
- if (optionId && optionId.charAt(0) === '=' && column.type === _FieldTableColumnTypes["default"].text) {
748
- var columnOperand = getColumnOperand(i);
749
- var cellOperand = getCellOperand(columnOperand, rowIndex + 1);
750
- nextRow.cells[column._id] = tableLookup[cellOperand];
751
- } else if (optionId && column.type === _FieldTableColumnTypes["default"].dropdown) {
752
- nextRow.cells[column._id] = column.optionsLookup[optionId] ? column.optionsLookup[optionId].value : optionId;
749
+ if (value && column.type === _FieldTableColumnTypes["default"].dropdown) {
750
+ nextRow.cells[column._id] = column.optionsLookup[value] ? column.optionsLookup[value].value : value;
751
+ } else {
752
+ nextRow.cells[column._id] = value;
753
753
  }
754
754
  });
755
755
  rowsLookup[nextRow._id] = nextRow;
756
- });
757
- console.log('table field rowsLookup', rowsLookup);
756
+ }); // validRows.forEach((row, rowIndex) => {
757
+ // const nextRow = {...row, cells: {...row.cells}};
758
+ // const validColumns = columns.filter((column) => !column.deleted);
759
+ // validColumns.forEach((column, i) => {
760
+ // const optionId = nextRow.cells[column._id];
761
+ // if(optionId && optionId.charAt(0) === '=' && column.type === FieldTableColumnTypes.text){
762
+ // const columnOperand = getColumnOperand(i);
763
+ // const cellOperand = getCellOperand(columnOperand,rowIndex+1 );
764
+ // nextRow.cells[column._id] = tableLookup[cellOperand];
765
+ // }
766
+ // else if (optionId && column.type === FieldTableColumnTypes.dropdown) {
767
+ // nextRow.cells[column._id] = column.optionsLookup[optionId] ? column.optionsLookup[optionId].value : optionId;
768
+ // }
769
+ // });
770
+ // rowsLookup[nextRow._id] = nextRow;
771
+ // });
772
+
758
773
  return rowsLookup;
759
774
  };
760
775
  /**
@@ -788,7 +803,6 @@ var getInputGroupRowLookupWithPopulatedDropdownCells = function getInputGroupRow
788
803
  });
789
804
  rowsLookup[nextRow._id] = nextRow;
790
805
  });
791
- console.log('input group rows lookup', rowsLookup);
792
806
  return rowsLookup;
793
807
  };
794
808
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builttocreate/engine-utils",
3
- "version": "1.8.1-rc.1.2.8",
3
+ "version": "1.8.1-rc.1.3.0",
4
4
  "description": "Utility library for common logic shared across web and mobile",
5
5
  "main": "dist/index.js",
6
6
  "files": [