rerobe-js-orm 2.4.83 → 2.4.84

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.
@@ -76,6 +76,7 @@ class ProductFromFormState extends ProductFactory_1.default {
76
76
  discountValue: props.fields.discountValue.inputValue || '',
77
77
  selectedForClearance: ((_r = props.props) === null || _r === void 0 ? void 0 : _r.selectedForClearance) || '',
78
78
  locationIds: props.fields.locationIds.selectedValues || [],
79
+ inventoryLocations: props.fields.inventoryLocations.selectedValues || [],
79
80
  };
80
81
  const timestampAttributes = {
81
82
  sellRequestReviewTimestamp: (_s = props.props) === null || _s === void 0 ? void 0 : _s.sellRequestReviewTimestamp,
@@ -24,5 +24,6 @@ export default class ProductFormState extends FormState {
24
24
  private discountTypeChangeHandler;
25
25
  private discountValueChangeHandler;
26
26
  private calculateSalePrice;
27
+ private inventoryLocationsChangeHandler;
27
28
  private fieldFactory;
28
29
  }
@@ -71,6 +71,7 @@ class ProductFormState extends FormState_1.default {
71
71
  this.fields.vendorName = this.fieldFactory('singleSelect', 'vendorName');
72
72
  this.fields.rfidTag = this.fieldFactory('textInput', 'rfidTag');
73
73
  this.fields.locationIds = this.fieldFactory('multiSelect', 'locationIds');
74
+ this.fields.inventoryLocations = this.fieldFactory('multiSelect', 'inventoryLocations');
74
75
  this.fields.featuredCollections = this.fieldFactory('multiSelect', 'featuredCollections');
75
76
  this.fields.tags = this.fieldFactory('multiSelect', 'tags');
76
77
  }
@@ -413,6 +414,24 @@ class ProductFormState extends FormState_1.default {
413
414
  }
414
415
  return '';
415
416
  }
417
+ inventoryLocationsChangeHandler(val) {
418
+ const { id, incomingAmount, availableAmount } = val;
419
+ const existingIds = this.fields.inventoryLocations.selectedValues.map((i) => i.id);
420
+ if (existingIds.includes(id)) {
421
+ const foundInd = this.fields.inventoryLocations.selectedValues.findIndex((i) => i.id === id);
422
+ const foundI = this.fields.inventoryLocations.selectedValues[foundInd];
423
+ // Delete case: val is exact same object
424
+ if (incomingAmount === foundI.incomingAmount && availableAmount === foundI.availableAmount) {
425
+ this.fields.inventoryLocations.selectedValues.splice(foundInd, 1);
426
+ }
427
+ else {
428
+ this.fields.inventoryLocations.selectedValues.splice(foundInd, 1, val);
429
+ }
430
+ }
431
+ else {
432
+ this.multiSelectChangeHandler('inventoryLocations', val);
433
+ }
434
+ }
416
435
  fieldFactory(fieldType, fieldKey, fieldOptions) {
417
436
  let options = fieldOptions || [];
418
437
  let hidden = false;
@@ -499,6 +518,7 @@ class ProductFormState extends FormState_1.default {
499
518
  };
500
519
  }
501
520
  if (fieldType === 'multiSelect') {
521
+ let onChangeHandler = (val) => this.multiSelectChangeHandler(fieldKey, val);
502
522
  if (fieldKey === 'productStyle') {
503
523
  options = this.setProductStylesFromCategoryAndType(this.props.productCategory, this.props.productType);
504
524
  if (this.props.productStyle && this.props.productStyle.length > 0) {
@@ -608,12 +628,15 @@ class ProductFormState extends FormState_1.default {
608
628
  }
609
629
  hidden = this.props.productCategory !== 'Clothing' || this.props.productType === 'Jeans';
610
630
  }
631
+ if (fieldKey === 'inventoryLocations') {
632
+ onChangeHandler = (val) => this.inventoryLocationsChangeHandler(val);
633
+ }
611
634
  return {
612
635
  options,
613
636
  hidden,
614
637
  selectedValues: this.props[fieldKey] || [],
615
638
  valid: this.props[fieldKey].length > 0,
616
- onChangeHandler: (val) => this.multiSelectChangeHandler(fieldKey, val),
639
+ onChangeHandler,
617
640
  };
618
641
  }
619
642
  if (fieldType === 'textInput') {
@@ -80,6 +80,7 @@ class Product extends Base_1.default {
80
80
  discountValue: (props === null || props === void 0 ? void 0 : props.discountValue) || '',
81
81
  selectedForClearance: (props === null || props === void 0 ? void 0 : props.selectedForClearance) || '',
82
82
  locationIds: (props === null || props === void 0 ? void 0 : props.locationIds) || [],
83
+ inventoryLocations: (props === null || props === void 0 ? void 0 : props.inventoryLocations) || [],
83
84
  };
84
85
  this.timestampAttributes = {
85
86
  sellRequestReviewDraftTimestamp: (props === null || props === void 0 ? void 0 : props.sellRequestReviewDraftTimestamp)
@@ -69,6 +69,7 @@ declare type ProductConsignmentAttributes = {
69
69
  discountValue: string;
70
70
  selectedForClearance: string;
71
71
  locationIds?: string[];
72
+ inventoryLocations: InventoryLocation[];
72
73
  };
73
74
  declare type ProductTimestampAttributes = {
74
75
  sellRequestReviewTimestamp: number | null;
@@ -188,6 +189,7 @@ declare type ProductConsignmentAttributesFormFields = {
188
189
  discountType: SingleSelectFormField<string>;
189
190
  discountValue: TextInputFormField<string>;
190
191
  locationIds: MultiSelectFormField<string>;
192
+ inventoryLocations: MultiSelectFormField<InventoryLocation>;
191
193
  };
192
194
  declare type ProductFormFields = ProductAttributesFormFields & ProductFilterAttributesFormFields & ProductConsignmentAttributesFormFields;
193
195
  interface ParamsForBuildProductInputObjForShopify {
@@ -221,3 +223,9 @@ declare type ProductLineItem = {
221
223
  image: string;
222
224
  quantity: number;
223
225
  };
226
+ declare type InventoryLocation = {
227
+ id: string;
228
+ name: string;
229
+ incomingAmount: number;
230
+ availableAmount: number;
231
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rerobe-js-orm",
3
- "version": "2.4.83",
3
+ "version": "2.4.84",
4
4
  "description": "ReRobe's Javascript ORM Framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",