@builttocreate/engine-utils 1.8.1-rc.1.3.1 → 1.8.1-rc.1.3.3
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 +6 -11
- package/dist/fieldHelper.js +6 -27
- package/dist/tableHelper.js +16 -38
- package/package.json +1 -1
package/dist/activityHelper.js
CHANGED
|
@@ -84,9 +84,7 @@ var addDocumentDataToActivities = function addDocumentDataToActivities(activitie
|
|
|
84
84
|
template.fields.forEach(function (field) {
|
|
85
85
|
return templateFieldLookup[field._id] = field;
|
|
86
86
|
});
|
|
87
|
-
}
|
|
88
|
-
// const fieldLookup = template && template.fieldLookup ? template.fieldLookup : null;
|
|
89
|
-
|
|
87
|
+
}
|
|
90
88
|
|
|
91
89
|
var fieldValues = doc && doc.fields ? doc.fields : null;
|
|
92
90
|
if (!activities || activities.length < 1 || !templateFieldLookup || !fieldValues) return activities;
|
|
@@ -116,16 +114,14 @@ var addDocumentDataToActivities = function addDocumentDataToActivities(activitie
|
|
|
116
114
|
* Added as a fix for table bug that did not display proper output for formula cells
|
|
117
115
|
* as rowIndex was messy
|
|
118
116
|
*/
|
|
119
|
-
console.log('tableDoc field value', docFieldValue);
|
|
120
117
|
var nextDocFieldValue = (0, _tableHelper.getRows)(docFieldValue);
|
|
121
|
-
console.log('nextDocFiedlValues', nextDocFieldValue);
|
|
122
118
|
|
|
123
119
|
if (!fieldRowsLookup[templateField._id]) {
|
|
124
120
|
fieldRowsLookup[templateField._id] = (0, _tableHelper.getTableRowLookupWithPopulatedDropdownCells)(templateField.tableColumns, nextDocFieldValue);
|
|
125
121
|
}
|
|
126
122
|
/**
|
|
127
|
-
* Table Step 2: create an easy way to lookup a row index so we can use it in our row
|
|
128
|
-
* display component.
|
|
123
|
+
* Table Step 2: create an easy way to lookup a row index so we can use it in our row
|
|
124
|
+
* display component.
|
|
129
125
|
*
|
|
130
126
|
* We only need to generate the row index lookup once per field to help increase performance,
|
|
131
127
|
* just incase we have other deficiencies that reference the same table field.
|
|
@@ -135,26 +131,25 @@ var addDocumentDataToActivities = function addDocumentDataToActivities(activitie
|
|
|
135
131
|
if (!fieldRowIndexLookup[templateField._id]) {
|
|
136
132
|
fieldRowIndexLookup[templateField._id] = (0, _tableHelper.getRowIndexLookup)(templateField._id, template.fieldSettings, docFieldValue);
|
|
137
133
|
}
|
|
138
|
-
|
|
139
|
-
;
|
|
140
134
|
/**
|
|
141
135
|
* Table Step 3: Add row and rowIndex to the activity.document object for easy reference.
|
|
142
136
|
*
|
|
143
137
|
* nextActivity.document.value will now contain the single row object with all cell values populated ready to be displayed
|
|
144
138
|
*/
|
|
145
139
|
|
|
140
|
+
|
|
146
141
|
nextActivity.document.value = fieldRowsLookup[activity.document.field][activity.document.row];
|
|
147
142
|
nextActivity.document.rowIndex = fieldRowIndexLookup[activity.document.field][activity.document.row];
|
|
148
143
|
} else if (docFieldValue && templateField.type === _FieldTypes["default"].inputGroup) {
|
|
149
144
|
/**
|
|
150
145
|
* Input Group Step 1: create an easy way to lookup a row with the dropdown cells populated.
|
|
151
146
|
*
|
|
152
|
-
* We only need to generate the row lookup once per field (since input groups are just rows)
|
|
147
|
+
* We only need to generate the row lookup once per field (since input groups are just rows)
|
|
153
148
|
* to help increase performance, just incase we have other deficiencies that reference the same table field.
|
|
154
149
|
*/
|
|
155
150
|
if (!fieldRowsLookup[templateField._id]) fieldRowsLookup[templateField._id] = (0, _tableHelper.getInputGroupRowLookupWithPopulatedDropdownCells)(templateField.tableColumns, docFieldValue);
|
|
156
151
|
/**
|
|
157
|
-
* Input Group Step 2: Add invidual row.cell value. We only add the invidual cell value and not the
|
|
152
|
+
* Input Group Step 2: Add invidual row.cell value. We only add the invidual cell value and not the
|
|
158
153
|
* whole row because input group display components are treated like regular field and not like table rows.
|
|
159
154
|
*/
|
|
160
155
|
|
package/dist/fieldHelper.js
CHANGED
|
@@ -108,7 +108,7 @@ var getDefaultFieldValuesFromTemplate = function getDefaultFieldValuesFromTempla
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
if (field.type === _FieldTypes["default"].date) {
|
|
111
|
-
fields[field._id] = field.value || new Date().getTime();
|
|
111
|
+
fields[field._id] = field.blockAutoPopulate ? '' : field.value || new Date().getTime();
|
|
112
112
|
}
|
|
113
113
|
});
|
|
114
114
|
return fields;
|
|
@@ -178,32 +178,12 @@ var getImportFieldValues = function getImportFieldValues(template, importSource,
|
|
|
178
178
|
return fields;
|
|
179
179
|
};
|
|
180
180
|
/**
|
|
181
|
-
* Generate
|
|
182
|
-
*
|
|
183
|
-
*
|
|
181
|
+
* Generate optionsLookup and fieldLookup for template fields
|
|
182
|
+
* Note: Options lookup will be used by dropdown, mutliSelect, table and inputGroup fields
|
|
183
|
+
* to display value in dropdowns
|
|
184
|
+
* @param {} template
|
|
185
|
+
* @returns template
|
|
184
186
|
*/
|
|
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
|
-
// }
|
|
207
187
|
|
|
208
188
|
|
|
209
189
|
exports.getImportFieldValues = getImportFieldValues;
|
|
@@ -244,7 +224,6 @@ var getTemplateWithLookups = function getTemplateWithLookups(template) {
|
|
|
244
224
|
nextTemplate.fields.push(nextField);
|
|
245
225
|
nextTemplate.fieldLookup[nextField._id] = nextField;
|
|
246
226
|
});
|
|
247
|
-
console.log('nextTemplate', nextTemplate);
|
|
248
227
|
return nextTemplate;
|
|
249
228
|
};
|
|
250
229
|
|
package/dist/tableHelper.js
CHANGED
|
@@ -716,13 +716,13 @@ var generateInputGroupFields = function generateInputGroupFields(field, columns)
|
|
|
716
716
|
* Populate table rows with values
|
|
717
717
|
* - Dropdown cells will have chosen values
|
|
718
718
|
* - Formula cells will have the formula result
|
|
719
|
-
*
|
|
719
|
+
*
|
|
720
720
|
* Note: Columns should already have the options lookup populated before
|
|
721
721
|
* being sent into this function
|
|
722
|
-
*
|
|
722
|
+
*
|
|
723
723
|
* @param {*} columns -
|
|
724
|
-
* @param {*} rows
|
|
725
|
-
* @returns
|
|
724
|
+
* @param {*} rows
|
|
725
|
+
* @returns
|
|
726
726
|
*/
|
|
727
727
|
|
|
728
728
|
|
|
@@ -733,20 +733,14 @@ var getTableRowLookupWithPopulatedDropdownCells = function getTableRowLookupWith
|
|
|
733
733
|
var tableLookup = generateTableLookup(rows, columns);
|
|
734
734
|
var validRows = getRows(rows);
|
|
735
735
|
var validColumns = getColumns(columns);
|
|
736
|
-
console.log('---------------------------------------------------------');
|
|
737
|
-
console.log('rows, columns', rows, columns);
|
|
738
|
-
console.log('valid rows , columns', validRows, validColumns);
|
|
739
736
|
validRows.forEach(function (row, rowIndex) {
|
|
740
737
|
var nextRow = _objectSpread(_objectSpread({}, row), {}, {
|
|
741
738
|
cells: _objectSpread({}, row.cells)
|
|
742
739
|
});
|
|
743
740
|
|
|
744
|
-
validColumns.forEach(function (column
|
|
741
|
+
validColumns.forEach(function (column) {
|
|
745
742
|
var cellOperand = getCellOperand(column.operand, rowIndex + 1);
|
|
746
|
-
console.log('column, rowIndex, cellOpearand', column, rowIndex, cellOperand);
|
|
747
743
|
var value = tableLookup[cellOperand];
|
|
748
|
-
console.log('tableLookup, tableLookup[cellOpearnad]', tableLookup, tableLookup[cellOperand]);
|
|
749
|
-
console.log('***************************************************************************************');
|
|
750
744
|
|
|
751
745
|
if (value && column.type === _FieldTableColumnTypes["default"].dropdown) {
|
|
752
746
|
nextRow.cells[column._id] = column.optionsLookup[value] ? column.optionsLookup[value].value : value;
|
|
@@ -755,34 +749,18 @@ var getTableRowLookupWithPopulatedDropdownCells = function getTableRowLookupWith
|
|
|
755
749
|
}
|
|
756
750
|
});
|
|
757
751
|
rowsLookup[nextRow._id] = nextRow;
|
|
758
|
-
});
|
|
759
|
-
// const nextRow = {...row, cells: {...row.cells}};
|
|
760
|
-
// const validColumns = columns.filter((column) => !column.deleted);
|
|
761
|
-
// validColumns.forEach((column, i) => {
|
|
762
|
-
// const optionId = nextRow.cells[column._id];
|
|
763
|
-
// if(optionId && optionId.charAt(0) === '=' && column.type === FieldTableColumnTypes.text){
|
|
764
|
-
// const columnOperand = getColumnOperand(i);
|
|
765
|
-
// const cellOperand = getCellOperand(columnOperand,rowIndex+1 );
|
|
766
|
-
// nextRow.cells[column._id] = tableLookup[cellOperand];
|
|
767
|
-
// }
|
|
768
|
-
// else if (optionId && column.type === FieldTableColumnTypes.dropdown) {
|
|
769
|
-
// nextRow.cells[column._id] = column.optionsLookup[optionId] ? column.optionsLookup[optionId].value : optionId;
|
|
770
|
-
// }
|
|
771
|
-
// });
|
|
772
|
-
// rowsLookup[nextRow._id] = nextRow;
|
|
773
|
-
// });
|
|
774
|
-
|
|
752
|
+
});
|
|
775
753
|
return rowsLookup;
|
|
776
754
|
};
|
|
777
755
|
/**
|
|
778
756
|
* Populate inputGroup dropdown questions with chosen value
|
|
779
|
-
*
|
|
757
|
+
*
|
|
780
758
|
* Note: Columns should already have the options lookup populated before
|
|
781
759
|
* being sent into this function
|
|
782
|
-
*
|
|
783
|
-
* @param {*} columns
|
|
784
|
-
* @param {*} rows
|
|
785
|
-
* @returns
|
|
760
|
+
*
|
|
761
|
+
* @param {*} columns
|
|
762
|
+
* @param {*} rows
|
|
763
|
+
* @returns
|
|
786
764
|
*/
|
|
787
765
|
|
|
788
766
|
|
|
@@ -796,7 +774,7 @@ var getInputGroupRowLookupWithPopulatedDropdownCells = function getInputGroupRow
|
|
|
796
774
|
cells: _objectSpread({}, row.cells)
|
|
797
775
|
});
|
|
798
776
|
|
|
799
|
-
columns.forEach(function (column
|
|
777
|
+
columns.forEach(function (column) {
|
|
800
778
|
var optionId = nextRow.cells[column._id];
|
|
801
779
|
|
|
802
780
|
if (optionId && column.type === _FieldTableColumnTypes["default"].dropdown) {
|
|
@@ -809,10 +787,10 @@ var getInputGroupRowLookupWithPopulatedDropdownCells = function getInputGroupRow
|
|
|
809
787
|
};
|
|
810
788
|
/**
|
|
811
789
|
* Generate row index lookup:
|
|
812
|
-
* @param {*} fieldId
|
|
813
|
-
* @param {*} fieldSettings
|
|
814
|
-
* @param {*} rows
|
|
815
|
-
* @returns
|
|
790
|
+
* @param {*} fieldId
|
|
791
|
+
* @param {*} fieldSettings
|
|
792
|
+
* @param {*} rows
|
|
793
|
+
* @returns
|
|
816
794
|
*/
|
|
817
795
|
|
|
818
796
|
|