@builttocreate/engine-utils 2.8.0-beta.6 → 2.8.0-beta.8

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.
@@ -171,7 +171,6 @@ var removeOrphanedFieldsFromJoydoc = exports.removeOrphanedFieldsFromJoydoc = fu
171
171
  nextDoc.fields = nextDoc.fields.filter(function (field) {
172
172
  var isOrphanedField = true;
173
173
  nextDoc.files.forEach(function (file) {
174
- var _file$views$find;
175
174
  var primaryViewPages = file.pages;
176
175
 
177
176
  // Check if field is associated with any field positions in primary view pages
@@ -180,21 +179,24 @@ var removeOrphanedFieldsFromJoydoc = exports.removeOrphanedFieldsFromJoydoc = fu
180
179
  return fieldPosition.field === field._id;
181
180
  });
182
181
  });
183
- var mobileViewPages = file.views.length > 0 ? ((_file$views$find = file.views.find(function (view) {
184
- return view.type === _FileViews["default"].mobile;
185
- })) === null || _file$views$find === void 0 ? void 0 : _file$views$find.pages) || [] : null;
186
182
 
187
- // Check if field is associated with any field positions in mobile view pages
188
- var isFieldAssociatedWithMobileView = mobileViewPages && mobileViewPages.length > 0 ? mobileViewPages.some(function (page) {
189
- return page.fieldPositions.some(function (fieldPosition) {
190
- return fieldPosition.field === field._id;
183
+ // Check if field is associated with other views
184
+ var isFieldAssociatedWithAnotherView;
185
+ if (file.views && file.views.length > 0) {
186
+ isFieldAssociatedWithAnotherView = file.views.some(function (view) {
187
+ return view.pages.some(function (page) {
188
+ return page.fieldPositions.some(function (fieldPosition) {
189
+ return fieldPosition.field === field._id;
190
+ });
191
+ });
191
192
  });
192
- }) : false;
193
- if (isFieldAssociatedWithPrimaryView || isFieldAssociatedWithMobileView) {
193
+ }
194
+ if (isFieldAssociatedWithPrimaryView || isFieldAssociatedWithAnotherView) {
194
195
  isOrphanedField = false;
195
196
  }
196
197
  });
197
198
  if (!isOrphanedField) return field;
199
+ return null;
198
200
  });
199
201
  return nextDoc;
200
202
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builttocreate/engine-utils",
3
- "version": "2.8.0-beta.6",
3
+ "version": "2.8.0-beta.8",
4
4
  "description": "Utility library for common logic shared across web and mobile",
5
5
  "main": "dist/index.js",
6
6
  "files": [