|
@@ -0,0 +1,84 @@
|
|
|
+<template lang="pug">
|
|
|
+ modal(name='variant-selector' transition='nice-modal-fade' height="500" @closed='handleClosed' :classes="['v--modal', 'variant-modal']")
|
|
|
+ searcher(:items='getItems()' :keys="['name', 'displayName']" @onSearch='filterVariants')
|
|
|
+ .product-variants
|
|
|
+ .product-variant(v-for='item in getItems()' :key='item.id' @click='selectProduct(item)')
|
|
|
+ img.variant-image
|
|
|
+ .variant-details
|
|
|
+ h2.variant-name {{ item.displayName }}
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ import { mapGetters, mapActions } from 'vuex'
|
|
|
+
|
|
|
+ import { Searcher } from '@@/common'
|
|
|
+ import { SELECT_PRODUCT } from '@/constants/actionTypes'
|
|
|
+
|
|
|
+ export default {
|
|
|
+ components: {
|
|
|
+ Searcher
|
|
|
+ },
|
|
|
+ computed: mapGetters([
|
|
|
+ 'productWithVariant'
|
|
|
+ ]),
|
|
|
+ methods: {
|
|
|
+ getItems() {
|
|
|
+ return this.filteredItems.length === 0 && !!this.productWithVariant ? this.productWithVariant.variants : this.filteredItems
|
|
|
+ },
|
|
|
+ filterVariants(values) {
|
|
|
+ this.filteredItems = values
|
|
|
+ },
|
|
|
+ handleClosed() {
|
|
|
+ this.selectProduct(null)
|
|
|
+ },
|
|
|
+ ...mapActions([
|
|
|
+ SELECT_PRODUCT
|
|
|
+ ])
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ productWithVariant(value) {
|
|
|
+ if (value) {
|
|
|
+ this.$modal.show('variant-selector')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ this.$modal.hide('variant-selector')
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ filteredItems: []
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="sass">
|
|
|
+ .variant-modal
|
|
|
+ padding: 15px !important
|
|
|
+ .product-variants
|
|
|
+ width: 100%;
|
|
|
+ height: calc(100% - 70px)
|
|
|
+ overflow-y: auto
|
|
|
+ .product-variant
|
|
|
+ width: calc(100% - 20px)
|
|
|
+ height: 84px
|
|
|
+ margin: 5px 10px
|
|
|
+ display: flex
|
|
|
+ &:hover
|
|
|
+ cursor: pointer
|
|
|
+ .variant-details
|
|
|
+ transition-duration: 0.5s
|
|
|
+ border-bottom: 2px solid #7c7bad
|
|
|
+ .variant-image
|
|
|
+ width: 80px
|
|
|
+ height: 80px
|
|
|
+ margin: 0
|
|
|
+ border: none
|
|
|
+ .variant-details
|
|
|
+ flex-grow: 1
|
|
|
+ border-bottom: 1px solid #d3d3d3
|
|
|
+ .variant-name
|
|
|
+ font-size: 10pt
|
|
|
+ margin-left: 10px
|
|
|
+</style>
|