@wikala/spmkt 2.31.1 → 3.0.0-beta.1
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/MIGRATION_GUIDE.md +310 -0
- package/api/product.js +1 -0
- package/api/request.js +12 -6
- package/api/user.js +1 -1
- package/components/Account/AccountDashboard.vue +101 -101
- package/components/Account/AccountStore.js +57 -31
- package/components/Account/AffiliateReport.vue +56 -60
- package/components/Account/{OrderDetail.vue → Orders/OrderDetail.vue} +44 -30
- package/components/Account/Orders/Orders.vue +124 -0
- package/components/Account/{AccountSettings.vue → Settings/AccountSettings.vue} +4 -4
- package/components/Account/Settings/ChangeEmail.vue +136 -0
- package/components/Account/Settings/ChangeName.vue +82 -0
- package/components/Account/Settings/ChangePassword.vue +91 -0
- package/components/Address/Address.vue +38 -57
- package/components/Address/AddressBook.vue +77 -57
- package/components/Address/AddressSelect.vue +94 -87
- package/components/Address/Edit.vue +253 -265
- package/components/Address/PostalCode.vue +22 -21
- package/components/AgeGate.vue +11 -5
- package/components/Auth/Login.vue +62 -44
- package/components/Auth/Register.vue +82 -60
- package/components/Auth/ResetPassword.vue +45 -30
- package/components/Cart/AgeVerification/AgeChecker.vue +3 -3
- package/components/Cart/CartBadge.vue +15 -4
- package/components/Cart/CartBox.vue +19 -11
- package/components/Cart/CartItem.vue +3 -3
- package/components/Cart/CartMode.vue +6 -5
- package/components/Cart/CartPreview.vue +24 -18
- package/components/Cart/CreditCard/Everyware.vue +10 -10
- package/components/Cart/CreditCard/ExtendedCreditCard.vue +5 -5
- package/components/Cart/CreditCard/SquarePay.vue +18 -16
- package/components/Cart/CreditCard/StandardCreditCard.vue +9 -9
- package/components/Cart/Delivery/Delivery.vue +16 -12
- package/components/Cart/Delivery/DeliveryAddress.vue +1 -1
- package/components/Cart/Delivery/DeliveryMethods.vue +1 -1
- package/components/Cart/Delivery/DeliveryOptions.vue +15 -9
- package/components/Cart/Delivery/DeliveryTypes.vue +8 -5
- package/components/Cart/Delivery/ReservationSlots.vue +14 -8
- package/components/Cart/Disclaimer.vue +1 -1
- package/components/Cart/OrderConfirmation.vue +1 -1
- package/components/Cart/Payment/Payment.vue +37 -33
- package/components/Cart/Payment/PaymentMethods.vue +6 -4
- package/components/Cart/ReviewAndSubmit.vue +9 -7
- package/components/Cart/ShoppingCart.vue +42 -31
- package/components/Cart/Store/actions.js +1 -1
- package/components/Cart/Store/getters.js +2 -1
- package/components/Cart/Store/index.js +1 -1
- package/components/Cart/Store/mutations.js +9 -7
- package/components/Cart/Store/state.js +2 -2
- package/components/Cart/UserIdentity.vue +1 -1
- package/components/Category/CategoryFilter.vue +128 -114
- package/components/Category/CategorySort.vue +44 -32
- package/components/Category/LoadMore.vue +39 -23
- package/components/DeliverTo.vue +10 -15
- package/components/DeliveryNotice.vue +72 -68
- package/components/DobInput.vue +24 -24
- package/components/Gmaps/GmapsAutocomplete.vue +139 -78
- package/components/Gmaps/GmapsLocations.vue +1 -1
- package/components/Gmaps/GmapsSingleLocation.vue +121 -87
- package/components/MobileMenu/icons/LeftArrowIcon.vue +1 -1
- package/components/MobileMenu/icons/MenuIcon.vue +1 -1
- package/components/MobileMenu/icons/RightArrowIcon.vue +1 -1
- package/components/ModalContainer/ModalContainer.vue +20 -13
- package/components/ModalContainer/index.js +62 -18
- package/components/Product/AddToCart.vue +237 -221
- package/components/Product/BoxAddToCart.vue +114 -86
- package/components/Product/Compare.vue +91 -49
- package/components/Product/CompareBox.vue +128 -123
- package/components/Product/Lookup.vue +92 -65
- package/components/Product/Photo.vue +105 -66
- package/components/Product/Price.vue +64 -43
- package/components/Product/ProductAutocomplete.vue +52 -57
- package/components/Product/ProductBox.vue +61 -38
- package/components/Product/ProductImages.vue +83 -86
- package/components/Product/Quantity.vue +115 -53
- package/components/Product/QuickView.vue +52 -45
- package/components/Product/RelatedProducts.vue +88 -23
- package/components/Product/SKU.vue +27 -8
- package/components/Product/Variants.vue +336 -342
- package/components/Product/reviews-questions/ProductQuestions.vue +226 -198
- package/components/Product/reviews-questions/ProductReviews.vue +122 -107
- package/components/Product/reviews-questions/Review.vue +54 -59
- package/components/Product/reviews-questions/ReviewForm.vue +222 -170
- package/components/Product/reviews-questions/ReviewImages.vue +197 -216
- package/components/Product/reviews-questions/Vote.vue +83 -57
- package/components/QuantityInput.vue +18 -8
- package/components/RangeInput.vue +15 -8
- package/components/Recaptcha.vue +8 -1
- package/components/SelectShippingCountry.vue +81 -62
- package/components/TimedOffer.vue +59 -74
- package/composables/globals.js +53 -0
- package/config.js +5 -2
- package/index.js +41 -10
- package/install.js +88 -0
- package/locales/en.json +2 -1
- package/locales/sr.json +2 -1
- package/package.json +49 -37
- package/utils/animate.css +50 -0
- package/utils/animate.js +1 -1
- package/utils/buefy.js +62 -0
- package/utils/directives.js +28 -45
- package/utils/event-bus.js +56 -0
- package/utils/filters.js +24 -7
- package/utils/format-date.js +17 -0
- package/utils/{gmaps.js → google/gmaps.js} +43 -10
- package/utils/{google-analytics-eec.js → google/google-analytics-eec.js} +7 -7
- package/utils/random-id.js +10 -0
- package/babel.config.js +0 -5
- package/components/Account/ChangeEmail.vue +0 -133
- package/components/Account/ChangeName.vue +0 -92
- package/components/Account/ChangePassword.vue +0 -94
- package/components/Account/CreditCards.vue +0 -18
- package/components/Account/Orders.vue +0 -110
- package/components/Account/Settings.vue +0 -18
- package/components/Cart/Delivery/DeliveryAddressGuest.spec.js +0 -128
- package/components/Cart/Delivery/DeliveryTypes.spec.js +0 -83
- package/components/Cart/PCIBadge/SecurityMetrics.vue +0 -11
- package/components/Instagram.vue +0 -49
- package/components/ProductImageModal.vue +0 -41
- package/jest.config.js +0 -16
- package/test/e2e/.babelrc.js +0 -8
- package/test/e2e/.eslintrc.js +0 -11
- package/test/e2e/accAuth.spec.js +0 -64
- package/test/e2e/ageGate.spec.js +0 -26
- package/test/e2e/checkout.spec.js +0 -106
- package/test/e2e/compare.spec.js +0 -52
- package/test/e2e/config/data.js +0 -21
- package/test/e2e/config/routes.js +0 -11
- package/test/e2e/region.spec.js +0 -46
- package/test/e2e/search.spec.js +0 -32
- package/tests/vueBuefy.js +0 -4
- package/tsconfig.json +0 -8
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="category-filters category-filter-component">
|
|
3
|
-
<template v-for="(filter, index) in filters">
|
|
3
|
+
<template v-for="(filter, index) in filters" :key="filter.id">
|
|
4
4
|
<div class="filter-container">
|
|
5
5
|
<div class="filter-title" @click="expandFilter($event)">
|
|
6
6
|
<h2>{{ filter.display_name }}</h2>
|
|
@@ -9,26 +9,25 @@
|
|
|
9
9
|
<div :class="{ 'filter-content': true, 'is-hidden': !isExpanded(filter.id) }">
|
|
10
10
|
<div v-if="rangeTypes.includes(filter.type)" class="range-filter-container" >
|
|
11
11
|
<RangeInput
|
|
12
|
-
|
|
12
|
+
v-model="filters[index].selected"
|
|
13
13
|
:min="filters[index].min"
|
|
14
14
|
:max="filters[index].max"
|
|
15
15
|
:step="filters[index].step"
|
|
16
|
-
:show-apply-button="
|
|
16
|
+
:show-apply-button="mq !== 'mobile'"
|
|
17
17
|
:filter-name="filter.display_name"
|
|
18
|
-
@
|
|
19
|
-
@input="rangeInput($event, index)"
|
|
18
|
+
@apply-range="applyRange($event, index)"
|
|
20
19
|
/>
|
|
21
20
|
</div>
|
|
22
21
|
<div v-else :class="[filter.values.length > 7 && !expanded[index] ? 'fixed-height-filter' : '']">
|
|
23
22
|
<div v-if="filter.values.length > 7" class="filter-query">
|
|
24
23
|
<input class="input" :placeholder="$t('category.searchBy') + ' ' + filter.display_name.toLowerCase()" @input="filterQuery($event, filter.id)" />
|
|
25
24
|
</div>
|
|
26
|
-
<div v-for="fval in filterfilter(filter.values, filter.id)">
|
|
27
|
-
<b-checkbox
|
|
25
|
+
<div v-for="fval in filterfilter(filter.values, filter.id)" :key="fval.value">
|
|
26
|
+
<b-checkbox v-model="fval.selected" @update:model-value="filterChange">{{ fval.value }}</b-checkbox>
|
|
28
27
|
</div>
|
|
29
28
|
<div v-if="filterq[filter.id] && filterq[filter.id][1] === 0"> No results </div>
|
|
30
29
|
</div>
|
|
31
|
-
<div v-if="
|
|
30
|
+
<div v-if="mq === 'mobile' && !rangeTypes.includes(filter.type) && filter.values.length > 7">
|
|
32
31
|
<div @click="expand(index)" class="ml-3 mt-1 is-link">{{ expanded[index] ? 'Show less' : 'Show more' }}</div>
|
|
33
32
|
</div>
|
|
34
33
|
</div>
|
|
@@ -36,14 +35,14 @@
|
|
|
36
35
|
</template>
|
|
37
36
|
<div ref="filtersFooter" class="columns is-gapless is-mobile filters-footer is-hidden-tablet">
|
|
38
37
|
<div class="column filters-footer-left-col">
|
|
39
|
-
<span v-if="filtersResultCount >= 0 &&
|
|
38
|
+
<span v-if="filtersResultCount >= 0 && checked !== ''">{{ $tc('category.productsFound', filtersResultCount) }}</span>
|
|
40
39
|
</div>
|
|
41
40
|
<div>
|
|
42
41
|
<button :class="[{ button: true, 'is-primary': filtersResultCount !== 0 }, 'button']" :disabled="!filtersResultCount" @click="applyFilters">
|
|
43
42
|
{{ $t('category.applyFilters') }}
|
|
44
43
|
</button>
|
|
45
44
|
</div>
|
|
46
|
-
<b-loading :is-full-page="false"
|
|
45
|
+
<b-loading :is-full-page="false" v-model="frcLoading" :can-cancel="false">
|
|
47
46
|
<b-icon pack="fas" icon="circle-notch" size="is-normal" custom-class="fa-spin"></b-icon>
|
|
48
47
|
</b-loading>
|
|
49
48
|
</div>
|
|
@@ -51,11 +50,14 @@
|
|
|
51
50
|
</template>
|
|
52
51
|
|
|
53
52
|
<script>
|
|
53
|
+
import { ref, reactive, onBeforeMount, onBeforeUnmount } from 'vue'
|
|
54
|
+
import { useInitialState, useMq } from '../../composables/globals'
|
|
54
55
|
import _ from 'underscore'
|
|
55
56
|
import config from '../../config'
|
|
56
57
|
import { request } from '../../api'
|
|
58
|
+
import { eventBus } from '../../utils/event-bus'
|
|
57
59
|
|
|
58
|
-
import RangeInput from '../../components/RangeInput'
|
|
60
|
+
import RangeInput from '../../components/RangeInput.vue'
|
|
59
61
|
|
|
60
62
|
let getFiltersResultCount = _.debounce(
|
|
61
63
|
async (filtersQueryString) => {
|
|
@@ -78,26 +80,25 @@ export default {
|
|
|
78
80
|
|
|
79
81
|
components: { RangeInput },
|
|
80
82
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
83
|
+
setup() {
|
|
84
|
+
const initialState = useInitialState()
|
|
85
|
+
const mq = useMq()
|
|
86
|
+
|
|
87
|
+
const filtersResultCount = ref(-1)
|
|
88
|
+
const filters = ref([])
|
|
89
|
+
const filtersFromURL = ref(null)
|
|
90
|
+
const checked = ref('')
|
|
91
|
+
const frcLoading = ref(false)
|
|
92
|
+
const rangeTypes = ref(RANGE_TYPES)
|
|
93
|
+
const filterq = reactive({})
|
|
94
|
+
const expanded = reactive({})
|
|
95
|
+
const filtersFooter = ref(null)
|
|
96
|
+
|
|
97
|
+
const expand = (idx) => {
|
|
98
|
+
expanded[idx] = !expanded[idx]
|
|
91
99
|
}
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
methods: {
|
|
95
|
-
|
|
96
|
-
expand(idx) {
|
|
97
|
-
this.$set(this.expanded, idx, !this.expanded[idx])
|
|
98
|
-
},
|
|
99
100
|
|
|
100
|
-
expandFilter(e) {
|
|
101
|
+
const expandFilter = (e) => {
|
|
101
102
|
let filterTitle = e.target.closest('.filter-title')
|
|
102
103
|
let filterContent = filterTitle.nextElementSibling
|
|
103
104
|
let expandIcon = filterTitle.querySelector('.filter-expand i')
|
|
@@ -105,71 +106,62 @@ export default {
|
|
|
105
106
|
filterContent.classList.toggle('is-hidden')
|
|
106
107
|
expandIcon.classList.toggle('fa-plus')
|
|
107
108
|
expandIcon.classList.toggle('fa-minus')
|
|
108
|
-
}
|
|
109
|
+
}
|
|
109
110
|
|
|
110
|
-
isExpanded(index) {
|
|
111
|
-
return
|
|
112
|
-
}
|
|
111
|
+
const isExpanded = (index) => {
|
|
112
|
+
return filtersFromURL.value[index] !== undefined
|
|
113
|
+
}
|
|
113
114
|
|
|
114
|
-
filterQuery(e, id) {
|
|
115
|
-
|
|
116
|
-
}
|
|
115
|
+
const filterQuery = (e, id) => {
|
|
116
|
+
filterq[id] = [e.target.value, 0]
|
|
117
|
+
}
|
|
117
118
|
|
|
118
|
-
filterfilter(values, id) {
|
|
119
|
+
const filterfilter = (values, id) => {
|
|
119
120
|
let query = ''
|
|
120
|
-
if (
|
|
121
|
-
query =
|
|
121
|
+
if (filterq[id]) {
|
|
122
|
+
query = filterq[id][0]
|
|
122
123
|
} else {
|
|
123
|
-
|
|
124
|
+
filterq[id] = ['', values.length]
|
|
124
125
|
}
|
|
125
126
|
if (query !== '') {
|
|
126
127
|
let filtered = values.filter((item) => {
|
|
127
128
|
return item.value.toLowerCase().includes(query.toLowerCase())
|
|
128
129
|
})
|
|
129
|
-
|
|
130
|
+
filterq[id][1] = filtered.length
|
|
130
131
|
return filtered
|
|
131
132
|
} else {
|
|
132
|
-
if (
|
|
133
|
-
|
|
133
|
+
if (filterq[id]) {
|
|
134
|
+
filterq[id][1] = values.length
|
|
134
135
|
}
|
|
135
136
|
return values
|
|
136
137
|
}
|
|
137
|
-
}
|
|
138
|
+
}
|
|
138
139
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
async getResultCount() {
|
|
162
|
-
this.filtersResultCount = -1
|
|
163
|
-
this.frcLoading = true
|
|
164
|
-
this.filtersResultCount = await getFiltersResultCount(this.checked)
|
|
165
|
-
this.frcLoading = false
|
|
166
|
-
},
|
|
167
|
-
|
|
168
|
-
getFiltersFromURL() {
|
|
140
|
+
const applyRange = (val, index) => {
|
|
141
|
+
filters.value[index] = Object.assign({}, filters.value[index], { selected: val })
|
|
142
|
+
filterChange()
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const applyFilters = () => {
|
|
146
|
+
eventBus.emit('filterChange', checked.value)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const changeRange = (val, index) => {
|
|
150
|
+
filters.value[index] = Object.assign({}, filters.value[index], { selected: val })
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const getResultCount = async () => {
|
|
154
|
+
filtersResultCount.value = -1
|
|
155
|
+
frcLoading.value = true
|
|
156
|
+
filtersResultCount.value = await getFiltersResultCount(checked.value)
|
|
157
|
+
frcLoading.value = false
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const getFiltersFromURL = () => {
|
|
169
161
|
let categoryUrl = new URL(window.location.href)
|
|
170
162
|
let urlFilters = categoryUrl.searchParams.get('f')
|
|
171
163
|
if (!urlFilters) {
|
|
172
|
-
|
|
164
|
+
filtersFromURL.value = []
|
|
173
165
|
return false
|
|
174
166
|
}
|
|
175
167
|
let filtersStruct = {}
|
|
@@ -177,18 +169,18 @@ export default {
|
|
|
177
169
|
let fvalues = filter.split(':')
|
|
178
170
|
filtersStruct[fvalues[0]] = fvalues[1].split(',')
|
|
179
171
|
})
|
|
180
|
-
|
|
181
|
-
}
|
|
172
|
+
filtersFromURL.value = filtersStruct
|
|
173
|
+
}
|
|
182
174
|
|
|
183
|
-
filterChange() {
|
|
175
|
+
const filterChange = () => {
|
|
184
176
|
let aCheckedFilters = []
|
|
185
177
|
|
|
186
|
-
if (
|
|
178
|
+
if (filters.value.constructor !== Array) {
|
|
187
179
|
console.log('Invalid filters structure')
|
|
188
180
|
return false
|
|
189
181
|
}
|
|
190
182
|
|
|
191
|
-
|
|
183
|
+
filters.value.forEach((filter) => {
|
|
192
184
|
if (RANGE_TYPES.includes(filter.type)) {
|
|
193
185
|
if (!_.isEmpty(filter.selected)) {
|
|
194
186
|
aCheckedFilters.push(filter.id + ':' + filter.selected.join(','))
|
|
@@ -201,60 +193,82 @@ export default {
|
|
|
201
193
|
}
|
|
202
194
|
})
|
|
203
195
|
|
|
204
|
-
|
|
205
|
-
if (
|
|
206
|
-
|
|
196
|
+
checked.value = aCheckedFilters.join(';')
|
|
197
|
+
if (mq.value !== 'mobile') {
|
|
198
|
+
eventBus.emit('filterChange', checked.value)
|
|
207
199
|
} else {
|
|
208
|
-
|
|
200
|
+
getResultCount()
|
|
209
201
|
}
|
|
210
202
|
return false
|
|
211
|
-
}
|
|
203
|
+
}
|
|
212
204
|
|
|
213
|
-
removeFilter(filterData) {
|
|
205
|
+
const removeFilter = (filterData) => {
|
|
214
206
|
let [filterId, filterValue] = filterData.split(':')
|
|
215
207
|
console.log('remove filter cf', filterId, filterValue)
|
|
216
|
-
|
|
208
|
+
filters.value.forEach((filter) => {
|
|
217
209
|
if (filter.id === parseInt(filterId)) {
|
|
218
210
|
if (RANGE_TYPES.includes(filter.type)) {
|
|
219
|
-
filter.selected =
|
|
220
|
-
|
|
221
|
-
|
|
211
|
+
filter.selected = ['', '']
|
|
212
|
+
filterChange()
|
|
213
|
+
applyFilters()
|
|
222
214
|
} else {
|
|
223
215
|
let found = _.findWhere(filter.values, { value: filterValue })
|
|
224
216
|
found.selected = false
|
|
225
|
-
|
|
226
|
-
|
|
217
|
+
filterChange()
|
|
218
|
+
applyFilters()
|
|
227
219
|
}
|
|
228
220
|
}
|
|
229
221
|
})
|
|
230
222
|
}
|
|
231
|
-
},
|
|
232
223
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
index,
|
|
244
|
-
|
|
245
|
-
...this.filters[index].rangeProps
|
|
224
|
+
onBeforeMount(() => {
|
|
225
|
+
getFiltersFromURL()
|
|
226
|
+
|
|
227
|
+
if (initialState.filters) {
|
|
228
|
+
filters.value = initialState.filters
|
|
229
|
+
filters.value.forEach((item, index) => {
|
|
230
|
+
if (RANGE_TYPES.includes(item.type)) {
|
|
231
|
+
if (filters.value[index].rangeProps.selected) {
|
|
232
|
+
filters.value[index].rangeProps.selected = filters.value[index].rangeProps.selected.map((item) => parseFloat(item))
|
|
233
|
+
}
|
|
234
|
+
filters.value[index] = Object.assign({}, filters.value[index], {
|
|
235
|
+
...filters.value[index].rangeProps
|
|
246
236
|
})
|
|
247
|
-
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}
|
|
237
|
+
}
|
|
238
|
+
})
|
|
239
|
+
}
|
|
251
240
|
|
|
252
|
-
|
|
253
|
-
this.removeFilter(filterData)
|
|
241
|
+
eventBus.on('removeFilter', removeFilter)
|
|
254
242
|
})
|
|
255
243
|
|
|
256
|
-
|
|
257
|
-
|
|
244
|
+
onBeforeUnmount(() => {
|
|
245
|
+
eventBus.off('removeFilter', removeFilter)
|
|
246
|
+
})
|
|
247
|
+
|
|
248
|
+
return {
|
|
249
|
+
filtersResultCount,
|
|
250
|
+
filters,
|
|
251
|
+
filtersFromURL,
|
|
252
|
+
checked,
|
|
253
|
+
frcLoading,
|
|
254
|
+
rangeTypes,
|
|
255
|
+
filterq,
|
|
256
|
+
expanded,
|
|
257
|
+
filtersFooter,
|
|
258
|
+
expand,
|
|
259
|
+
expandFilter,
|
|
260
|
+
isExpanded,
|
|
261
|
+
filterQuery,
|
|
262
|
+
filterfilter,
|
|
263
|
+
applyRange,
|
|
264
|
+
applyFilters,
|
|
265
|
+
changeRange,
|
|
266
|
+
getResultCount,
|
|
267
|
+
getFiltersFromURL,
|
|
268
|
+
filterChange,
|
|
269
|
+
removeFilter,
|
|
270
|
+
mq
|
|
271
|
+
}
|
|
258
272
|
}
|
|
259
273
|
}
|
|
260
274
|
|
|
@@ -11,8 +11,13 @@
|
|
|
11
11
|
</template>
|
|
12
12
|
|
|
13
13
|
<script>
|
|
14
|
+
import { ref, computed, onMounted } from 'vue'
|
|
15
|
+
import { useMq, useT } from '../../composables/globals'
|
|
16
|
+
import { eventBus } from '../../utils/event-bus'
|
|
17
|
+
|
|
14
18
|
export default {
|
|
15
19
|
name: 'CategorySort',
|
|
20
|
+
|
|
16
21
|
props: {
|
|
17
22
|
selected: {
|
|
18
23
|
type: String,
|
|
@@ -20,46 +25,53 @@ export default {
|
|
|
20
25
|
},
|
|
21
26
|
options: {
|
|
22
27
|
type: Array,
|
|
23
|
-
default:
|
|
24
|
-
return [
|
|
25
|
-
{ value: 'best-selling', label: this.$t('category.sortLabels.bestSelling') },
|
|
26
|
-
{ value: 'top-rated', label: this.$t('category.sortLabels.topRated') },
|
|
27
|
-
{ value: 'most-rated', label: this.$t('category.sortLabels.mostRated') },
|
|
28
|
-
{ value: 'price-lth', label: this.$t('category.sortLabels.priceAscending') },
|
|
29
|
-
{ value: 'price-htl', label: this.$t('category.sortLabels.priceDescending') },
|
|
30
|
-
{ value: 'newest', label: this.$t('category.sortLabels.newest') },
|
|
31
|
-
{ value: 'sale', label: this.$t('category.sortLabels.sale') },
|
|
32
|
-
{ value: 'thc', label: this.$t('category.sortLabels.thc') },
|
|
33
|
-
{ value: 'cbd', label: this.$t('category.sortLabels.cbd') }
|
|
34
|
-
]
|
|
35
|
-
}
|
|
28
|
+
default: () => []
|
|
36
29
|
}
|
|
37
30
|
},
|
|
38
31
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
32
|
+
setup(props) {
|
|
33
|
+
const { t: $t } = useT()
|
|
34
|
+
const mq = useMq()
|
|
35
|
+
|
|
36
|
+
const selectedValue = ref('')
|
|
37
|
+
|
|
38
|
+
const defaultOptions = computed(() => {
|
|
39
|
+
return [
|
|
40
|
+
{ value: 'best-selling', label: $t('category.sortLabels.bestSelling') },
|
|
41
|
+
{ value: 'top-rated', label: $t('category.sortLabels.topRated') },
|
|
42
|
+
{ value: 'most-rated', label: $t('category.sortLabels.mostRated') },
|
|
43
|
+
{ value: 'price-lth', label: $t('category.sortLabels.priceAscending') },
|
|
44
|
+
{ value: 'price-htl', label: $t('category.sortLabels.priceDescending') },
|
|
45
|
+
{ value: 'newest', label: $t('category.sortLabels.newest') },
|
|
46
|
+
{ value: 'sale', label: $t('category.sortLabels.sale') },
|
|
47
|
+
]
|
|
48
|
+
})
|
|
44
49
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
const finalOptions = computed(() => {
|
|
51
|
+
return props.options.length > 0 ? props.options : defaultOptions.value
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
const sortByLabel = computed(() => {
|
|
55
|
+
if (selectedValue.value && mq.value !== 'mobile') {
|
|
56
|
+
return $t('category.lSortBy')
|
|
51
57
|
}
|
|
52
|
-
|
|
53
|
-
|
|
58
|
+
return ''
|
|
59
|
+
})
|
|
54
60
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
this.$bus.$emit('sortChange', selected)
|
|
61
|
+
const sortByInput = (selected) => {
|
|
62
|
+
eventBus.emit('sortChange', selected)
|
|
58
63
|
}
|
|
59
|
-
},
|
|
60
64
|
|
|
61
|
-
|
|
62
|
-
|
|
65
|
+
onMounted(() => {
|
|
66
|
+
selectedValue.value = props.selected
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
selectedValue,
|
|
71
|
+
options: finalOptions,
|
|
72
|
+
sortByLabel,
|
|
73
|
+
sortByInput
|
|
74
|
+
}
|
|
63
75
|
}
|
|
64
76
|
}
|
|
65
77
|
</script>
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
@click="loadMore"
|
|
5
5
|
:disabled="isLoading"
|
|
6
6
|
:class="['button', buttonClass]"
|
|
7
|
+
data-test="load-more-btn"
|
|
7
8
|
>
|
|
8
9
|
<span v-if="!isLoading">{{ buttonLabel }}</span>
|
|
9
10
|
<span v-else>{{ loadingLabel }}</span>
|
|
@@ -12,10 +13,15 @@
|
|
|
12
13
|
</template>
|
|
13
14
|
|
|
14
15
|
<script>
|
|
15
|
-
import
|
|
16
|
+
import { ref, getCurrentInstance, createApp } from 'vue'
|
|
17
|
+
import { copyAppContext } from 'buefy'
|
|
18
|
+
import Price from '../Product/Price.vue'
|
|
16
19
|
|
|
17
20
|
export default {
|
|
18
21
|
name: 'LoadMore',
|
|
22
|
+
components: {
|
|
23
|
+
Price
|
|
24
|
+
},
|
|
19
25
|
props: {
|
|
20
26
|
totalPages: {
|
|
21
27
|
type: Number,
|
|
@@ -34,22 +40,20 @@ export default {
|
|
|
34
40
|
default: '',
|
|
35
41
|
}
|
|
36
42
|
},
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
async loadMore() {
|
|
46
|
-
this.isLoading = true;
|
|
43
|
+
setup(props) {
|
|
44
|
+
const isLoading = ref(false)
|
|
45
|
+
const currentPage = ref(1)
|
|
46
|
+
const hasMoreContent = ref(true)
|
|
47
|
+
const instance = getCurrentInstance()
|
|
48
|
+
|
|
49
|
+
const loadMore = async () => {
|
|
50
|
+
isLoading.value = true
|
|
47
51
|
|
|
48
52
|
try {
|
|
49
|
-
|
|
53
|
+
currentPage.value++
|
|
50
54
|
|
|
51
|
-
const url = new URL(window.location.href)
|
|
52
|
-
url.searchParams.set('page',
|
|
55
|
+
const url = new URL(window.location.href)
|
|
56
|
+
url.searchParams.set('page', currentPage.value)
|
|
53
57
|
url.searchParams.set('partial', '1')
|
|
54
58
|
|
|
55
59
|
const response = await fetch(url)
|
|
@@ -58,25 +62,37 @@ export default {
|
|
|
58
62
|
const temp = document.createElement('div')
|
|
59
63
|
temp.innerHTML = html
|
|
60
64
|
|
|
61
|
-
const loadMoreContainer =
|
|
65
|
+
const loadMoreContainer = instance.proxy.$el.closest('.load-more-container')
|
|
62
66
|
loadMoreContainer.insertAdjacentElement('beforebegin', temp)
|
|
63
67
|
|
|
64
|
-
//We need to initialize and mount all Vue components inside fetched content
|
|
65
|
-
|
|
68
|
+
// We need to initialize and mount all Vue components inside fetched content.
|
|
69
|
+
// Share the page app's context (global components like box-add-to-cart, $bus,
|
|
70
|
+
// store, i18n, compiler options), which Vue 2's Vue.extend inherited
|
|
71
|
+
const app = createApp({
|
|
66
72
|
template: temp.innerHTML,
|
|
67
73
|
components: { Price }
|
|
68
|
-
})
|
|
69
|
-
|
|
74
|
+
})
|
|
75
|
+
copyAppContext(instance.appContext.app, app)
|
|
76
|
+
app.mount(temp)
|
|
77
|
+
// Vue 2's $mount replaced the element; Vue 3 renders inside it. Unwrap, so
|
|
78
|
+
// each page's .columns sits beside the first one and gets the same spacing
|
|
79
|
+
temp.replaceWith(...temp.childNodes)
|
|
70
80
|
} catch (error) {
|
|
71
81
|
console.error('Error loading more content:', error)
|
|
72
82
|
} finally {
|
|
73
|
-
|
|
74
|
-
if(
|
|
75
|
-
|
|
76
|
-
return
|
|
83
|
+
isLoading.value = false
|
|
84
|
+
if (currentPage.value === props.totalPages) {
|
|
85
|
+
hasMoreContent.value = false
|
|
77
86
|
}
|
|
78
87
|
}
|
|
79
88
|
}
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
isLoading,
|
|
92
|
+
currentPage,
|
|
93
|
+
hasMoreContent,
|
|
94
|
+
loadMore
|
|
95
|
+
}
|
|
80
96
|
}
|
|
81
97
|
}
|
|
82
98
|
</script>
|
package/components/DeliverTo.vue
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
</template>
|
|
16
16
|
|
|
17
17
|
<script>
|
|
18
|
-
import SelectShippingCountry from '
|
|
18
|
+
import SelectShippingCountry from './SelectShippingCountry.vue'
|
|
19
19
|
|
|
20
20
|
export default {
|
|
21
21
|
name: 'DeliverTo',
|
|
@@ -26,30 +26,25 @@ export default {
|
|
|
26
26
|
required: true
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
|
-
data() {
|
|
30
|
-
return {
|
|
31
|
-
countries: []
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
29
|
computed: {
|
|
35
30
|
isNorthAmerica() {
|
|
36
|
-
|
|
37
|
-
return true
|
|
38
|
-
} else {
|
|
39
|
-
return false
|
|
40
|
-
}
|
|
31
|
+
return ['US', 'CA'].includes(this.locale.country_iso)
|
|
41
32
|
},
|
|
42
33
|
countryName() {
|
|
43
34
|
if (this.locale.country.length > 13) {
|
|
44
35
|
return this.locale.country.substring(0, 11) + '...'
|
|
45
|
-
} else {
|
|
46
|
-
return this.locale.country
|
|
47
36
|
}
|
|
37
|
+
return this.locale.country
|
|
48
38
|
}
|
|
49
39
|
},
|
|
50
40
|
methods: {
|
|
51
|
-
|
|
52
|
-
this.
|
|
41
|
+
selectCountry() {
|
|
42
|
+
this.$modalContainer.open({
|
|
43
|
+
component: SelectShippingCountry,
|
|
44
|
+
hasModalCard: true,
|
|
45
|
+
customClasses: 'wkl-modal-container',
|
|
46
|
+
canCancel: ['escape', 'outside']
|
|
47
|
+
})
|
|
53
48
|
}
|
|
54
49
|
}
|
|
55
50
|
}
|