@evershop/evershop 1.0.0 → 1.1.0
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/bin/build/client/index.js +1 -1
- package/bin/build/complie.js +1 -1
- package/bin/build/index.js +1 -1
- package/bin/build/server/index.js +1 -1
- package/bin/build/server/useDDL.js +1 -1
- package/bin/dev/index.js +2 -1
- package/bin/evershop +8 -7
- package/bin/extension/index.js +1 -1
- package/bin/install/index.js +1 -1
- package/bin/lib/addDefaultMiddlewareFuncs.js +2 -2
- package/bin/lib/app.js +1 -1
- package/bin/lib/bootstrap/migrate.js +1 -1
- package/bin/lib/buildEntry.js +1 -1
- package/bin/lib/onError.js +1 -1
- package/bin/lib/onListening.js +1 -1
- package/bin/lib/startUp.js +10 -9
- package/bin/lib/watch/watchComponents.js +16 -26
- package/bin/lib/watch/watchMF.js +1 -1
- package/bin/lib/watch/watchMR.js +1 -1
- package/bin/lib/watch/watchSchema.js +1 -1
- package/bin/user/changePassword.js +1 -1
- package/bin/user/create.js +1 -1
- package/package.json +2 -2
- package/src/components/admin/catalog/productEdit/category/CategoryItem.jsx +1 -1
- package/src/components/admin/catalog/productEdit/category/CategoryTree.jsx +1 -1
- package/src/components/admin/catalog/productEdit/variants/CreateVariantGroup.jsx +3 -8
- package/src/components/admin/catalog/productEdit/variants/Variant.jsx +1 -1
- package/src/components/admin/catalog/productEdit/variants/VariantModal.jsx +62 -6
- package/src/components/admin/catalog/productEdit/variants/Variants.jsx +1 -1
- package/src/components/admin/checkout/shippingSetting/Method.jsx +130 -0
- package/src/components/admin/{oms → checkout}/shippingSetting/MethodForm.jsx +124 -13
- package/src/components/admin/{oms → checkout}/shippingSetting/Methods.jsx +2 -2
- package/src/components/admin/checkout/shippingSetting/PriceBasedPrice.jsx +101 -0
- package/src/components/admin/checkout/shippingSetting/WeightBasedPrice.jsx +101 -0
- package/src/components/admin/{oms → checkout}/shippingSetting/Zone.jsx +34 -4
- package/src/components/admin/{oms → checkout}/shippingSetting/Zones.jsx +6 -3
- package/src/components/admin/promotion/couponEdit/AttributeGroupSelector.jsx +5 -5
- package/src/components/admin/promotion/couponEdit/CategorySelector.jsx +5 -5
- package/src/components/admin/promotion/couponEdit/CollectionSelector.jsx +5 -5
- package/src/components/admin/promotion/couponEdit/ProductSkuSelector.jsx +27 -6
- package/src/components/common/context/checkout.jsx +8 -14
- package/src/components/common/form/Field.jsx +1 -1
- package/src/components/common/form/fields/Input.jsx +2 -1
- package/src/components/common/form/validator.js +6 -2
- package/src/components/common/grid/headers/Dummy.jsx +1 -1
- package/src/components/common/grid/headers/Sortable.jsx +148 -0
- package/src/components/common/grid/rows/StatusRow.jsx +1 -1
- package/src/components/common/list/Filter.jsx +83 -0
- package/src/components/common/list/Filter.scss +39 -0
- package/src/components/frontStore/catalog/categoryView/filter/AttributeFilter.jsx +19 -5
- package/src/components/frontStore/catalog/categoryView/filter/CategoryFilter.jsx +59 -52
- package/src/components/frontStore/catalog/categoryView/filter/PriceFilter.jsx +20 -11
- package/src/components/frontStore/catalog/product/list/SortOptions.jsx +4 -2
- package/src/components/frontStore/catalog/product/list/Sorting.jsx +5 -5
- package/src/components/frontStore/checkout/checkout/payment/paymentStep/StepContent.jsx +9 -6
- package/src/components/frontStore/stripe/checkout/CheckoutForm.jsx +8 -4
- package/src/lib/event/callSubscibers.js +14 -11
- package/src/lib/event/event-manager.js +1 -1
- package/src/lib/event/loadSubscribers.js +2 -2
- package/src/lib/helpers.js +3 -1
- package/src/lib/log/CustomColorize.js +22 -0
- package/src/lib/log/logger.js +153 -19
- package/src/lib/middleware/Handler.js +2 -3
- package/src/lib/middleware/async.js +5 -9
- package/src/lib/middleware/sync.js +5 -10
- package/src/lib/middleware/tests/app/app.js +1 -1
- package/src/lib/router/buildAbsoluteUrl.js +1 -1
- package/src/lib/util/buildFilterFromUrl.js +31 -64
- package/src/lib/util/defaultPaginationFilters.js +102 -0
- package/src/lib/util/filterOperationMapp.js +16 -0
- package/src/lib/util/registry.js +44 -6
- package/src/lib/webpack/dev/createConfigClient.js +2 -0
- package/src/lib/webpack/loaders/AreaLoader.js +1 -1
- package/src/lib/webpack/loaders/loadTranslationFromCsv.js +1 -1
- package/src/lib/webpack/plugins/Tailwindcss.js +1 -1
- package/src/modules/auth/graphql/types/AdminUser/AdminUser.admin.resolvers.js +6 -6
- package/src/modules/auth/pages/admin/adminLogin/LoginForm.jsx +1 -15
- package/src/modules/base/api/global/[apiResponse]apiErrorHandler.js +2 -2
- package/src/modules/base/pages/global/[response]errorHandler.js +2 -2
- package/src/modules/catalog/api/addProductToCategory/addProducts.js +1 -1
- package/src/modules/catalog/api/addProductToCollection/addProducts.js +35 -22
- package/src/modules/catalog/api/removeProductFromCollection/removeProducts.js +20 -5
- package/src/modules/catalog/bootstrap.js +63 -0
- package/src/modules/catalog/graphql/types/Attribute/Attribute.admin.graphql +2 -2
- package/src/modules/catalog/graphql/types/Attribute/Attribute.admin.resolvers.js +48 -276
- package/src/modules/catalog/graphql/types/Category/Category.graphql +15 -2
- package/src/modules/catalog/graphql/types/Category/Category.resolvers.js +2 -2
- package/src/modules/catalog/graphql/types/Collection/Collection.resolvers.js +2 -2
- package/src/modules/catalog/graphql/types/Product/Product.resolvers.js +1 -1
- package/src/modules/catalog/graphql/types/Product/Variant/Variant.graphql +2 -2
- package/src/modules/catalog/graphql/types/Product/Variant/Variant.resolvers.js +68 -92
- package/src/modules/catalog/pages/admin/attributeEdit+attributeNew/General.jsx +13 -9
- package/src/modules/catalog/pages/admin/attributeGrid/Grid.jsx +82 -39
- package/src/modules/catalog/pages/admin/attributeGrid/index.js +1 -1
- package/src/modules/catalog/pages/admin/categoryEdit/Products.jsx +5 -5
- package/src/modules/catalog/pages/admin/categoryGrid/Grid.jsx +48 -16
- package/src/modules/catalog/pages/admin/categoryGrid/index.js +1 -1
- package/src/modules/catalog/pages/admin/collectionEdit/Products.jsx +5 -5
- package/src/modules/catalog/pages/admin/collectionGrid/Grid.jsx +46 -5
- package/src/modules/catalog/pages/admin/collectionGrid/index.js +1 -1
- package/src/modules/catalog/pages/admin/productEdit+productNew/Attributes.jsx +28 -24
- package/src/modules/catalog/pages/admin/productGrid/Grid.jsx +158 -26
- package/src/modules/catalog/pages/admin/productGrid/index.js +1 -2
- package/src/modules/catalog/pages/frontStore/all/SearchBox.jsx +2 -1
- package/src/modules/catalog/pages/frontStore/catalogSearch/[index]filters.js +4 -59
- package/src/modules/catalog/pages/frontStore/catalogSearch/index.js +11 -0
- package/src/modules/catalog/pages/frontStore/categoryView/Filter.jsx +22 -6
- package/src/modules/catalog/pages/frontStore/categoryView/Filter.scss +2 -0
- package/src/modules/catalog/pages/frontStore/categoryView/[index]filters.js +5 -105
- package/src/modules/catalog/pages/frontStore/homepage/FeaturedProducts.jsx +1 -1
- package/src/modules/catalog/pages/frontStore/productView/Form.jsx +8 -3
- package/src/modules/catalog/pages/frontStore/productView/Variants.jsx +102 -40
- package/src/modules/catalog/services/AttributeCollection.js +59 -0
- package/src/modules/catalog/services/AttributeGroupCollection.js +100 -0
- package/src/modules/catalog/services/CategoryCollection.js +27 -84
- package/src/modules/catalog/services/CollectionCollection.js +24 -72
- package/src/modules/catalog/services/ProductCollection.js +50 -216
- package/src/modules/catalog/services/attribute/deleteProductAttribute.js +15 -0
- package/src/modules/catalog/services/getAttributeGroupsBaseQuery.js +3 -0
- package/src/modules/catalog/services/getAttributesBaseQuery.js +3 -0
- package/src/modules/catalog/services/getCollectionsBaseQuery.js +0 -1
- package/src/modules/catalog/services/product/updateProduct.js +8 -2
- package/src/modules/catalog/services/registerDefaultAttributeCollectionFilters.js +149 -0
- package/src/modules/catalog/services/registerDefaultCategoryCollectionFilters.js +85 -0
- package/src/modules/catalog/services/registerDefaultCollectionCollectionFilters.js +65 -0
- package/src/modules/catalog/services/registerDefaultProductCollectionFilters.js +219 -0
- package/src/modules/catalog/subscribers/category_created/buildUrlRewrite.js +1 -1
- package/src/modules/catalog/subscribers/category_deleted/deleteUrlRewrite.js +1 -1
- package/src/modules/catalog/subscribers/category_updated/builUrlRewrite.js +1 -1
- package/src/modules/catalog/subscribers/product_created/builUrlRewrite.js +1 -1
- package/src/modules/catalog/subscribers/product_deleted/deleteUrlRewrite.js +1 -1
- package/src/modules/catalog/subscribers/product_image_added/localGenerateProductImageVariant.js +3 -3
- package/src/modules/checkout/api/addCartShippingMethod/saveShippingMethod.js +6 -1
- package/src/modules/checkout/api/createCart/[context]bodyParser[auth].js +5 -0
- package/src/modules/checkout/api/createCart/createNewCart.js +92 -0
- package/src/modules/checkout/api/createCart/payloadSchema.json +44 -0
- package/src/modules/checkout/api/createCart/route.json +5 -0
- package/src/modules/checkout/api/deleteShippingZone/deleteShippingZone.js +58 -0
- package/src/modules/checkout/api/deleteShippingZone/route.json +5 -0
- package/src/modules/checkout/api/deleteShippingZoneMethod/deleteShippingZoneMethod.js +85 -0
- package/src/modules/checkout/api/deleteShippingZoneMethod/route.json +5 -0
- package/src/modules/checkout/api/getShippingMethods/sendMethods.js +37 -0
- package/src/modules/checkout/api/updateShippingMethod/[context]borderParser[auth].js +5 -0
- package/src/modules/checkout/api/updateShippingMethod/payloadSchema.json +12 -0
- package/src/modules/checkout/api/updateShippingMethod/route.json +5 -0
- package/src/modules/checkout/api/updateShippingMethod/updateShippingMethod.js +64 -0
- package/src/modules/checkout/api/updateShippingZoneMethod/payloadSchema.json +43 -1
- package/src/modules/checkout/api/updateShippingZoneMethod/updateShippingZoneMethod.js +17 -3
- package/src/modules/checkout/bootstrap.js +1 -1
- package/src/modules/checkout/graphql/types/ShippingMethod/ShippingMethod.graphql +1 -0
- package/src/modules/checkout/graphql/types/ShippingMethod/ShippingMethod.resolvers.js +4 -0
- package/src/modules/checkout/graphql/types/ShippingZone/ShippingZone.graphql +21 -1
- package/src/modules/checkout/graphql/types/ShippingZone/ShippingZone.resolvers.js +34 -4
- package/src/modules/checkout/graphql/types/Weight/Weight.resolvers.js +8 -11
- package/src/modules/checkout/migration/Version-1.0.5.js +28 -0
- package/src/modules/{oms → checkout}/pages/admin/shippingSetting/ShippingSetting.jsx +66 -43
- package/src/modules/checkout/pages/frontStore/all/[auth]addCustomerToCart.js +3 -3
- package/src/modules/checkout/pages/frontStore/checkout/PaymentStep.jsx +3 -2
- package/src/modules/checkout/pages/frontStore/checkout/ShippingMethods.jsx +23 -10
- package/src/modules/checkout/pages/frontStore/checkout/SummaryMobile.jsx +132 -0
- package/src/modules/checkout/pages/frontStore/checkout/SummaryMobile.scss +7 -0
- package/src/modules/checkout/services/cart/Cart.js +23 -7
- package/src/modules/checkout/services/cart/DataObject.js +3 -3
- package/src/modules/checkout/services/cart/registerCartBaseFields.js +32 -0
- package/src/modules/checkout/services/cart/registerCartItemBaseFields.js +3 -2
- package/src/modules/cms/bootstrap.js +17 -0
- package/src/modules/cms/graphql/types/CmsPage/CmsPage.resolvers.js +2 -11
- package/src/modules/cms/pages/admin/all/Layout.scss +3 -2
- package/src/modules/cms/pages/admin/all/SearchBox.jsx +1 -1
- package/src/modules/cms/pages/admin/cmsPageGrid/Grid.jsx +62 -9
- package/src/modules/cms/pages/admin/cmsPageGrid/index.js +1 -2
- package/src/modules/cms/services/CMSPageCollection.js +23 -70
- package/src/modules/cms/services/registerDefaultPageCollectionFilters.js +62 -0
- package/src/modules/cms/services/tailwind.admin.config.js +6 -1
- package/src/modules/customer/api/createCustomer/[bodyParser]createCustomer.js +2 -2
- package/src/modules/customer/api/resetPassword/[bodyParser]resetPassword.js +2 -2
- package/src/modules/customer/api/updatePassword/[bodyParser]updatePassword.js +2 -2
- package/src/modules/customer/bootstrap.js +29 -0
- package/src/modules/customer/graphql/types/Customer/Customer.admin.resolvers.js +2 -4
- package/src/modules/customer/pages/admin/customerGrid/Grid.jsx +108 -14
- package/src/modules/customer/pages/admin/customerGrid/index.js +1 -2
- package/src/modules/customer/pages/frontStore/login/LoginForm.jsx +0 -1
- package/src/modules/customer/services/CustomerCollection.js +23 -104
- package/src/modules/customer/services/CustomerGroupCollection.js +21 -70
- package/src/modules/customer/services/registerDefaultCustomerCollectionFilters.js +90 -0
- package/src/modules/customer/services/registerDefaultCustomerGroupCollectionFilters.js +50 -0
- package/src/modules/graphql/pages/global/[bodyParser]buildQuery[graphql].js +1 -1
- package/src/modules/graphql/pages/global/[buildQuery]graphql[notification].js +1 -1
- package/src/modules/graphql/services/graphqlMiddleware.js +1 -1
- package/src/modules/oms/bootstrap.js +17 -0
- package/src/modules/oms/graphql/types/Order/Order.admin.resolvers.js +1 -1
- package/src/modules/oms/graphql/types/Order/Order.resolvers.js +2 -1
- package/src/modules/oms/pages/admin/orderGrid/Grid.jsx +152 -51
- package/src/modules/oms/pages/admin/orderGrid/index.js +1 -2
- package/src/modules/oms/services/OrderCollection.js +19 -139
- package/src/modules/oms/services/registerDefaultOrderCollectionFilters.js +121 -0
- package/src/modules/promotion/bootstrap.js +16 -0
- package/src/modules/promotion/graphql/types/Coupon/Coupon.admin.resolvers.js +2 -7
- package/src/modules/promotion/pages/admin/couponGrid/Grid.jsx +157 -33
- package/src/modules/promotion/pages/admin/couponGrid/index.js +1 -2
- package/src/modules/promotion/services/CouponCollection.js +21 -130
- package/src/modules/promotion/services/registerDefaultCouponCollectionFilters.js +72 -0
- package/src/modules/stripe/api/stripeWebHook/[bodyJson]webhook.js +4 -2
- package/src/modules/tax/bootstrap.js +17 -0
- package/src/modules/tax/services/TaxClassCollection.js +22 -56
- package/src/modules/tax/services/registerDefaultTaxClassCollectionFilters.js +49 -0
- package/src/components/admin/oms/shippingSetting/Method.jsx +0 -73
- package/src/components/common/grid/headers/Basic.jsx +0 -55
- package/src/lib/log/debuger.js +0 -89
- package/src/modules/customer/pages/frontStore/login/LoginButton.jsx +0 -27
- /package/src/components/admin/{oms → checkout}/shippingSetting/ZoneForm.jsx +0 -0
- /package/src/modules/{oms → checkout}/pages/admin/all/ShippingSettingMenu.jsx +0 -0
- /package/src/modules/{oms → checkout}/pages/admin/shippingSetting/index.js +0 -0
- /package/src/modules/{oms → checkout}/pages/admin/shippingSetting/route.json +0 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Items } from '@components/frontStore/checkout/checkout/summary/Items';
|
|
4
|
+
import { CartSummary } from '@components/frontStore/checkout/checkout/summary/Cart';
|
|
5
|
+
import Area from '@components/common/Area';
|
|
6
|
+
import './SummaryMobile.scss';
|
|
7
|
+
|
|
8
|
+
export default function Summary({
|
|
9
|
+
cart,
|
|
10
|
+
setting: { displayCheckoutPriceIncludeTax }
|
|
11
|
+
}) {
|
|
12
|
+
return (
|
|
13
|
+
<Area
|
|
14
|
+
id="checkoutSummary"
|
|
15
|
+
className="checkout-summary checkout__summary__mobile md:hidden divide-y border rounded border-divider px-2 mb-2"
|
|
16
|
+
coreComponents={[
|
|
17
|
+
{
|
|
18
|
+
component: { default: Items },
|
|
19
|
+
props: { items: cart.items, displayCheckoutPriceIncludeTax },
|
|
20
|
+
sortOrder: 20,
|
|
21
|
+
id: 'checkoutOrderSummaryItems'
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
component: { default: CartSummary },
|
|
25
|
+
props: { ...cart, displayCheckoutPriceIncludeTax },
|
|
26
|
+
sortOrder: 30,
|
|
27
|
+
id: 'checkoutOrderSummaryCart'
|
|
28
|
+
}
|
|
29
|
+
]}
|
|
30
|
+
/>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
Summary.propTypes = {
|
|
35
|
+
cart: PropTypes.shape({
|
|
36
|
+
items: PropTypes.arrayOf(
|
|
37
|
+
PropTypes.shape({
|
|
38
|
+
thumbnail: PropTypes.string,
|
|
39
|
+
productName: PropTypes.string,
|
|
40
|
+
variantOptions: PropTypes.string,
|
|
41
|
+
qty: PropTypes.number,
|
|
42
|
+
total: PropTypes.shape({
|
|
43
|
+
text: PropTypes.string
|
|
44
|
+
}),
|
|
45
|
+
subTotal: PropTypes.shape({
|
|
46
|
+
text: PropTypes.string
|
|
47
|
+
})
|
|
48
|
+
})
|
|
49
|
+
),
|
|
50
|
+
totalQty: PropTypes.number,
|
|
51
|
+
subTotal: PropTypes.shape({
|
|
52
|
+
text: PropTypes.string
|
|
53
|
+
}),
|
|
54
|
+
subTotalInclTax: PropTypes.shape({
|
|
55
|
+
text: PropTypes.string
|
|
56
|
+
}),
|
|
57
|
+
grandTotal: PropTypes.shape({
|
|
58
|
+
text: PropTypes.string
|
|
59
|
+
}),
|
|
60
|
+
discountAmount: PropTypes.shape({
|
|
61
|
+
text: PropTypes.string
|
|
62
|
+
}),
|
|
63
|
+
taxAmount: PropTypes.shape({
|
|
64
|
+
text: PropTypes.string
|
|
65
|
+
}),
|
|
66
|
+
shippingFeeInclTax: PropTypes.shape({
|
|
67
|
+
text: PropTypes.string
|
|
68
|
+
}),
|
|
69
|
+
shippingMethodName: PropTypes.string,
|
|
70
|
+
coupon: PropTypes.string
|
|
71
|
+
}).isRequired,
|
|
72
|
+
setting: PropTypes.shape({
|
|
73
|
+
displayCheckoutPriceIncludeTax: PropTypes.bool
|
|
74
|
+
}).isRequired
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const layout = {
|
|
78
|
+
areaId: 'beforePlaceOrderButton',
|
|
79
|
+
sortOrder: 10
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const query = `
|
|
83
|
+
query Query {
|
|
84
|
+
cart {
|
|
85
|
+
totalQty
|
|
86
|
+
subTotal {
|
|
87
|
+
value
|
|
88
|
+
text
|
|
89
|
+
}
|
|
90
|
+
subTotalInclTax {
|
|
91
|
+
value
|
|
92
|
+
text
|
|
93
|
+
}
|
|
94
|
+
grandTotal {
|
|
95
|
+
value
|
|
96
|
+
text
|
|
97
|
+
}
|
|
98
|
+
discountAmount {
|
|
99
|
+
value
|
|
100
|
+
text
|
|
101
|
+
}
|
|
102
|
+
taxAmount {
|
|
103
|
+
value
|
|
104
|
+
text
|
|
105
|
+
}
|
|
106
|
+
shippingFeeInclTax {
|
|
107
|
+
value
|
|
108
|
+
text
|
|
109
|
+
}
|
|
110
|
+
shippingMethodName
|
|
111
|
+
coupon
|
|
112
|
+
items {
|
|
113
|
+
thumbnail
|
|
114
|
+
productName
|
|
115
|
+
productSku
|
|
116
|
+
qty
|
|
117
|
+
variantOptions
|
|
118
|
+
total {
|
|
119
|
+
value
|
|
120
|
+
text
|
|
121
|
+
}
|
|
122
|
+
subTotal {
|
|
123
|
+
value
|
|
124
|
+
text
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
setting {
|
|
129
|
+
displayCheckoutPriceIncludeTax
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
`;
|
|
@@ -6,7 +6,10 @@ const {
|
|
|
6
6
|
} = require('@evershop/evershop/src/lib/util/registry');
|
|
7
7
|
const { select } = require('@evershop/postgres-query-builder');
|
|
8
8
|
const { pool } = require('@evershop/evershop/src/lib/postgres/connection');
|
|
9
|
-
const { v4: uuidv4 } = require('uuid');
|
|
9
|
+
const { v4: uuidv4, validate } = require('uuid');
|
|
10
|
+
const {
|
|
11
|
+
translate
|
|
12
|
+
} = require('@evershop/evershop/src/lib/locale/translate/translate');
|
|
10
13
|
const { DataObject } = require('./DataObject');
|
|
11
14
|
const {
|
|
12
15
|
getProductsBaseQuery
|
|
@@ -62,6 +65,12 @@ class Cart extends DataObject {
|
|
|
62
65
|
return this.getData('items') ?? [];
|
|
63
66
|
}
|
|
64
67
|
|
|
68
|
+
/**
|
|
69
|
+
*
|
|
70
|
+
* @param {string} productID | product_id, sku, or uuid
|
|
71
|
+
* @param {number} qty
|
|
72
|
+
* @returns
|
|
73
|
+
*/
|
|
65
74
|
async addItem(productID, qty) {
|
|
66
75
|
const item = await this.createItem(productID, parseInt(qty, 10));
|
|
67
76
|
if (item.hasError()) {
|
|
@@ -87,7 +96,7 @@ class Cart extends DataObject {
|
|
|
87
96
|
if (!duplicateItem) {
|
|
88
97
|
items = items.concat(item);
|
|
89
98
|
}
|
|
90
|
-
await this.setData('items', items);
|
|
99
|
+
await this.setData('items', items, true);
|
|
91
100
|
return duplicateItem || item;
|
|
92
101
|
}
|
|
93
102
|
}
|
|
@@ -115,14 +124,21 @@ class Cart extends DataObject {
|
|
|
115
124
|
throw new Error('Invalid quantity');
|
|
116
125
|
}
|
|
117
126
|
const productQuery = getProductsBaseQuery();
|
|
118
|
-
|
|
119
|
-
.where('
|
|
120
|
-
|
|
127
|
+
if (validate(productID)) {
|
|
128
|
+
productQuery.where('product.uuid', '=', productID);
|
|
129
|
+
} else if (/^\d+$/.test(productID)) {
|
|
130
|
+
productQuery
|
|
131
|
+
.where('product.product_id', '=', productID)
|
|
132
|
+
.or('product.sku', '=', productID);
|
|
133
|
+
} else {
|
|
134
|
+
productQuery.where('product.sku', '=', productID);
|
|
135
|
+
}
|
|
136
|
+
const product = await productQuery.load(pool);
|
|
121
137
|
if (!product) {
|
|
122
|
-
throw new Error('Product not found');
|
|
138
|
+
throw new Error(translate('Product not found'));
|
|
123
139
|
}
|
|
124
140
|
const item = new Item(this, {
|
|
125
|
-
product_id:
|
|
141
|
+
product_id: product.product_id,
|
|
126
142
|
qty
|
|
127
143
|
});
|
|
128
144
|
await item.build();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable no-underscore-dangle */
|
|
2
2
|
const isEqualWith = require('lodash/isEqualWith');
|
|
3
|
-
const { error } = require('@evershop/evershop/src/lib/log/
|
|
3
|
+
const { error } = require('@evershop/evershop/src/lib/log/logger');
|
|
4
4
|
|
|
5
5
|
module.exports.DataObject = class DataObject {
|
|
6
6
|
#fields;
|
|
@@ -80,7 +80,7 @@ module.exports.DataObject = class DataObject {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
async setData(key, value) {
|
|
83
|
+
async setData(key, value, force = false) {
|
|
84
84
|
this.#triggeredField = key;
|
|
85
85
|
this.#requestedValue = value;
|
|
86
86
|
if (this.isBuilding === true) {
|
|
@@ -91,7 +91,7 @@ module.exports.DataObject = class DataObject {
|
|
|
91
91
|
throw new Error(`Field ${key} not existed`);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
if (isEqualWith(this.#data[key], value)) {
|
|
94
|
+
if (isEqualWith(this.#data[key], value) && !force) {
|
|
95
95
|
return value;
|
|
96
96
|
}
|
|
97
97
|
|
|
@@ -262,6 +262,7 @@ module.exports.registerCartBaseFields = function registerCartBaseFields() {
|
|
|
262
262
|
);
|
|
263
263
|
shippingMethodQuery
|
|
264
264
|
.where('uuid', '=', shippingMethod)
|
|
265
|
+
.and('is_enabled', '=', true)
|
|
265
266
|
.and(
|
|
266
267
|
'shipping_zone_method.zone_id',
|
|
267
268
|
'=',
|
|
@@ -383,6 +384,37 @@ module.exports.registerCartBaseFields = function registerCartBaseFields() {
|
|
|
383
384
|
this.setError('shipping_fee_excl_tax', response.data.message);
|
|
384
385
|
return 0;
|
|
385
386
|
}
|
|
387
|
+
} else if (shippingMethod.weight_based_cost) {
|
|
388
|
+
const totalWeight = this.getData('total_weight');
|
|
389
|
+
const weightBasedCost = shippingMethod.weight_based_cost
|
|
390
|
+
.map(({ min_weight, cost }) => ({
|
|
391
|
+
min_weight: parseFloat(min_weight),
|
|
392
|
+
cost: toPrice(cost)
|
|
393
|
+
}))
|
|
394
|
+
.sort((a, b) => a.min_weight - b.min_weight);
|
|
395
|
+
|
|
396
|
+
let cost = 0;
|
|
397
|
+
for (let i = 0; i < weightBasedCost.length; i += 1) {
|
|
398
|
+
if (totalWeight >= weightBasedCost[i].min_weight) {
|
|
399
|
+
cost = weightBasedCost[i].cost;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
return toPrice(cost);
|
|
403
|
+
} else if (shippingMethod.price_based_cost) {
|
|
404
|
+
const subTotal = this.getData('sub_total');
|
|
405
|
+
const priceBasedCost = shippingMethod.price_based_cost
|
|
406
|
+
.map(({ min_price, cost }) => ({
|
|
407
|
+
min_price: toPrice(min_price),
|
|
408
|
+
cost: toPrice(cost)
|
|
409
|
+
}))
|
|
410
|
+
.sort((a, b) => a.min_price - b.min_price);
|
|
411
|
+
let cost = 0;
|
|
412
|
+
for (let i = 0; i < priceBasedCost.length; i += 1) {
|
|
413
|
+
if (subTotal >= priceBasedCost[i].min_price) {
|
|
414
|
+
cost = priceBasedCost[i].cost;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
return toPrice(cost);
|
|
386
418
|
} else {
|
|
387
419
|
this.setError(
|
|
388
420
|
'shipping_fee_excl_tax',
|
|
@@ -328,8 +328,9 @@ module.exports.registerCartItemBaseFields =
|
|
|
328
328
|
.from('variant_group')
|
|
329
329
|
.where('variant_group_id', '=', product.variant_group_id)
|
|
330
330
|
.load(pool);
|
|
331
|
-
if (!group)
|
|
332
|
-
|
|
331
|
+
if (!group) {
|
|
332
|
+
return null;
|
|
333
|
+
} else {
|
|
333
334
|
const query = select('a.attribute_code')
|
|
334
335
|
.select('a.attribute_name')
|
|
335
336
|
.select('a.attribute_id')
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
const config = require('config');
|
|
2
|
+
const registerDefaultPageCollectionFilters = require('./services/registerDefaultPageCollectionFilters');
|
|
3
|
+
const {
|
|
4
|
+
defaultPaginationFilters
|
|
5
|
+
} = require('../../lib/util/defaultPaginationFilters');
|
|
6
|
+
const { addProcessor } = require('../../lib/util/registry');
|
|
2
7
|
|
|
3
8
|
module.exports = () => {
|
|
4
9
|
const themeConfig = {
|
|
@@ -20,4 +25,16 @@ module.exports = () => {
|
|
|
20
25
|
config.util.setModuleDefaults('system', {
|
|
21
26
|
file_storage: 'local'
|
|
22
27
|
});
|
|
28
|
+
|
|
29
|
+
// Reigtering the default filters for attribute collection
|
|
30
|
+
addProcessor(
|
|
31
|
+
'cmsPageCollectionFilters',
|
|
32
|
+
registerDefaultPageCollectionFilters,
|
|
33
|
+
1
|
|
34
|
+
);
|
|
35
|
+
addProcessor(
|
|
36
|
+
'cmsPageCollectionFilters',
|
|
37
|
+
(filters) => [...filters, ...defaultPaginationFilters],
|
|
38
|
+
2
|
|
39
|
+
);
|
|
23
40
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const { select } = require('@evershop/postgres-query-builder');
|
|
2
1
|
const { buildUrl } = require('@evershop/evershop/src/lib/router/buildUrl');
|
|
3
2
|
const { camelCase } = require('@evershop/evershop/src/lib/util/camelCase');
|
|
4
3
|
const {
|
|
@@ -9,23 +8,15 @@ const { CMSPageCollection } = require('../../../services/CMSPageCollection');
|
|
|
9
8
|
module.exports = {
|
|
10
9
|
Query: {
|
|
11
10
|
cmsPage: async (root, { id }, { pool }) => {
|
|
12
|
-
const query =
|
|
13
|
-
query
|
|
14
|
-
.leftJoin('cms_page_description')
|
|
15
|
-
.on(
|
|
16
|
-
'cms_page.cms_page_id',
|
|
17
|
-
'=',
|
|
18
|
-
'cms_page_description.cms_page_description_cms_page_id'
|
|
19
|
-
);
|
|
11
|
+
const query = getCmsPagesBaseQuery();
|
|
20
12
|
query.where('cms_page_id', '=', id);
|
|
21
|
-
|
|
22
13
|
const page = await query.load(pool);
|
|
23
14
|
return page ? camelCase(page) : null;
|
|
24
15
|
},
|
|
25
16
|
cmsPages: async (_, { filters = [] }, { user }) => {
|
|
26
17
|
const query = getCmsPagesBaseQuery();
|
|
27
18
|
const root = new CMSPageCollection(query);
|
|
28
|
-
await root.init(
|
|
19
|
+
await root.init(filters, !!user);
|
|
29
20
|
return root;
|
|
30
21
|
}
|
|
31
22
|
},
|
|
@@ -7,10 +7,11 @@ import { useAlertContext } from '@components/common/modal/Alert';
|
|
|
7
7
|
import { Checkbox } from '@components/common/form/fields/Checkbox';
|
|
8
8
|
import { Card } from '@components/admin/cms/Card';
|
|
9
9
|
import Area from '@components/common/Area';
|
|
10
|
-
import BasicColumnHeader from '@components/common/grid/headers/Basic';
|
|
11
|
-
import StatusColumnHeader from '@components/common/grid/headers/Status';
|
|
12
10
|
import StatusRow from '@components/common/grid/rows/StatusRow';
|
|
13
11
|
import PageName from '@components/admin/cms/cmsPageGrid/rows/PageName';
|
|
12
|
+
import { Form } from '@components/common/form/Form';
|
|
13
|
+
import { Field } from '@components/common/form/Field';
|
|
14
|
+
import SortableHeader from '@components/common/grid/headers/Sortable';
|
|
14
15
|
|
|
15
16
|
function Actions({ pages = [], selectedIds = [] }) {
|
|
16
17
|
const { openAlert, closeAlert } = useAlertContext();
|
|
@@ -164,6 +165,60 @@ export default function CMSPageGrid({
|
|
|
164
165
|
|
|
165
166
|
return (
|
|
166
167
|
<Card>
|
|
168
|
+
<Card.Session
|
|
169
|
+
title={
|
|
170
|
+
<Form submitBtn={false}>
|
|
171
|
+
<Area
|
|
172
|
+
id="cmsPageGridFilter"
|
|
173
|
+
noOuter
|
|
174
|
+
coreComponents={[
|
|
175
|
+
{
|
|
176
|
+
component: {
|
|
177
|
+
default: () => (
|
|
178
|
+
<Field
|
|
179
|
+
type="text"
|
|
180
|
+
id="name"
|
|
181
|
+
placeholder="Search"
|
|
182
|
+
value={
|
|
183
|
+
currentFilters.find((f) => f.key === 'name')?.value
|
|
184
|
+
}
|
|
185
|
+
onKeyPress={(e) => {
|
|
186
|
+
// If the user press enter, we should submit the form
|
|
187
|
+
if (e.key === 'Enter') {
|
|
188
|
+
const url = new URL(document.location);
|
|
189
|
+
const name = document.getElementById('name')?.value;
|
|
190
|
+
if (name) {
|
|
191
|
+
url.searchParams.set('name[operation]', 'like');
|
|
192
|
+
url.searchParams.set('name[value]', name);
|
|
193
|
+
} else {
|
|
194
|
+
url.searchParams.delete('name[operation]');
|
|
195
|
+
url.searchParams.delete('name[value]');
|
|
196
|
+
}
|
|
197
|
+
window.location.href = url;
|
|
198
|
+
}
|
|
199
|
+
}}
|
|
200
|
+
/>
|
|
201
|
+
)
|
|
202
|
+
},
|
|
203
|
+
sortOrder: 10
|
|
204
|
+
}
|
|
205
|
+
]}
|
|
206
|
+
/>
|
|
207
|
+
</Form>
|
|
208
|
+
}
|
|
209
|
+
actions={[
|
|
210
|
+
{
|
|
211
|
+
variant: 'interactive',
|
|
212
|
+
name: 'Clear filter',
|
|
213
|
+
onAction: () => {
|
|
214
|
+
// Just get the url and remove all query params
|
|
215
|
+
const url = new URL(document.location);
|
|
216
|
+
url.search = '';
|
|
217
|
+
window.location.href = url.href;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
]}
|
|
221
|
+
/>
|
|
167
222
|
<table className="listing sticky">
|
|
168
223
|
<thead>
|
|
169
224
|
<tr>
|
|
@@ -186,9 +241,9 @@ export default function CMSPageGrid({
|
|
|
186
241
|
{
|
|
187
242
|
component: {
|
|
188
243
|
default: () => (
|
|
189
|
-
<
|
|
244
|
+
<SortableHeader
|
|
190
245
|
title="Name"
|
|
191
|
-
|
|
246
|
+
name="name"
|
|
192
247
|
currentFilters={currentFilters}
|
|
193
248
|
/>
|
|
194
249
|
)
|
|
@@ -198,12 +253,10 @@ export default function CMSPageGrid({
|
|
|
198
253
|
{
|
|
199
254
|
component: {
|
|
200
255
|
default: () => (
|
|
201
|
-
<
|
|
256
|
+
<SortableHeader
|
|
202
257
|
title="Status"
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
(f) => f.key === 'status'
|
|
206
|
-
)}
|
|
258
|
+
name="status"
|
|
259
|
+
currentFilters={currentFilters}
|
|
207
260
|
/>
|
|
208
261
|
)
|
|
209
262
|
},
|
|
@@ -11,6 +11,5 @@ module.exports = (request, response) => {
|
|
|
11
11
|
title: 'Cms pages',
|
|
12
12
|
description: 'Cms pages'
|
|
13
13
|
});
|
|
14
|
-
|
|
15
|
-
setContextValue(request, 'filtersFromUrl', buildFilterFromUrl(query));
|
|
14
|
+
setContextValue(request, 'filtersFromUrl', buildFilterFromUrl(request));
|
|
16
15
|
};
|
|
@@ -1,91 +1,44 @@
|
|
|
1
1
|
const { camelCase } = require('@evershop/evershop/src/lib/util/camelCase');
|
|
2
2
|
const { pool } = require('@evershop/evershop/src/lib/postgres/connection');
|
|
3
|
+
const { getValue } = require('@evershop/evershop/src/lib/util/registry');
|
|
3
4
|
|
|
4
5
|
class CMSPageCollection {
|
|
5
6
|
constructor(baseQuery) {
|
|
6
7
|
this.baseQuery = baseQuery;
|
|
7
8
|
}
|
|
8
9
|
|
|
9
|
-
async init(
|
|
10
|
-
if (!
|
|
10
|
+
async init(filters = [], isAdmin = false) {
|
|
11
|
+
if (!isAdmin) {
|
|
11
12
|
this.baseQuery.andWhere('cms_page.status', '=', 't');
|
|
12
13
|
}
|
|
13
14
|
const currentFilters = [];
|
|
14
15
|
|
|
15
|
-
//
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
'ILIKE',
|
|
21
|
-
`%${nameFilter.value}%`
|
|
22
|
-
);
|
|
23
|
-
currentFilters.push({
|
|
24
|
-
key: 'name',
|
|
25
|
-
operation: '=',
|
|
26
|
-
value: nameFilter.value
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Status filter
|
|
31
|
-
const statusFilter = filters.find((f) => f.key === 'status');
|
|
32
|
-
if (statusFilter) {
|
|
33
|
-
this.baseQuery.andWhere('cms_page.status', '=', statusFilter.value);
|
|
34
|
-
currentFilters.push({
|
|
35
|
-
key: 'status',
|
|
36
|
-
operation: '=',
|
|
37
|
-
value: statusFilter.value
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const sortBy = filters.find((f) => f.key === 'sortBy');
|
|
42
|
-
const sortOrder = filters.find(
|
|
43
|
-
(f) =>
|
|
44
|
-
f.key === 'sortOrder' &&
|
|
45
|
-
['ASC', 'DESC', 'asc', 'desc'].includes(f.value)
|
|
46
|
-
) || { value: 'DESC' };
|
|
16
|
+
// Apply the filters
|
|
17
|
+
const cmsPageCollectionFilters = await getValue(
|
|
18
|
+
'cmsPageCollectionFilters',
|
|
19
|
+
[]
|
|
20
|
+
);
|
|
47
21
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
operation: '=',
|
|
62
|
-
value: sortOrder.value
|
|
63
|
-
});
|
|
64
|
-
}
|
|
22
|
+
cmsPageCollectionFilters.forEach((filter) => {
|
|
23
|
+
const check = filters.find((f) => f.key === filter.key);
|
|
24
|
+
if (check) {
|
|
25
|
+
if (filter.operation.includes(check.operation)) {
|
|
26
|
+
filter.callback(
|
|
27
|
+
this.baseQuery,
|
|
28
|
+
check.operation,
|
|
29
|
+
check.value,
|
|
30
|
+
currentFilters
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
});
|
|
65
35
|
|
|
66
36
|
// Clone the main query for getting total right before doing the paging
|
|
67
37
|
const totalQuery = this.baseQuery.clone();
|
|
68
38
|
totalQuery.select('COUNT(cms_page.cms_page_id)', 'total');
|
|
69
39
|
totalQuery.removeOrderBy();
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const limit = filters.find((f) => f.key === 'limit' && f.value > 0) || {
|
|
73
|
-
value: 20
|
|
74
|
-
}; // TODO: Get from the config
|
|
75
|
-
currentFilters.push({
|
|
76
|
-
key: 'page',
|
|
77
|
-
operation: '=',
|
|
78
|
-
value: page.value
|
|
79
|
-
});
|
|
80
|
-
currentFilters.push({
|
|
81
|
-
key: 'limit',
|
|
82
|
-
operation: '=',
|
|
83
|
-
value: limit.value
|
|
84
|
-
});
|
|
85
|
-
this.baseQuery.limit(
|
|
86
|
-
(page.value - 1) * parseInt(limit.value, 10),
|
|
87
|
-
parseInt(limit.value, 10)
|
|
88
|
-
);
|
|
40
|
+
totalQuery.removeLimit();
|
|
41
|
+
|
|
89
42
|
this.currentFilters = currentFilters;
|
|
90
43
|
this.totalQuery = totalQuery;
|
|
91
44
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
const {
|
|
2
|
+
OPERATION_MAP
|
|
3
|
+
} = require('@evershop/evershop/src/lib/util/filterOperationMapp');
|
|
4
|
+
const { getValueSync } = require('@evershop/evershop/src/lib/util/registry');
|
|
5
|
+
|
|
6
|
+
module.exports = async function registerDefaultPageCollectionFilters() {
|
|
7
|
+
// List of default supported filters
|
|
8
|
+
const defaultFilters = [
|
|
9
|
+
{
|
|
10
|
+
key: 'name',
|
|
11
|
+
operation: ['eq', 'like'],
|
|
12
|
+
callback: (query, operation, value, currentFilters) => {
|
|
13
|
+
if (operation === 'eq') {
|
|
14
|
+
query.andWhere('cms_page_description.name', '=', value);
|
|
15
|
+
} else {
|
|
16
|
+
query.andWhere('cms_page_description.name', 'ilike', `%${value}%`);
|
|
17
|
+
}
|
|
18
|
+
currentFilters.push({
|
|
19
|
+
key: 'name',
|
|
20
|
+
operation,
|
|
21
|
+
value
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
key: 'status',
|
|
27
|
+
operation: ['eq'],
|
|
28
|
+
callback: (query, operation, value, currentFilters) => {
|
|
29
|
+
query.andWhere('cms_page.status', OPERATION_MAP[operation], value);
|
|
30
|
+
currentFilters.push({
|
|
31
|
+
key: 'status',
|
|
32
|
+
operation,
|
|
33
|
+
value
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
key: 'ob',
|
|
39
|
+
operation: ['eq'],
|
|
40
|
+
callback: (query, operation, value, currentFilters) => {
|
|
41
|
+
const cmsPageCollectionSortBy = getValueSync(
|
|
42
|
+
'cmsPageCollectionSortBy',
|
|
43
|
+
{
|
|
44
|
+
name: (query) => query.orderBy('cms_page_description.name'),
|
|
45
|
+
status: (query) => query.orderBy('cms_page.status')
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
if (cmsPageCollectionSortBy[value]) {
|
|
50
|
+
cmsPageCollectionSortBy[value](query, operation);
|
|
51
|
+
currentFilters.push({
|
|
52
|
+
key: 'ob',
|
|
53
|
+
operation,
|
|
54
|
+
value
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
return defaultFilters;
|
|
62
|
+
};
|