rerobe-js-orm 2.4.70 → 2.4.74

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.
@@ -1,5 +1,5 @@
1
1
  import FormStateFactory from '../FormStateFactory';
2
2
  import ProductFormState from '../../../form-states/Product/ProductFormState';
3
3
  export default class ProductFormStateFactory extends FormStateFactory {
4
- createFormState(props?: CompleteProduct): ProductFormState;
4
+ createFormState(props?: CompleteProduct, opts?: any): ProductFormState;
5
5
  }
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const FormStateFactory_1 = require("../FormStateFactory");
4
4
  const ProductFormState_1 = require("../../../form-states/Product/ProductFormState");
5
5
  class ProductFormStateFactory extends FormStateFactory_1.default {
6
- createFormState(props) {
7
- return new ProductFormState_1.default(props);
6
+ createFormState(props, opts) {
7
+ return new ProductFormState_1.default(props, opts);
8
8
  }
9
9
  }
10
10
  exports.default = ProductFormStateFactory;
@@ -4,7 +4,7 @@ const FormStateFactory_1 = require("../FormStateFactory");
4
4
  const ProductCollectionFormState_1 = require("../../../form-states/ProductCollection/ProductCollectionFormState");
5
5
  class ProductCollectionFormStateFactory extends FormStateFactory_1.default {
6
6
  createFormState(props, opts) {
7
- return new ProductCollectionFormState_1.default(props);
7
+ return new ProductCollectionFormState_1.default(props, opts);
8
8
  }
9
9
  }
10
10
  exports.default = ProductCollectionFormStateFactory;
@@ -4,7 +4,7 @@ const OrderFactory_1 = require("./OrderFactory");
4
4
  const Order_1 = require("../../models/Order");
5
5
  class OrderFromFormState extends OrderFactory_1.default {
6
6
  createOrder(fs) {
7
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
7
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
8
8
  const currencyCode = fs.fields.currencyCode.inputValue || 'SEK';
9
9
  const customer = fs.fields.customer.selectedValue || {};
10
10
  const firstName = fs.fields.firstName.inputValue;
@@ -17,13 +17,14 @@ class OrderFromFormState extends OrderFactory_1.default {
17
17
  documentId: ((_c = fs.props) === null || _c === void 0 ? void 0 : _c.documentId) || '',
18
18
  name: ((_d = fs.props) === null || _d === void 0 ? void 0 : _d.name) || '',
19
19
  orderNumber: (_e = fs.props) === null || _e === void 0 ? void 0 : _e.orderNumber,
20
- state: ((_f = fs.props) === null || _f === void 0 ? void 0 : _f.state) || Order_1.default.ORDER_STATES.draft,
20
+ ribbnOrderNumber: (_f = fs.props) === null || _f === void 0 ? void 0 : _f.ribbnOrderNumber,
21
+ state: ((_g = fs.props) === null || _g === void 0 ? void 0 : _g.state) || Order_1.default.ORDER_STATES.draft,
21
22
  currencyCode: fs.fields.currencyCode.inputValue,
22
- statusUrl: ((_g = fs.props) === null || _g === void 0 ? void 0 : _g.statusUrl) || '',
23
- processedAt: ((_h = fs.props) === null || _h === void 0 ? void 0 : _h.processedAt) || new Date().toUTCString(),
23
+ statusUrl: ((_h = fs.props) === null || _h === void 0 ? void 0 : _h.statusUrl) || '',
24
+ processedAt: ((_j = fs.props) === null || _j === void 0 ? void 0 : _j.processedAt) || new Date().toUTCString(),
24
25
  financialStatus: fs.fields.financialStatus.selectedValue,
25
26
  fulfillmentStatus: fs.fields.fulfillmentStatus.selectedValue,
26
- fulfillments: ((_j = fs.props) === null || _j === void 0 ? void 0 : _j.fulfillments) || [],
27
+ fulfillments: ((_k = fs.props) === null || _k === void 0 ? void 0 : _k.fulfillments) || [],
27
28
  shippingAddress: fs.fields.shippingAddress.selectedValue || {
28
29
  id: '',
29
30
  address1: '',
@@ -34,7 +35,7 @@ class OrderFromFormState extends OrderFactory_1.default {
34
35
  province: '',
35
36
  zip: '',
36
37
  },
37
- shippingDiscountAllocations: ((_k = fs.props) === null || _k === void 0 ? void 0 : _k.shippingDiscountAllocations) || [],
38
+ shippingDiscountAllocations: ((_l = fs.props) === null || _l === void 0 ? void 0 : _l.shippingDiscountAllocations) || [],
38
39
  shippingLine: fs.fields.shippingLine
39
40
  ? fs.fields.shippingLine.selectedValue
40
41
  : {
@@ -55,9 +56,9 @@ class OrderFromFormState extends OrderFactory_1.default {
55
56
  originalTotalPrice: { amount: fs.fields.originalTotalPrice.inputValue || 0, currencyCode },
56
57
  lineItems: fs.fields.lineItems.selectedValues || [],
57
58
  cancelReason: fs.fields.cancelReason.selectedValue || '',
58
- canceledAt: ((_l = fs.props) === null || _l === void 0 ? void 0 : _l.canceledAt) || '',
59
- customerUrl: ((_m = fs.props) === null || _m === void 0 ? void 0 : _m.customerUrl) || '',
60
- discountApplications: ((_o = fs.props) === null || _o === void 0 ? void 0 : _o.discountApplications) || [],
59
+ canceledAt: ((_m = fs.props) === null || _m === void 0 ? void 0 : _m.canceledAt) || '',
60
+ customerUrl: ((_o = fs.props) === null || _o === void 0 ? void 0 : _o.customerUrl) || '',
61
+ discountApplications: ((_p = fs.props) === null || _p === void 0 ? void 0 : _p.discountApplications) || [],
61
62
  physicalLocation: fs.fields.physicalLocation.selectedValue || {
62
63
  id: '',
63
64
  activatable: true,
@@ -76,7 +77,7 @@ class OrderFromFormState extends OrderFactory_1.default {
76
77
  },
77
78
  notes: fs.fields.notes.inputValue || '',
78
79
  userId: (customer === null || customer === void 0 ? void 0 : customer.uid) || '',
79
- customerName: ((_p = fs.props) === null || _p === void 0 ? void 0 : _p.customerName) ||
80
+ customerName: ((_q = fs.props) === null || _q === void 0 ? void 0 : _q.customerName) ||
80
81
  (customer.displayName ? customer.displayName : '') ||
81
82
  (customer.firstName && customer.lastName ? `${customer.firstName} ${customer.lastName}` : '') ||
82
83
  (firstName && lastName ? `${firstName} ${lastName}` : ''),
@@ -84,9 +85,9 @@ class OrderFromFormState extends OrderFactory_1.default {
84
85
  phone: (customer === null || customer === void 0 ? void 0 : customer.phone) || fs.fields.phone.inputValue || '',
85
86
  paymentMethod: fs.fields.paymentMethod.selectedValue || '',
86
87
  paymentDetails: fs.fields.paymentDetails.selectedValue || {},
87
- merchantId: ((_q = fs.props) === null || _q === void 0 ? void 0 : _q.merchantId) || '',
88
+ merchantId: ((_r = fs.props) === null || _r === void 0 ? void 0 : _r.merchantId) || '',
88
89
  tags: fs.fields.tags.selectedValues || [],
89
- refunds: ((_r = fs.props) === null || _r === void 0 ? void 0 : _r.refunds) || [],
90
+ refunds: ((_s = fs.props) === null || _s === void 0 ? void 0 : _s.refunds) || [],
90
91
  };
91
92
  return new Order_1.default(Object.assign({}, orderAttributes));
92
93
  }
@@ -46,6 +46,7 @@ class ProductFromFormState extends ProductFactory_1.default {
46
46
  shoeSize: props.fields.shoeSize.selectedValue,
47
47
  measurements: props.fields.measurements.selectedValue || {},
48
48
  featuredCollections: props.fields.featuredCollections.selectedValues || [],
49
+ tags: props.fields.tags.selectedValues || [],
49
50
  };
50
51
  const consignmentAttributes = {
51
52
  previousSellers: props.fields.previousSellers.selectedValues,
@@ -3,7 +3,13 @@ import Product from '../../models/Product';
3
3
  export default class ProductFormState extends FormState {
4
4
  fields: ProductFormFields;
5
5
  props: CompleteProduct;
6
- constructor(props?: any);
6
+ opts: {
7
+ featuredCollectionOpts: {
8
+ label: string;
9
+ value: string;
10
+ }[];
11
+ };
12
+ constructor(props?: any, opts?: any);
7
13
  autoCreateTitle(): string;
8
14
  autoCreateDescription(): string;
9
15
  createProduct(): Product;
@@ -5,9 +5,10 @@ const options_1 = require("./options");
5
5
  const Product_1 = require("../../models/Product");
6
6
  const ProductFromFormState_1 = require("../../factories/Product/ProductFromFormState");
7
7
  class ProductFormState extends FormState_1.default {
8
- constructor(props) {
8
+ constructor(props, opts) {
9
9
  super();
10
10
  this.props = new Product_1.default(props).toObj();
11
+ this.opts = opts;
11
12
  // ProductAttributesFormFields
12
13
  this.fields.availableForSale = this.fieldFactory('singleSelect', 'availableForSale', options_1.availableForSaleOptions);
13
14
  this.fields.description = this.fieldFactory('textInput', 'description');
@@ -71,6 +72,7 @@ class ProductFormState extends FormState_1.default {
71
72
  this.fields.rfidTag = this.fieldFactory('textInput', 'rfidTag');
72
73
  this.fields.locationIds = this.fieldFactory('multiSelect', 'locationIds');
73
74
  this.fields.featuredCollections = this.fieldFactory('multiSelect', 'featuredCollections');
75
+ this.fields.tags = this.fieldFactory('multiSelect', 'tags');
74
76
  }
75
77
  autoCreateTitle() {
76
78
  return this.createProduct().autoCreateTitle();
@@ -508,6 +510,23 @@ class ProductFormState extends FormState_1.default {
508
510
  }
509
511
  hidden = this.props.productStyle.length < 1;
510
512
  }
513
+ if (fieldKey === 'tags') {
514
+ if (this.props.tags && Array.isArray(this.props.tags) && this.props.tags.length > 0) {
515
+ this.props.tags.forEach((tag) => {
516
+ if (!options.map((o) => o.value).includes(tag)) {
517
+ options.splice(0, 0, { label: tag, value: tag });
518
+ }
519
+ });
520
+ }
521
+ hidden = Boolean(this.props.tags && Array.isArray(this.props.tags) && this.props.tags.length < 1);
522
+ }
523
+ if (fieldKey === 'featuredCollections') {
524
+ if (this.opts && this.opts.featuredCollectionOpts && this.opts.featuredCollectionOpts.length > 0) {
525
+ options = this.utilities
526
+ .uniqObjArray([...options, ...this.opts.featuredCollectionOpts.map((o) => ({ label: o.label, value: o.value }))], 'value')
527
+ .filter((o) => { var _a; return !((_a = this.props.featuredCollections) === null || _a === void 0 ? void 0 : _a.includes(o.value)); });
528
+ }
529
+ }
511
530
  if (fieldKey === 'clothingSize') {
512
531
  if (this.props.gender === 'Woman') {
513
532
  options = [
@@ -50,6 +50,7 @@ class Product extends Base_1.default {
50
50
  condition: (props === null || props === void 0 ? void 0 : props.condition) || '',
51
51
  measurements: (props === null || props === void 0 ? void 0 : props.measurements) || {},
52
52
  featuredCollections: (props === null || props === void 0 ? void 0 : props.featuredCollections) || [],
53
+ tags: (props === null || props === void 0 ? void 0 : props.tags) || [],
53
54
  };
54
55
  this.consignmentAttributes = {
55
56
  sellRequestImageUrls: (props === null || props === void 0 ? void 0 : props.sellRequestImageUrls) || [],
@@ -39,6 +39,7 @@ declare type ProductFilterAttributes = {
39
39
  shoeSize: string;
40
40
  measurements: Measurements;
41
41
  featuredCollections?: string[];
42
+ tags?: string[];
42
43
  };
43
44
  declare type ProductConsignmentAttributes = {
44
45
  sellRequestImageUrls: string[];
@@ -138,6 +139,7 @@ declare type ProductFilterAttributesFormFields = {
138
139
  productStyle: MultiSelectFormField<string>;
139
140
  shoeSize: SingleSelectFormField<string>;
140
141
  featuredCollections: MultiSelectFormField<string>;
142
+ tags: MultiSelectFormField<string>;
141
143
  };
142
144
  declare type ProductConsignmentAttributesFormFields = {
143
145
  previousSellers: MultiSelectFormField<string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rerobe-js-orm",
3
- "version": "2.4.70",
3
+ "version": "2.4.74",
4
4
  "description": "ReRobe's Javascript ORM Framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -14,7 +14,8 @@
14
14
  "prepublishOnly": "npm test && npm run lint",
15
15
  "preversion": "npm run lint",
16
16
  "version": "npm run format && git add -A src",
17
- "postversion": "git push && git push --tags"
17
+ "postversion": "git push && git push --tags",
18
+ "clean": "npm run format && npm run lint"
18
19
  },
19
20
  "repository": {
20
21
  "type": "git",