rerobe-js-orm 2.9.2 → 2.9.4
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/form-states/FormState.d.ts +1 -0
- package/lib/form-states/FormState.js +5 -0
- package/lib/form-states/Product/ProductFormState.d.ts +6 -0
- package/lib/form-states/Product/ProductFormState.js +41 -156
- package/lib/form-states/Product/options.d.ts +8 -0
- package/lib/form-states/Product/options.js +79 -1
- package/package.json +1 -1
|
@@ -7,5 +7,6 @@ export default abstract class FormState extends Base {
|
|
|
7
7
|
multiSelectChangeHandler<T>(key: keyof FormStateObject, value: T): void;
|
|
8
8
|
multiSelectMediaChangeHandler(key: keyof FormStateObject, fileArr: FileObj[]): void;
|
|
9
9
|
onAddNewOptionToFormFieldOptions(key: keyof FormStateObject, option: FormFieldOption): void;
|
|
10
|
+
onSetNewFormFieldOptions(key: keyof FormStateObject, options: FormFieldOption[]): void;
|
|
10
11
|
editExistingOption(key: keyof FormStateObject, oldOptionValue: string, option: FormFieldOption): void;
|
|
11
12
|
}
|
|
@@ -38,6 +38,11 @@ class FormState extends Base_1.default {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
+
onSetNewFormFieldOptions(key, options) {
|
|
42
|
+
const formField = this.fields[key];
|
|
43
|
+
const newOptions = this.utilities.uniqObjArray(options, 'value');
|
|
44
|
+
formField.options = newOptions;
|
|
45
|
+
}
|
|
41
46
|
editExistingOption(key, oldOptionValue, option) {
|
|
42
47
|
const formField = this.fields[key];
|
|
43
48
|
const existingOptionIndex = formField.options && formField.options.findIndex((opt) => opt.value === oldOptionValue);
|
|
@@ -12,6 +12,12 @@ export default class ProductFormState extends FormState {
|
|
|
12
12
|
taxonomy: {
|
|
13
13
|
[key: string]: any;
|
|
14
14
|
};
|
|
15
|
+
brands: string[];
|
|
16
|
+
colors: string[];
|
|
17
|
+
clothingSizes: string[];
|
|
18
|
+
jeanSizes: string[];
|
|
19
|
+
shoeSizes: string[];
|
|
20
|
+
conditions: string[];
|
|
15
21
|
};
|
|
16
22
|
constructor(props?: any, opts?: any);
|
|
17
23
|
autoCreateTitle(): string;
|
|
@@ -125,84 +125,10 @@ class ProductFormState extends FormState_1.default {
|
|
|
125
125
|
this.fields.productStyle.valid = false;
|
|
126
126
|
// Update clothingSize fields based on gender selected
|
|
127
127
|
if (value === 'Woman') {
|
|
128
|
-
this.fields.clothingSize.options =
|
|
129
|
-
{
|
|
130
|
-
label: 'No Size',
|
|
131
|
-
value: 'No Size',
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
label: 'XXS (32)',
|
|
135
|
-
value: 'XXS (32)',
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
label: 'XS (34)',
|
|
139
|
-
value: 'XS (34)',
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
label: 'S (36)',
|
|
143
|
-
value: 'S (36)',
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
label: 'M (38)',
|
|
147
|
-
value: 'M (38)',
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
label: 'L (40)',
|
|
151
|
-
value: 'L (40)',
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
label: 'XL (42)',
|
|
155
|
-
value: 'XL (42)',
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
label: 'XXL (44)',
|
|
159
|
-
value: 'XXL (44)',
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
label: 'XXXL (46)',
|
|
163
|
-
value: 'XXXL (46)',
|
|
164
|
-
},
|
|
165
|
-
];
|
|
128
|
+
this.fields.clothingSize.options = options_1.womanClothingSizeOptions;
|
|
166
129
|
}
|
|
167
130
|
if (value === 'Man') {
|
|
168
|
-
this.fields.clothingSize.options =
|
|
169
|
-
{
|
|
170
|
-
label: 'No Size',
|
|
171
|
-
value: 'No Size',
|
|
172
|
-
},
|
|
173
|
-
{
|
|
174
|
-
label: 'XXS (42)',
|
|
175
|
-
value: 'XXS (42)',
|
|
176
|
-
},
|
|
177
|
-
{
|
|
178
|
-
label: 'XS (44)',
|
|
179
|
-
value: 'XS (44)',
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
label: 'S (46)',
|
|
183
|
-
value: 'S (46)',
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
label: 'M (48)',
|
|
187
|
-
value: 'M (48)',
|
|
188
|
-
},
|
|
189
|
-
{
|
|
190
|
-
label: 'L (50)',
|
|
191
|
-
value: 'L (50)',
|
|
192
|
-
},
|
|
193
|
-
{
|
|
194
|
-
label: 'XL (52)',
|
|
195
|
-
value: 'XL (52)',
|
|
196
|
-
},
|
|
197
|
-
{
|
|
198
|
-
label: 'XXL (54)',
|
|
199
|
-
value: 'XXL (54)',
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
label: 'XXXL (56)',
|
|
203
|
-
value: 'XXXL (56)',
|
|
204
|
-
},
|
|
205
|
-
];
|
|
131
|
+
this.fields.clothingSize.options = options_1.manClothingSizeOptions;
|
|
206
132
|
}
|
|
207
133
|
this.fields.clothingSize.hidden = true;
|
|
208
134
|
this.fields.clothingSize.selectedValues = [];
|
|
@@ -487,6 +413,7 @@ class ProductFormState extends FormState_1.default {
|
|
|
487
413
|
}
|
|
488
414
|
}
|
|
489
415
|
fieldFactory(fieldType, fieldKey, fieldOptions) {
|
|
416
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
490
417
|
let options = fieldOptions || [];
|
|
491
418
|
let hidden = false;
|
|
492
419
|
if (fieldType === 'singleSelect') {
|
|
@@ -552,35 +479,63 @@ class ProductFormState extends FormState_1.default {
|
|
|
552
479
|
}
|
|
553
480
|
if (fieldKey === 'jeanSize') {
|
|
554
481
|
hidden = this.props.productCategory !== 'Clothing' || this.props.productType !== 'Jeans';
|
|
482
|
+
let selectedJeanSizeOptions = [];
|
|
555
483
|
if (this.props.jeanSize) {
|
|
484
|
+
selectedJeanSizeOptions = [{ label: this.props.jeanSize, value: this.props.jeanSize }];
|
|
556
485
|
if (!options.map((o) => o.value).includes(this.props.jeanSize)) {
|
|
557
|
-
options.splice(0, 0,
|
|
486
|
+
options.splice(0, 0, ...selectedJeanSizeOptions);
|
|
558
487
|
}
|
|
559
488
|
}
|
|
489
|
+
if ((_b = (_a = this.opts) === null || _a === void 0 ? void 0 : _a.jeanSizes) === null || _b === void 0 ? void 0 : _b.length) {
|
|
490
|
+
const jeanSizesOptions = this.opts.jeanSizes.map((t) => ({ label: t, value: t }));
|
|
491
|
+
options = this.utilities.uniqObjArray([...selectedJeanSizeOptions, ...jeanSizesOptions], 'value');
|
|
492
|
+
}
|
|
560
493
|
}
|
|
561
494
|
if (fieldKey === 'shoeSize') {
|
|
562
495
|
hidden = this.props.productCategory !== 'Shoes';
|
|
496
|
+
let selectedShoeSizeOptions = [];
|
|
563
497
|
if (this.props.shoeSize) {
|
|
498
|
+
selectedShoeSizeOptions = [{ label: this.props.shoeSize, value: this.props.shoeSize }];
|
|
564
499
|
if (!options.map((o) => o.value).includes(this.props.shoeSize)) {
|
|
565
|
-
options.splice(0, 0,
|
|
500
|
+
options.splice(0, 0, ...selectedShoeSizeOptions);
|
|
566
501
|
}
|
|
567
502
|
}
|
|
503
|
+
if ((_d = (_c = this.opts) === null || _c === void 0 ? void 0 : _c.shoeSizes) === null || _d === void 0 ? void 0 : _d.length) {
|
|
504
|
+
const shoeSizesOptions = this.opts.shoeSizes.map((t) => ({ label: t, value: t }));
|
|
505
|
+
options = this.utilities.uniqObjArray([...selectedShoeSizeOptions, ...shoeSizesOptions], 'value');
|
|
506
|
+
}
|
|
568
507
|
}
|
|
569
508
|
if (fieldKey === 'brand') {
|
|
509
|
+
let selectedBrandOptions = [];
|
|
570
510
|
if (this.props.brand) {
|
|
511
|
+
selectedBrandOptions = [{ label: this.props.brand, value: this.props.brand }];
|
|
571
512
|
if (!options.map((o) => o.value).includes(this.props.brand)) {
|
|
572
|
-
options.splice(0, 0,
|
|
513
|
+
options.splice(0, 0, ...selectedBrandOptions);
|
|
573
514
|
}
|
|
574
515
|
}
|
|
516
|
+
if ((_f = (_e = this.opts) === null || _e === void 0 ? void 0 : _e.brands) === null || _f === void 0 ? void 0 : _f.length) {
|
|
517
|
+
const brandsOptions = this.opts.brands.map((t) => ({ label: t, value: t }));
|
|
518
|
+
options = this.utilities.uniqObjArray([...selectedBrandOptions, ...brandsOptions], 'value');
|
|
519
|
+
}
|
|
575
520
|
}
|
|
576
521
|
if (fieldKey === 'color') {
|
|
522
|
+
let selectedColorOptions = [];
|
|
577
523
|
if (this.props.color) {
|
|
524
|
+
selectedColorOptions = [{ label: this.props.color, value: this.props.color }];
|
|
578
525
|
if (!options.map((o) => o.value).includes(this.props.color)) {
|
|
579
|
-
options.splice(0, 0,
|
|
526
|
+
options.splice(0, 0, ...selectedColorOptions);
|
|
580
527
|
}
|
|
581
528
|
}
|
|
529
|
+
if ((_h = (_g = this.opts) === null || _g === void 0 ? void 0 : _g.colors) === null || _h === void 0 ? void 0 : _h.length) {
|
|
530
|
+
const colorsOptions = this.opts.colors.map((t) => ({ label: t, value: t }));
|
|
531
|
+
options = this.utilities.uniqObjArray([...selectedColorOptions, ...colorsOptions], 'value');
|
|
532
|
+
}
|
|
582
533
|
}
|
|
583
534
|
if (fieldKey === 'condition') {
|
|
535
|
+
if ((_k = (_j = this.opts) === null || _j === void 0 ? void 0 : _j.conditions) === null || _k === void 0 ? void 0 : _k.length) {
|
|
536
|
+
const conditionsOptions = this.opts.conditions.map((t) => ({ label: t, value: t }));
|
|
537
|
+
options = this.utilities.uniqObjArray(conditionsOptions, 'value');
|
|
538
|
+
}
|
|
584
539
|
onChangeHandler = (val) => this.conditionSelectHandler(val);
|
|
585
540
|
}
|
|
586
541
|
return {
|
|
@@ -623,84 +578,14 @@ class ProductFormState extends FormState_1.default {
|
|
|
623
578
|
}
|
|
624
579
|
if (fieldKey === 'clothingSize') {
|
|
625
580
|
if (this.props.gender === 'Woman') {
|
|
626
|
-
options =
|
|
627
|
-
{
|
|
628
|
-
label: 'No Size',
|
|
629
|
-
value: 'No Size',
|
|
630
|
-
},
|
|
631
|
-
{
|
|
632
|
-
label: 'XXS (32)',
|
|
633
|
-
value: 'XXS (32)',
|
|
634
|
-
},
|
|
635
|
-
{
|
|
636
|
-
label: 'XS (34)',
|
|
637
|
-
value: 'XS (34)',
|
|
638
|
-
},
|
|
639
|
-
{
|
|
640
|
-
label: 'S (36)',
|
|
641
|
-
value: 'S (36)',
|
|
642
|
-
},
|
|
643
|
-
{
|
|
644
|
-
label: 'M (38)',
|
|
645
|
-
value: 'M (38)',
|
|
646
|
-
},
|
|
647
|
-
{
|
|
648
|
-
label: 'L (40)',
|
|
649
|
-
value: 'L (40)',
|
|
650
|
-
},
|
|
651
|
-
{
|
|
652
|
-
label: 'XL (42)',
|
|
653
|
-
value: 'XL (42)',
|
|
654
|
-
},
|
|
655
|
-
{
|
|
656
|
-
label: 'XXL (44)',
|
|
657
|
-
value: 'XXL (44)',
|
|
658
|
-
},
|
|
659
|
-
{
|
|
660
|
-
label: 'XXXL (46)',
|
|
661
|
-
value: 'XXXL (46)',
|
|
662
|
-
},
|
|
663
|
-
];
|
|
581
|
+
options = options_1.womanClothingSizeOptions;
|
|
664
582
|
}
|
|
665
583
|
if (this.props.gender === 'Man') {
|
|
666
|
-
options =
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
{
|
|
672
|
-
label: 'XXS (42)',
|
|
673
|
-
value: 'XXS (42)',
|
|
674
|
-
},
|
|
675
|
-
{
|
|
676
|
-
label: 'XS (44)',
|
|
677
|
-
value: 'XS (44)',
|
|
678
|
-
},
|
|
679
|
-
{
|
|
680
|
-
label: 'S (46)',
|
|
681
|
-
value: 'S (46)',
|
|
682
|
-
},
|
|
683
|
-
{
|
|
684
|
-
label: 'M (48)',
|
|
685
|
-
value: 'M (48)',
|
|
686
|
-
},
|
|
687
|
-
{
|
|
688
|
-
label: 'L (50)',
|
|
689
|
-
value: 'L (50)',
|
|
690
|
-
},
|
|
691
|
-
{
|
|
692
|
-
label: 'XL (52)',
|
|
693
|
-
value: 'XL (52)',
|
|
694
|
-
},
|
|
695
|
-
{
|
|
696
|
-
label: 'XXL (54)',
|
|
697
|
-
value: 'XXL (54)',
|
|
698
|
-
},
|
|
699
|
-
{
|
|
700
|
-
label: 'XXXL (56)',
|
|
701
|
-
value: 'XXXL (56)',
|
|
702
|
-
},
|
|
703
|
-
];
|
|
584
|
+
options = options_1.manClothingSizeOptions;
|
|
585
|
+
}
|
|
586
|
+
if ((_m = (_l = this.opts) === null || _l === void 0 ? void 0 : _l.clothingSizes) === null || _m === void 0 ? void 0 : _m.length) {
|
|
587
|
+
const clothingSizesOptions = this.opts.clothingSizes.map((t) => ({ label: t, value: t }));
|
|
588
|
+
options = this.utilities.uniqObjArray(clothingSizesOptions, 'value');
|
|
704
589
|
}
|
|
705
590
|
hidden = this.props.productCategory !== 'Clothing' || this.props.productType === 'Jeans';
|
|
706
591
|
}
|
|
@@ -16,6 +16,14 @@ export const clothingSizeOptions: {
|
|
|
16
16
|
label: string;
|
|
17
17
|
value: string;
|
|
18
18
|
}[];
|
|
19
|
+
export const womanClothingSizeOptions: {
|
|
20
|
+
label: string;
|
|
21
|
+
value: string;
|
|
22
|
+
}[];
|
|
23
|
+
export const manClothingSizeOptions: {
|
|
24
|
+
label: string;
|
|
25
|
+
value: string;
|
|
26
|
+
}[];
|
|
19
27
|
export const sizeCommentOptions: {
|
|
20
28
|
label: string;
|
|
21
29
|
value: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
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.unisexShoes = exports.mensShoes = exports.shoes = exports.unisexClothing = exports.mensClothing = exports.clothing = exports.productCategories = exports.clothingMaterials = exports.shoeSizes = exports.jeanSizes = exports.gender = exports.conditions = exports.colors = exports.brands = exports.sizeCommentOptions = exports.clothingSizeOptions = exports.statusOptions = exports.publishTypeOptions = exports.availableForSaleOptions = void 0;
|
|
3
|
+
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.unisexShoes = exports.mensShoes = exports.shoes = exports.unisexClothing = exports.mensClothing = exports.clothing = exports.productCategories = exports.clothingMaterials = exports.shoeSizes = exports.jeanSizes = exports.gender = exports.conditions = exports.colors = exports.brands = exports.sizeCommentOptions = exports.manClothingSizeOptions = exports.womanClothingSizeOptions = exports.clothingSizeOptions = 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 = [
|
|
@@ -73,6 +73,84 @@ const clothingSizeOptions = [
|
|
|
73
73
|
},
|
|
74
74
|
];
|
|
75
75
|
exports.clothingSizeOptions = clothingSizeOptions;
|
|
76
|
+
const womanClothingSizeOptions = [
|
|
77
|
+
{
|
|
78
|
+
label: 'No Size',
|
|
79
|
+
value: 'No Size',
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
label: 'XXS (32)',
|
|
83
|
+
value: 'XXS (32)',
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
label: 'XS (34)',
|
|
87
|
+
value: 'XS (34)',
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
label: 'S (36)',
|
|
91
|
+
value: 'S (36)',
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
label: 'M (38)',
|
|
95
|
+
value: 'M (38)',
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
label: 'L (40)',
|
|
99
|
+
value: 'L (40)',
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
label: 'XL (42)',
|
|
103
|
+
value: 'XL (42)',
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
label: 'XXL (44)',
|
|
107
|
+
value: 'XXL (44)',
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
label: 'XXXL (46)',
|
|
111
|
+
value: 'XXXL (46)',
|
|
112
|
+
},
|
|
113
|
+
];
|
|
114
|
+
exports.womanClothingSizeOptions = womanClothingSizeOptions;
|
|
115
|
+
const manClothingSizeOptions = [
|
|
116
|
+
{
|
|
117
|
+
label: 'No Size',
|
|
118
|
+
value: 'No Size',
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
label: 'XXS (42)',
|
|
122
|
+
value: 'XXS (42)',
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
label: 'XS (44)',
|
|
126
|
+
value: 'XS (44)',
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
label: 'S (46)',
|
|
130
|
+
value: 'S (46)',
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
label: 'M (48)',
|
|
134
|
+
value: 'M (48)',
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
label: 'L (50)',
|
|
138
|
+
value: 'L (50)',
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
label: 'XL (52)',
|
|
142
|
+
value: 'XL (52)',
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
label: 'XXL (54)',
|
|
146
|
+
value: 'XXL (54)',
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
label: 'XXXL (56)',
|
|
150
|
+
value: 'XXXL (56)',
|
|
151
|
+
},
|
|
152
|
+
];
|
|
153
|
+
exports.manClothingSizeOptions = manClothingSizeOptions;
|
|
76
154
|
const sizeCommentOptions = [
|
|
77
155
|
{
|
|
78
156
|
label: 'Small in size',
|