ProductStep.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <template lang="pug">
  2. .purchase-step
  3. .products-selector
  4. searcher(:items='variants' :keys="['name', 'displayName', 'ean13']" @onSearch='filterProducts')
  5. card-grid(:items='visibleProducts' :details="['price:c']" :options='selectedCurrency' @onSelect='selectProduct')
  6. variant-modal(:items='productWithVariant && productWithVariant.variants' :show='!!productWithVariant' @onSelect='selectProduct' @onClose='selectProduct')
  7. price-modal(:item='itemPriced' :options='selectedCurrency' :show='!!itemPriced' @onAccept='changePrice' @onCancel='changePrice')
  8. cart(:items='cartItems' @onIncrementQty='addToCart' @onChangePrice='changePrice' @onUndoPrice='undoPrice' @onDecrementQty='decreaseFromCart' @onDeleteItem='removeFromCart' @onTotalComputed='updateCartTotal' :options='selectedCurrency')
  9. </template>
  10. <script>
  11. import { mapGetters, mapActions } from 'vuex'
  12. import { Searcher, CardGrid, Cart } from '../common'
  13. import VariantModal from '../modals/VariantModal'
  14. import PriceModal from '../modals/PriceModal'
  15. export default {
  16. components: {
  17. Searcher,
  18. CardGrid,
  19. Cart,
  20. VariantModal,
  21. PriceModal
  22. },
  23. computed: mapGetters([
  24. 'products',
  25. 'variants',
  26. 'visibleProducts',
  27. 'loadingProducts',
  28. 'cartItems',
  29. 'selectedCurrency',
  30. 'productWithVariant',
  31. 'itemPriced'
  32. ]),
  33. methods: mapActions([
  34. 'filterProducts',
  35. 'selectProduct',
  36. 'addToCart',
  37. 'decreaseFromCart',
  38. 'changePrice',
  39. 'undoPrice',
  40. 'removeFromCart',
  41. 'updateCartTotal'
  42. ])
  43. }
  44. </script>
  45. <style lang="sass">
  46. .purchase-step
  47. .products-selector
  48. width: calc(100% - 300px)
  49. height: 100%
  50. padding-right: 5px
  51. display: inline-block
  52. </style>