rerobe-js-orm 3.0.25 → 3.0.27
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/lib/factories/Product/ProductFromFormState.js +1 -1
- package/lib/form-states/Product/ProductFormState.d.ts +1 -1
- package/lib/form-states/Product/ProductFormState.js +49 -25
- package/lib/form-states/Product/options.d.ts +2 -3
- package/lib/form-states/Product/options.js +5 -10
- package/lib/models/Product.js +3 -3
- package/lib/types/rerobe-product-types.d.ts +3 -3
- package/package.json +1 -1
|
@@ -37,7 +37,7 @@ class ProductFromFormState extends ProductFactory_1.default {
|
|
|
37
37
|
const productFilterAttributes = {
|
|
38
38
|
documentId: (_o = props.props) === null || _o === void 0 ? void 0 : _o.documentId,
|
|
39
39
|
brand: props.fields.brand.selectedValue,
|
|
40
|
-
|
|
40
|
+
measurementCategory: props.fields.measurementCategory.selectedValue,
|
|
41
41
|
size: props.fields.size.selectedValue,
|
|
42
42
|
clothingSize: props.fields.clothingSize.selectedValues,
|
|
43
43
|
jeanSize: props.fields.jeanSize.selectedValue,
|
|
@@ -42,7 +42,7 @@ export default class ProductFormState extends FormState {
|
|
|
42
42
|
private productTypeSelectHandler;
|
|
43
43
|
private setPriceRangeFromPrice;
|
|
44
44
|
private setGenderFromPassedOptions;
|
|
45
|
-
private
|
|
45
|
+
private setProductCategoriesFromGender;
|
|
46
46
|
private setProductTypesFromCategory;
|
|
47
47
|
private setProductTypesFromPassedOptions;
|
|
48
48
|
private setProductStylesFromCategoryAndType;
|
|
@@ -29,13 +29,13 @@ class ProductFormState extends FormState_1.default {
|
|
|
29
29
|
this.fields.measurements = this.fieldFactory('singleSelect', 'measurements');
|
|
30
30
|
// ProductFilterAttributesFormFields
|
|
31
31
|
this.fields.brand = this.fieldFactory('singleSelect', 'brand', options_1.brands);
|
|
32
|
-
this.fields.
|
|
32
|
+
this.fields.measurementCategory = this.fieldFactory('singleSelect', 'measurementCategory', options_1.measurementCategoryOptions);
|
|
33
33
|
this.fields.size = this.fieldFactory('singleSelect', 'size', options_1.clothingSizeOptions);
|
|
34
34
|
this.fields.color = this.fieldFactory('singleSelect', 'color', options_1.colors);
|
|
35
35
|
this.fields.condition = this.fieldFactory('singleSelect', 'condition', options_1.conditions);
|
|
36
36
|
this.fields.majorDefects = this.fieldFactory('multiSelect', 'majorDefects', options_1.majorDefectOptions);
|
|
37
37
|
this.fields.minorDefects = this.fieldFactory('multiSelect', 'minorDefects', options_1.minorDefectOptions);
|
|
38
|
-
this.fields.gender = this.fieldFactory('singleSelect', 'gender', options_1.
|
|
38
|
+
this.fields.gender = this.fieldFactory('singleSelect', 'gender', options_1.genderOptions);
|
|
39
39
|
this.fields.materialComposition = this.fieldFactory('singleSelect', 'materialComposition', options_1.clothingMaterials);
|
|
40
40
|
this.fields.priceRange = this.fieldFactory('textInput', 'priceRange');
|
|
41
41
|
this.fields.productCategory = this.fieldFactory('singleSelect', 'productCategory', options_1.productCategories);
|
|
@@ -105,7 +105,7 @@ class ProductFormState extends FormState_1.default {
|
|
|
105
105
|
this.fields.gender.selectedValue = value;
|
|
106
106
|
this.fields.gender.valid = !!value;
|
|
107
107
|
// Reset productCategory fields except options
|
|
108
|
-
this.fields.productCategory.options = this.
|
|
108
|
+
this.fields.productCategory.options = this.setProductCategoriesFromGender(value);
|
|
109
109
|
this.fields.productCategory.hidden = true;
|
|
110
110
|
this.fields.productCategory.valid = false;
|
|
111
111
|
this.fields.productCategory.selectedValue = '';
|
|
@@ -256,25 +256,35 @@ class ProductFormState extends FormState_1.default {
|
|
|
256
256
|
return '1000+';
|
|
257
257
|
}
|
|
258
258
|
setGenderFromPassedOptions() {
|
|
259
|
+
let options = options_1.genderOptions;
|
|
260
|
+
let selectedGenderOptions = [];
|
|
261
|
+
if (this.props.gender) {
|
|
262
|
+
selectedGenderOptions = [{ label: this.props.gender, value: this.props.gender }];
|
|
263
|
+
if (!options.map((o) => o.value).includes(this.props.gender)) {
|
|
264
|
+
options.splice(0, 0, ...selectedGenderOptions);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
259
267
|
if (this.opts && this.opts.taxonomy && Object.keys(this.opts.taxonomy).length > 0) {
|
|
260
|
-
|
|
268
|
+
const passedOptions = Object.keys(this.opts.taxonomy).map((t) => ({ label: t, value: t }));
|
|
269
|
+
options = this.utilities.uniqObjArray([...selectedGenderOptions, ...passedOptions], 'value');
|
|
261
270
|
}
|
|
262
|
-
return
|
|
271
|
+
return options;
|
|
263
272
|
}
|
|
264
|
-
|
|
265
|
-
let
|
|
273
|
+
setProductCategoriesFromGender(genderSelected) {
|
|
274
|
+
let options = options_1.productCategories;
|
|
275
|
+
let selectedProductCategoryOptions = [];
|
|
276
|
+
if (this.props.productCategory) {
|
|
277
|
+
selectedProductCategoryOptions = [{ label: this.props.productCategory, value: this.props.productCategory }];
|
|
278
|
+
if (!options.map((o) => o.value).includes(this.props.productCategory)) {
|
|
279
|
+
options.splice(0, 0, ...selectedProductCategoryOptions);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
266
282
|
if (this.opts && this.opts.taxonomy && Object.keys(this.opts.taxonomy).length > 0 && genderSelected) {
|
|
267
283
|
const t = this.opts.taxonomy;
|
|
268
284
|
const { [genderSelected]: genderObj = {} } = t;
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
else {
|
|
272
|
-
productCategoryOptions = options_1.productCategories;
|
|
285
|
+
const passedOptions = Object.keys(genderObj).map((k) => ({ label: k, value: k }));
|
|
286
|
+
options = this.utilities.uniqObjArray([...selectedProductCategoryOptions, ...passedOptions], 'value');
|
|
273
287
|
}
|
|
274
|
-
const selectedCategoryOptions = this.props.productCategory
|
|
275
|
-
? [{ label: this.props.productCategory, value: this.props.productCategory }]
|
|
276
|
-
: [];
|
|
277
|
-
const options = this.utilities.uniqObjArray([...productCategoryOptions, ...selectedCategoryOptions], 'value');
|
|
278
288
|
return options;
|
|
279
289
|
}
|
|
280
290
|
setProductTypesFromCategory(productCategory, genderSelected) {
|
|
@@ -324,6 +334,7 @@ class ProductFormState extends FormState_1.default {
|
|
|
324
334
|
}
|
|
325
335
|
}
|
|
326
336
|
setProductTypesFromPassedOptions(productCategory, genderSelected) {
|
|
337
|
+
let options = this.setProductTypesFromCategory(productCategory, genderSelected);
|
|
327
338
|
if (productCategory &&
|
|
328
339
|
genderSelected &&
|
|
329
340
|
this.opts &&
|
|
@@ -331,9 +342,16 @@ class ProductFormState extends FormState_1.default {
|
|
|
331
342
|
Object.keys(this.opts.taxonomy).length > 0) {
|
|
332
343
|
const t = this.opts.taxonomy;
|
|
333
344
|
const { [genderSelected]: { [productCategory]: productTypeArr = [] } = {} } = t;
|
|
334
|
-
|
|
345
|
+
options = productTypeArr;
|
|
346
|
+
}
|
|
347
|
+
let selectedProductTypeOptions = [];
|
|
348
|
+
if (this.props.productType) {
|
|
349
|
+
selectedProductTypeOptions = [{ label: this.props.productType, value: this.props.productType, styles: [] }];
|
|
350
|
+
if (!options.map((o) => o.value).includes(this.props.productType)) {
|
|
351
|
+
options.splice(0, 0, ...selectedProductTypeOptions);
|
|
352
|
+
}
|
|
335
353
|
}
|
|
336
|
-
return
|
|
354
|
+
return options;
|
|
337
355
|
}
|
|
338
356
|
setProductStylesFromCategoryAndType(productCategory, productType) {
|
|
339
357
|
switch (productCategory) {
|
|
@@ -397,6 +415,7 @@ class ProductFormState extends FormState_1.default {
|
|
|
397
415
|
}
|
|
398
416
|
}
|
|
399
417
|
setProductStylesFromPassedOptions(productCategory, productType) {
|
|
418
|
+
let options = this.setProductStylesFromCategoryAndType(productCategory, productType);
|
|
400
419
|
if (this.opts &&
|
|
401
420
|
this.opts.taxonomy &&
|
|
402
421
|
Object.keys(this.opts.taxonomy).length > 0 &&
|
|
@@ -407,11 +426,16 @@ class ProductFormState extends FormState_1.default {
|
|
|
407
426
|
const { [genderSelected]: { [productCategory]: productTypeArr = [] } = {} } = t;
|
|
408
427
|
const [pType] = productTypeArr.filter((p) => p.value === productType);
|
|
409
428
|
if (pType) {
|
|
410
|
-
|
|
429
|
+
options = pType.styles.map((s) => ({ label: s, value: s }));
|
|
411
430
|
}
|
|
412
|
-
return [];
|
|
413
431
|
}
|
|
414
|
-
|
|
432
|
+
if (this.props.productStyle && Array.isArray(this.props.productStyle) && this.props.productStyle.length > 0) {
|
|
433
|
+
options = [...new Set([...this.props.productStyle, ...options.map((o) => o.value)])].map((s) => ({
|
|
434
|
+
label: s,
|
|
435
|
+
value: s,
|
|
436
|
+
}));
|
|
437
|
+
}
|
|
438
|
+
return options;
|
|
415
439
|
}
|
|
416
440
|
discountTypeChangeHandler(val) {
|
|
417
441
|
const prevVal = this.fields.discountType.selectedValue;
|
|
@@ -521,7 +545,7 @@ class ProductFormState extends FormState_1.default {
|
|
|
521
545
|
onChangeHandler = (val) => this.genderSelectHandler(val);
|
|
522
546
|
}
|
|
523
547
|
if (fieldKey === 'productCategory') {
|
|
524
|
-
options = this.
|
|
548
|
+
options = this.setProductCategoriesFromGender(this.props.gender);
|
|
525
549
|
onChangeHandler = (val) => this.productCategorySelectHandler(val);
|
|
526
550
|
}
|
|
527
551
|
if (fieldKey === 'productType') {
|
|
@@ -606,11 +630,11 @@ class ProductFormState extends FormState_1.default {
|
|
|
606
630
|
}
|
|
607
631
|
}
|
|
608
632
|
}
|
|
609
|
-
if (fieldKey === '
|
|
633
|
+
if (fieldKey === 'measurementCategory') {
|
|
610
634
|
let selectedOptions = [];
|
|
611
|
-
if (this.props.
|
|
612
|
-
selectedOptions = [{ label: this.props.
|
|
613
|
-
if (!options.map((o) => o.value).includes(this.props.
|
|
635
|
+
if (this.props.measurementCategory) {
|
|
636
|
+
selectedOptions = [{ label: this.props.measurementCategory, value: this.props.measurementCategory }];
|
|
637
|
+
if (!options.map((o) => o.value).includes(this.props.measurementCategory)) {
|
|
614
638
|
options.splice(0, 0, ...selectedOptions);
|
|
615
639
|
}
|
|
616
640
|
}
|
|
@@ -59,7 +59,7 @@ export const conditions: ({
|
|
|
59
59
|
key: string;
|
|
60
60
|
color?: undefined;
|
|
61
61
|
})[];
|
|
62
|
-
export const
|
|
62
|
+
export const genderOptions: {
|
|
63
63
|
label: string;
|
|
64
64
|
value: string;
|
|
65
65
|
}[];
|
|
@@ -79,7 +79,6 @@ export const clothingMaterials: {
|
|
|
79
79
|
export const productCategories: {
|
|
80
80
|
label: string;
|
|
81
81
|
value: string;
|
|
82
|
-
color: string;
|
|
83
82
|
}[];
|
|
84
83
|
export const clothing: {
|
|
85
84
|
label: string;
|
|
@@ -188,7 +187,7 @@ export const minorDefectOptions: {
|
|
|
188
187
|
label: string;
|
|
189
188
|
value: string;
|
|
190
189
|
}[];
|
|
191
|
-
export const
|
|
190
|
+
export const measurementCategoryOptions: {
|
|
192
191
|
label: string;
|
|
193
192
|
value: string;
|
|
194
193
|
measurementFields: string[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.measurementCategoryOptions = exports.minorDefectOptions = exports.majorDefectOptions = exports.productOptions = exports.productIsOnSaleOptions = exports.discountTypeOptions = exports.salesChannelOptions = exports.unisexJewelry = exports.mensJewelry = exports.jewelry = exports.unisexAccessories = exports.mensAccessories = exports.accessories = exports.unisexBags = exports.mensBags = exports.bags = exports.weightUnits = exports.productWeightRanges = exports.unisexShoes = exports.mensShoes = exports.shoes = exports.unisexClothing = exports.mensClothing = exports.clothing = exports.productCategories = exports.clothingMaterials = exports.shoeSizes = exports.jeanSizes = exports.genderOptions = exports.conditions = exports.colors = exports.brands = exports.sizeCommentOptions = exports.manClothingSizeOptions = exports.womanClothingSizeOptions = exports.clothingSizeOptions = exports.sizeOptions = exports.statusOptions = exports.publishTypeOptions = exports.availableForSaleOptions = void 0;
|
|
4
4
|
const product_constants_1 = require("../../constants/product-constants");
|
|
5
5
|
const lodash_1 = require("lodash");
|
|
6
6
|
const availableForSaleOptions = [
|
|
@@ -34,7 +34,7 @@ const statusOptions = Object.values(product_constants_1.PRODUCT_STATES).map((val
|
|
|
34
34
|
value: val,
|
|
35
35
|
}));
|
|
36
36
|
exports.statusOptions = statusOptions;
|
|
37
|
-
const
|
|
37
|
+
const measurementCategoryOptions = [
|
|
38
38
|
{
|
|
39
39
|
label: 'Suits & Blazers',
|
|
40
40
|
value: 'Suits & Blazers',
|
|
@@ -98,7 +98,7 @@ const sizeCategoryOptions = [
|
|
|
98
98
|
measurementFields: ['width', 'height', 'depth'],
|
|
99
99
|
},
|
|
100
100
|
];
|
|
101
|
-
exports.
|
|
101
|
+
exports.measurementCategoryOptions = measurementCategoryOptions;
|
|
102
102
|
const sizeOptions = [
|
|
103
103
|
{
|
|
104
104
|
label: 'No Size',
|
|
@@ -1816,7 +1816,7 @@ const minorDefectOptions = [
|
|
|
1816
1816
|
{ label: 'Other minor Issue', value: 'Other minor issue' },
|
|
1817
1817
|
];
|
|
1818
1818
|
exports.minorDefectOptions = minorDefectOptions;
|
|
1819
|
-
const
|
|
1819
|
+
const genderOptions = [
|
|
1820
1820
|
{
|
|
1821
1821
|
label: 'Woman',
|
|
1822
1822
|
value: 'Woman',
|
|
@@ -1842,7 +1842,7 @@ const gender = [
|
|
|
1842
1842
|
value: 'NA',
|
|
1843
1843
|
},
|
|
1844
1844
|
];
|
|
1845
|
-
exports.
|
|
1845
|
+
exports.genderOptions = genderOptions;
|
|
1846
1846
|
const jeanSizes = [
|
|
1847
1847
|
{ label: '24', value: '24' },
|
|
1848
1848
|
{ label: '25', value: '25' },
|
|
@@ -2089,27 +2089,22 @@ const productCategories = [
|
|
|
2089
2089
|
{
|
|
2090
2090
|
label: 'Clothing',
|
|
2091
2091
|
value: 'Clothing',
|
|
2092
|
-
color: '#cfdfff',
|
|
2093
2092
|
},
|
|
2094
2093
|
{
|
|
2095
2094
|
label: 'Shoes',
|
|
2096
2095
|
value: 'Shoes',
|
|
2097
|
-
color: '#d0f0fd',
|
|
2098
2096
|
},
|
|
2099
2097
|
{
|
|
2100
2098
|
label: 'Bags',
|
|
2101
2099
|
value: 'Bags',
|
|
2102
|
-
color: '#d0f0fd',
|
|
2103
2100
|
},
|
|
2104
2101
|
{
|
|
2105
2102
|
label: 'Accessories',
|
|
2106
2103
|
value: 'Accessories',
|
|
2107
|
-
color: '#d0f0fd',
|
|
2108
2104
|
},
|
|
2109
2105
|
{
|
|
2110
2106
|
label: 'Jewelry',
|
|
2111
2107
|
value: 'Jewelry',
|
|
2112
|
-
color: '#d0f0fd',
|
|
2113
2108
|
},
|
|
2114
2109
|
];
|
|
2115
2110
|
exports.productCategories = productCategories;
|
package/lib/models/Product.js
CHANGED
|
@@ -44,7 +44,7 @@ class Product extends Base_1.default {
|
|
|
44
44
|
jeanSize: (props === null || props === void 0 ? void 0 : props.jeanSize) || '',
|
|
45
45
|
shoeSize: (props === null || props === void 0 ? void 0 : props.shoeSize) || '',
|
|
46
46
|
size: (props === null || props === void 0 ? void 0 : props.size) || '',
|
|
47
|
-
|
|
47
|
+
measurementCategory: (props === null || props === void 0 ? void 0 : props.measurementCategory) || '',
|
|
48
48
|
productCategory: (props === null || props === void 0 ? void 0 : props.productCategory) || '',
|
|
49
49
|
productType: (props === null || props === void 0 ? void 0 : props.productType) || '',
|
|
50
50
|
productStyle: (props === null || props === void 0 ? void 0 : props.productStyle) || [],
|
|
@@ -285,7 +285,7 @@ class Product extends Base_1.default {
|
|
|
285
285
|
compareAtPrice: this.utilities.sanitizeNumber(this.attributes.compareAtPrice),
|
|
286
286
|
costPerItem: this.utilities.sanitizeNumber(this.attributes.costPerItem),
|
|
287
287
|
priceRange: this.utilities.sanitizeString(this.filterAttributes.priceRange),
|
|
288
|
-
|
|
288
|
+
measurementCategory: this.utilities.sanitizeString(this.filterAttributes.measurementCategory),
|
|
289
289
|
productCategory: this.utilities.sanitizeString(this.filterAttributes.productCategory),
|
|
290
290
|
productType: this.utilities.sanitizeString(this.filterAttributes.productType),
|
|
291
291
|
productStyle: this.utilities.sanitzeStringArr(this.filterAttributes.productStyle),
|
|
@@ -567,7 +567,7 @@ class Product extends Base_1.default {
|
|
|
567
567
|
{
|
|
568
568
|
facet: true,
|
|
569
569
|
optional: true,
|
|
570
|
-
name: '
|
|
570
|
+
name: 'measurementCategory',
|
|
571
571
|
type: 'string',
|
|
572
572
|
},
|
|
573
573
|
{
|
|
@@ -39,7 +39,7 @@ declare type ProductFilterAttributes = {
|
|
|
39
39
|
gender: string;
|
|
40
40
|
materialComposition: MaterialComposition;
|
|
41
41
|
priceRange: string;
|
|
42
|
-
|
|
42
|
+
measurementCategory: string;
|
|
43
43
|
productCategory: string;
|
|
44
44
|
productType: string;
|
|
45
45
|
productStyle: string[];
|
|
@@ -170,7 +170,7 @@ declare type ProductFilterAttributesFormFields = {
|
|
|
170
170
|
gender: SingleSelectFormField<string>;
|
|
171
171
|
materialComposition: SingleSelectFormField<MaterialComposition>;
|
|
172
172
|
priceRange: TextInputFormField<string>;
|
|
173
|
-
|
|
173
|
+
measurementCategory: SingleSelectFormField<string>;
|
|
174
174
|
productCategory: SingleSelectFormField<string>;
|
|
175
175
|
productType: SingleSelectFormField<string>;
|
|
176
176
|
productStyle: MultiSelectFormField<string>;
|
|
@@ -259,7 +259,7 @@ declare type TypesenseProductObj = {
|
|
|
259
259
|
compareAtPrice: number;
|
|
260
260
|
costPerItem: number;
|
|
261
261
|
priceRange: string;
|
|
262
|
-
|
|
262
|
+
measurementCategory: string;
|
|
263
263
|
productCategory: string;
|
|
264
264
|
productType: string;
|
|
265
265
|
productStyle: string[];
|