@builttocreate/engine-utils 1.8.1-rc.1.2.7 → 1.8.1-rc.1.2.9
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.
- package/dist/activityHelper.js +10 -4
- package/dist/fieldHelper.js +3 -3
- package/dist/tableHelper.js +50 -14
- package/package.json +1 -1
package/dist/activityHelper.js
CHANGED
|
@@ -84,7 +84,8 @@ var addDocumentDataToActivities = function addDocumentDataToActivities(activitie
|
|
|
84
84
|
template.fields.forEach(function (field) {
|
|
85
85
|
return templateFieldLookup[field._id] = field;
|
|
86
86
|
});
|
|
87
|
-
} //
|
|
87
|
+
} //I don't think this line is needed. Consult Scooby
|
|
88
|
+
// const fieldLookup = template && template.fieldLookup ? template.fieldLookup : null;
|
|
88
89
|
|
|
89
90
|
|
|
90
91
|
var fieldValues = doc && doc.fields ? doc.fields : null;
|
|
@@ -110,13 +111,18 @@ var addDocumentDataToActivities = function addDocumentDataToActivities(activitie
|
|
|
110
111
|
* We only need to generate the row lookup once per field to help increase performance,
|
|
111
112
|
* just incase we have other deficiencies that reference the same table field.
|
|
112
113
|
*/
|
|
113
|
-
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Removing deleted rows from doc field value
|
|
117
|
+
* Added as a fix for table bug that did not display proper output for formula cells
|
|
118
|
+
* as rowIndex was messy
|
|
119
|
+
*/
|
|
114
120
|
var nextDocFieldValue = docFieldValue.filter(function (item) {
|
|
115
121
|
return !item.deleted;
|
|
116
122
|
});
|
|
117
123
|
|
|
118
124
|
if (!fieldRowsLookup[templateField._id]) {
|
|
119
|
-
fieldRowsLookup[templateField._id] = (0, _tableHelper.
|
|
125
|
+
fieldRowsLookup[templateField._id] = (0, _tableHelper.getTableRowLookupWithPopulatedDropdownCells)(templateField.tableColumns, nextDocFieldValue);
|
|
120
126
|
}
|
|
121
127
|
/**
|
|
122
128
|
* Table Step 2: create an easy way to lookup a row index so we can use it in our row
|
|
@@ -147,7 +153,7 @@ var addDocumentDataToActivities = function addDocumentDataToActivities(activitie
|
|
|
147
153
|
* We only need to generate the row lookup once per field (since input groups are just rows)
|
|
148
154
|
* to help increase performance, just incase we have other deficiencies that reference the same table field.
|
|
149
155
|
*/
|
|
150
|
-
if (!fieldRowsLookup[templateField._id]) fieldRowsLookup[templateField._id] = (0, _tableHelper.
|
|
156
|
+
if (!fieldRowsLookup[templateField._id]) fieldRowsLookup[templateField._id] = (0, _tableHelper.getInputGroupRowLookupWithPopulatedDropdownCells)(templateField.tableColumns, docFieldValue);
|
|
151
157
|
/**
|
|
152
158
|
* Input Group Step 2: Add invidual row.cell value. We only add the invidual cell value and not the
|
|
153
159
|
* whole row because input group display components are treated like regular field and not like table rows.
|
package/dist/fieldHelper.js
CHANGED
|
@@ -202,7 +202,7 @@ var getTemplateWithLookups = function getTemplateWithLookups(template) {
|
|
|
202
202
|
|
|
203
203
|
if (nextField.tableColumns) {
|
|
204
204
|
nextField.tableColumnsLookup = {};
|
|
205
|
-
nextField.tableColumns.forEach(function (column) {
|
|
205
|
+
nextField.tableColumns.forEach(function (column, index) {
|
|
206
206
|
var nextColumn = _objectSpread(_objectSpread({}, column), {}, {
|
|
207
207
|
optionsLookup: {}
|
|
208
208
|
});
|
|
@@ -227,10 +227,10 @@ var getTemplateWithLookups = function getTemplateWithLookups(template) {
|
|
|
227
227
|
nextRow.cells[column._id] = column.optionsLookup[optionId] ? column.optionsLookup[optionId].value : optionId;
|
|
228
228
|
}
|
|
229
229
|
*/
|
|
230
|
+
// column.optionsLookup = nextColumn.optionsLookup;
|
|
230
231
|
|
|
231
232
|
|
|
232
|
-
|
|
233
|
-
nextField.tableColumnsLookup[nextColumn._id] = nextColumn;
|
|
233
|
+
nextField.tableColumns[index] = nextColumn; // nextField.tableColumnsLookup[nextColumn._id] = nextColumn;
|
|
234
234
|
});
|
|
235
235
|
}
|
|
236
236
|
|
package/dist/tableHelper.js
CHANGED
|
@@ -7,7 +7,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
10
|
-
exports["default"] = exports.handleMoveTableRowDown = exports.handleMoveTableRowUp = exports.handleDuplicateTableRow = exports.handleCreateTableRow = exports.handleInsertTableRow = exports.handleTableCellChange = exports.getRowIndexLookup = exports.
|
|
10
|
+
exports["default"] = exports.handleMoveTableRowDown = exports.handleMoveTableRowUp = exports.handleDuplicateTableRow = exports.handleCreateTableRow = exports.handleInsertTableRow = exports.handleTableCellChange = exports.getRowIndexLookup = exports.getInputGroupRowLookupWithPopulatedDropdownCells = exports.getTableRowLookupWithPopulatedDropdownCells = exports.generateInputGroupFields = exports.spreadOperandRange = exports.validFormulaString = exports.hasOperandRange = exports.hasCircularOperandReference = exports.resolveOperandValue = exports.getFormulaResult = exports.generateTableLookup = exports.generateTableLookupForRows = exports.generateTableFieldLookups = exports.generateRowTableLookup = exports.getCellOperand = exports.getTemplateColumnOperandLookup = exports.getIndexesFromTableCellOperand = exports.getColumnOperand = exports.getColumns = exports.getTableFieldRowOrder = exports.getRowMap = exports.getFilteredRowOrder = exports.sortRows = exports.getRows = exports.getDefaultRow = exports.getTableFieldLookupKey = void 0;
|
|
11
11
|
|
|
12
12
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
13
|
|
|
@@ -713,25 +713,29 @@ var generateInputGroupFields = function generateInputGroupFields(field, columns)
|
|
|
713
713
|
return tableReferences;
|
|
714
714
|
};
|
|
715
715
|
/**
|
|
716
|
-
* Populate
|
|
717
|
-
*
|
|
716
|
+
* Populate table rows with values
|
|
717
|
+
* - Dropdown cells will have chosen values
|
|
718
|
+
* - Formula cells will have the formula result
|
|
719
|
+
*
|
|
720
|
+
* Note: Columns should already have the options lookup populated before
|
|
721
|
+
* being sent into this function
|
|
722
|
+
*
|
|
723
|
+
* @param {*} columns -
|
|
718
724
|
* @param {*} rows
|
|
719
725
|
* @returns
|
|
720
726
|
*/
|
|
721
|
-
//Columns should have the options lookup already populated
|
|
722
727
|
|
|
723
728
|
|
|
724
729
|
exports.generateInputGroupFields = generateInputGroupFields;
|
|
725
730
|
|
|
726
|
-
var
|
|
731
|
+
var getTableRowLookupWithPopulatedDropdownCells = function getTableRowLookupWithPopulatedDropdownCells(columns, rows) {
|
|
727
732
|
var rowsLookup = {};
|
|
728
733
|
var tableLookup = generateTableLookup(rows, columns);
|
|
729
|
-
var validRows = typeof row === 'string' ? JSON.parse(rows) : rows;
|
|
734
|
+
var validRows = typeof row === 'string' ? JSON.parse(rows) : rows; //Removing deleted columns so column operand doesn't look messy
|
|
735
|
+
|
|
730
736
|
var validColumns = columns.filter(function (column) {
|
|
731
737
|
return !column.deleted;
|
|
732
738
|
});
|
|
733
|
-
console.log('validRows', validRows);
|
|
734
|
-
console.log('validColumns', validColumns);
|
|
735
739
|
validRows.forEach(function (row, rowIndex) {
|
|
736
740
|
var nextRow = _objectSpread(_objectSpread({}, row), {}, {
|
|
737
741
|
cells: _objectSpread({}, row.cells)
|
|
@@ -743,10 +747,6 @@ var getRowLookupWithPopulatedDropdownCells = function getRowLookupWithPopulatedD
|
|
|
743
747
|
if (optionId && optionId.charAt(0) === '=' && column.type === _FieldTableColumnTypes["default"].text) {
|
|
744
748
|
var columnOperand = getColumnOperand(i);
|
|
745
749
|
var cellOperand = getCellOperand(columnOperand, rowIndex + 1);
|
|
746
|
-
console.log('columnOperand', columnOperand, i);
|
|
747
|
-
console.log('cellOperand', cellOperand);
|
|
748
|
-
console.log('endResult', tableLookup, tableLookup[cellOperand]);
|
|
749
|
-
console.log('*****************************************************');
|
|
750
750
|
nextRow.cells[column._id] = tableLookup[cellOperand];
|
|
751
751
|
} else if (optionId && column.type === _FieldTableColumnTypes["default"].dropdown) {
|
|
752
752
|
nextRow.cells[column._id] = column.optionsLookup[optionId] ? column.optionsLookup[optionId].value : optionId;
|
|
@@ -754,6 +754,41 @@ var getRowLookupWithPopulatedDropdownCells = function getRowLookupWithPopulatedD
|
|
|
754
754
|
});
|
|
755
755
|
rowsLookup[nextRow._id] = nextRow;
|
|
756
756
|
});
|
|
757
|
+
console.log('table field rowsLookup', rowsLookup);
|
|
758
|
+
return rowsLookup;
|
|
759
|
+
};
|
|
760
|
+
/**
|
|
761
|
+
* Populate inputGroup dropdown questions with chosen value
|
|
762
|
+
*
|
|
763
|
+
* Note: Columns should already have the options lookup populated before
|
|
764
|
+
* being sent into this function
|
|
765
|
+
*
|
|
766
|
+
* @param {*} columns
|
|
767
|
+
* @param {*} rows
|
|
768
|
+
* @returns
|
|
769
|
+
*/
|
|
770
|
+
|
|
771
|
+
|
|
772
|
+
exports.getTableRowLookupWithPopulatedDropdownCells = getTableRowLookupWithPopulatedDropdownCells;
|
|
773
|
+
|
|
774
|
+
var getInputGroupRowLookupWithPopulatedDropdownCells = function getInputGroupRowLookupWithPopulatedDropdownCells(columns, rows) {
|
|
775
|
+
var rowsLookup = {};
|
|
776
|
+
var validRows = typeof row === 'string' ? JSON.parse(rows) : rows;
|
|
777
|
+
validRows.forEach(function (row) {
|
|
778
|
+
var nextRow = _objectSpread(_objectSpread({}, row), {}, {
|
|
779
|
+
cells: _objectSpread({}, row.cells)
|
|
780
|
+
});
|
|
781
|
+
|
|
782
|
+
columns.forEach(function (column, i) {
|
|
783
|
+
var optionId = nextRow.cells[column._id];
|
|
784
|
+
|
|
785
|
+
if (optionId && column.type === _FieldTableColumnTypes["default"].dropdown) {
|
|
786
|
+
nextRow.cells[column._id] = column.optionsLookup[optionId] ? column.optionsLookup[optionId].value : optionId;
|
|
787
|
+
}
|
|
788
|
+
});
|
|
789
|
+
rowsLookup[nextRow._id] = nextRow;
|
|
790
|
+
});
|
|
791
|
+
console.log('input group rows lookup', rowsLookup);
|
|
757
792
|
return rowsLookup;
|
|
758
793
|
};
|
|
759
794
|
/**
|
|
@@ -765,7 +800,7 @@ var getRowLookupWithPopulatedDropdownCells = function getRowLookupWithPopulatedD
|
|
|
765
800
|
*/
|
|
766
801
|
|
|
767
802
|
|
|
768
|
-
exports.
|
|
803
|
+
exports.getInputGroupRowLookupWithPopulatedDropdownCells = getInputGroupRowLookupWithPopulatedDropdownCells;
|
|
769
804
|
|
|
770
805
|
var getRowIndexLookup = function getRowIndexLookup(fieldId, fieldSettings, rows) {
|
|
771
806
|
var rowOrder = getTableFieldRowOrder(fieldId, fieldSettings, rows);
|
|
@@ -921,7 +956,8 @@ var _default = {
|
|
|
921
956
|
spreadOperandRange: spreadOperandRange,
|
|
922
957
|
getTableFieldLookupKey: getTableFieldLookupKey,
|
|
923
958
|
getTableFieldRowOrder: getTableFieldRowOrder,
|
|
924
|
-
|
|
959
|
+
getTableRowLookupWithPopulatedDropdownCells: getTableRowLookupWithPopulatedDropdownCells,
|
|
960
|
+
getInputGroupRowLookupWithPopulatedDropdownCells: getInputGroupRowLookupWithPopulatedDropdownCells,
|
|
925
961
|
getRowIndexLookup: getRowIndexLookup,
|
|
926
962
|
handleTableCellChange: handleTableCellChange,
|
|
927
963
|
handleInsertTableRow: handleInsertTableRow,
|