@ecomplus/widget-product-card 1.0.0-beta.19 → 1.0.0-beta.190

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecomplus/widget-product-card",
3
- "version": "1.0.0-beta.19",
3
+ "version": "1.0.0-beta.190",
4
4
  "description": "Storefront plugin with Vue component for product cards",
5
5
  "module": "src/index.js",
6
6
  "browser": "dist/widget-product-card.min.js",
@@ -8,7 +8,7 @@
8
8
  "jsdelivr": "dist/public/widget-product-card.var.min.js",
9
9
  "unpkg": "dist/public/widget-product-card.var.min.js",
10
10
  "scripts": {
11
- "build": "NODE_ENV=production webpack",
11
+ "build": "cross-env NODE_ENV=production webpack",
12
12
  "serve": "webpack-dev-server"
13
13
  },
14
14
  "repository": {
@@ -36,7 +36,7 @@
36
36
  "vue": ">=2 <4"
37
37
  },
38
38
  "dependencies": {
39
- "@ecomplus/storefront-components": "^1.0.0-beta.22"
39
+ "@ecomplus/storefront-components": "^1.0.0-beta.191"
40
40
  },
41
41
  "webpackOutput": {
42
42
  "library": "widgetProductCard",
package/src/index.js CHANGED
@@ -6,6 +6,7 @@
6
6
 
7
7
  import Vue from 'vue'
8
8
  import lozad from 'lozad'
9
+ import { inStock as checkInStock } from '@ecomplus/utils'
9
10
  import EcomSearch from '@ecomplus/search-engine'
10
11
  import ProductCard from '#components/ProductCard.vue'
11
12
 
@@ -24,7 +25,7 @@ export default (options = {}, elClass = 'product-card') => {
24
25
  const setupComponent = ($productCard, productId, sku, product, isLoaded) => {
25
26
  new Vue({
26
27
  render: h => h(ProductCard, {
27
- class: elClass,
28
+ class: elClass !== 'product-card' ? elClass : null,
28
29
  attrs: {
29
30
  'data-product-id': productId,
30
31
  'data-sku': sku
@@ -33,7 +34,8 @@ export default (options = {}, elClass = 'product-card') => {
33
34
  ...options.props,
34
35
  productId,
35
36
  product,
36
- isLoaded
37
+ isLoaded,
38
+ transitionClass: null
37
39
  },
38
40
  scopedSlots: typeof getScopedSlots === 'function'
39
41
  ? getScopedSlots($productCard, h)
@@ -54,13 +56,12 @@ export default (options = {}, elClass = 'product-card') => {
54
56
  }
55
57
 
56
58
  let preFetchPromise
57
- if (productIds.length >= 6 && productIds.length <= 70 && !options.skipSearchApi) {
59
+ if (productIds.length >= 4 && productIds.length <= 70 && !options.skipSearchApi) {
58
60
  const search = new EcomSearch()
59
- delete search.dsl.aggs
60
- delete search.dsl.sort
61
- search.setPageSize(productIds.length).setProductIds(productIds)
62
-
63
- preFetchPromise = search.fetch({ timeout: 5000 })
61
+ preFetchPromise = search
62
+ .setPageSize(productIds.length)
63
+ .setProductIds(productIds)
64
+ .fetch(true, { timeout: 5000 })
64
65
  .then(() => {
65
66
  const items = search.getItems()
66
67
  for (let i = 0; i < 2; i++) {
@@ -92,10 +93,16 @@ export default (options = {}, elClass = 'product-card') => {
92
93
  let isLoaded
93
94
  if (product) {
94
95
  isLoaded = true
96
+ if (!product.available || !product.visible || !checkInStock(product)) {
97
+ const $cardLi = $productCard.parentNode && $productCard.parentNode.parentNode
98
+ if ($cardLi && $cardLi.tagName === 'LI') {
99
+ $cardLi.parentNode.appendChild($cardLi)
100
+ }
101
+ }
95
102
  } else {
96
- const $parent = $productCard.parentNode
97
- if ($parent) {
98
- product = $parent.dataset.product
103
+ const $productItem = $productCard.parentNode
104
+ if ($productItem) {
105
+ product = $productItem.dataset.product
99
106
  if (typeof product === 'string') {
100
107
  try {
101
108
  product = JSON.parse(product)
@@ -0,0 +1 @@
1
+ module.exports = require('../../webpack.config')