@builttocreate/engine-utils 2.4.0-beta.0.1 → 2.4.0-beta.0.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.
@@ -344,14 +344,21 @@ var isFieldEmpty = function isFieldEmpty(fieldType, fieldValue, fieldOptions, fi
344
344
  exports.isFieldEmpty = isFieldEmpty;
345
345
 
346
346
  var isTargetOptionDeleted = function isTargetOptionDeleted(value, options) {
347
- //Dropdown field has value as a string whereas multiselect has value as an array
348
- var nextValue = value && typeof value === 'string' ? value : value[0]; //If user unchecks an option in mutliselect value will be undefiend
349
-
350
- if (!nextValue) return true;
351
- var targetOption = options.find(function (option) {
352
- return option._id === nextValue;
347
+ /***
348
+ * Dropdown field will send value as a string
349
+ * where as multiselect field will send value as an array
350
+ */
351
+ var nextValue = Array.isArray(value) ? value : [value];
352
+ if (!nextValue || nextValue.length === 0) return true;
353
+ var optionsLookup = {};
354
+ options.forEach(function (option) {
355
+ optionsLookup[option._id] = option;
356
+ });
357
+ var undeletedOptions = nextValue.filter(function (item) {
358
+ return optionsLookup[item] && !optionsLookup[item].deleted;
353
359
  });
354
- return targetOption ? targetOption.deleted : true;
360
+ var result = undeletedOptions.length > 0 ? false : true;
361
+ return result;
355
362
  };
356
363
 
357
364
  exports.isTargetOptionDeleted = isTargetOptionDeleted;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builttocreate/engine-utils",
3
- "version": "2.4.0-beta.0.1",
3
+ "version": "2.4.0-beta.0.3",
4
4
  "description": "Utility library for common logic shared across web and mobile",
5
5
  "main": "dist/index.js",
6
6
  "files": [