@builttocreate/engine-utils 2.8.0-beta.2 → 2.8.0-beta.5

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.
@@ -97,7 +97,7 @@ var addDocumentDataToActivities = function addDocumentDataToActivities(activitie
97
97
 
98
98
  if (activity.document && activity.document.field) {
99
99
  var docFieldValue = fieldValues[activity.document.field];
100
- var templateField = templateFieldLookup[activity.document.field];
100
+ var templateField = templateFieldLookup[activity.document.field] || {};
101
101
  nextActivity.document.title = templateField.title;
102
102
  nextActivity.document.type = templateField.type;
103
103
  nextActivity.document.columns = templateField.tableColumns;
@@ -173,7 +173,7 @@ var addDocumentDataToActivities = function addDocumentDataToActivities(activitie
173
173
 
174
174
  nextActivity.document.value = _nextDocFieldValue;
175
175
  } //This should handle adding the display value for selection and regular input fields
176
- else {
176
+ else if (templateField.optionsLookup) {
177
177
  var option = templateField.optionsLookup[docFieldValue];
178
178
  nextActivity.document.value = option && option.value ? option.value : docFieldValue;
179
179
  }
@@ -191,6 +191,37 @@ var getCleanedJoyDoc = function getCleanedJoyDoc(doc) {
191
191
  });
192
192
  }
193
193
 
194
+ console.log('initialdOC', JSON.parse(JSON.stringify(doc)));
195
+ var fieldsWithFieldPositions = nextDoc.fields.filter(function (field) {
196
+ var isFieldAssociatedWithAFieldPosition = false;
197
+ nextDoc.files.forEach(function (file) {
198
+ var _file$views$find;
199
+
200
+ var primaryViewPages = file.pages; // Check if field is associated with any field positions in primary view pages
201
+
202
+ var isFieldAssociatedWithPrimaryView = primaryViewPages.some(function (page) {
203
+ return page.fieldPositions.some(function (fieldPosition) {
204
+ return fieldPosition.field === field._id;
205
+ });
206
+ });
207
+ var mobileViewPages = file.views.length > 0 ? ((_file$views$find = file.views.find(function (view) {
208
+ return view.type === _FileViews["default"].mobile;
209
+ })) === null || _file$views$find === void 0 ? void 0 : _file$views$find.pages) || [] : null; // Check if field is associated with any field positions in mobile view pages
210
+
211
+ var isFieldAssociatedWithMobileView = mobileViewPages && mobileViewPages.length > 0 ? mobileViewPages.some(function (page) {
212
+ return page.fieldPositions.some(function (fieldPosition) {
213
+ return fieldPosition.field === field._id;
214
+ });
215
+ }) : false;
216
+
217
+ if (isFieldAssociatedWithPrimaryView || isFieldAssociatedWithMobileView) {
218
+ isFieldAssociatedWithAFieldPosition = true;
219
+ }
220
+ });
221
+ return isFieldAssociatedWithAFieldPosition;
222
+ });
223
+ console.log('finalView', JSON.parse(JSON.stringify(nextDoc)));
224
+ nextDoc.fields = fieldsWithFieldPositions;
194
225
  return nextDoc;
195
226
  };
196
227
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builttocreate/engine-utils",
3
- "version": "2.8.0-beta.2",
3
+ "version": "2.8.0-beta.5",
4
4
  "description": "Utility library for common logic shared across web and mobile",
5
5
  "main": "dist/index.js",
6
6
  "files": [