@wikala/spmkt 3.0.0-beta.1 → 3.0.0-beta.2
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/components/Address/Edit.vue +8 -28
- package/components/Address/address.schema.js +4 -4
- package/components/Cart/CreditCard/Everyware.vue +2 -2
- package/components/Cart/CreditCard/ExtendedCreditCard.vue +2 -2
- package/components/Cart/CreditCard/StandardCreditCard.vue +2 -2
- package/components/Cart/Delivery/Delivery.vue +2 -2
- package/components/Cart/Delivery/ReservationSlots.vue +3 -3
- package/components/Cart/Payment/Payment.vue +2 -2
- package/components/Cart/ShoppingCart.vue +2 -2
- package/components/Cart/Store/getters.js +5 -3
- package/components/Cart/Store/mutations.js +8 -6
- package/components/Cart/UserIdentity.vue +2 -2
- package/components/Category/CategoryFilter.vue +37 -34
- package/components/Gmaps/GmapsAutocomplete.vue +2 -2
- package/components/Gmaps/GmapsLocations.vue +2 -2
- package/components/Product/AddToCart.vue +10 -7
- package/components/Product/CompareBox.vue +6 -4
- package/components/Product/Lookup.vue +2 -2
- package/components/Product/ProductAutocomplete.vue +2 -2
- package/components/Product/Variants.vue +16 -16
- package/components/Product/reviews-questions/ReviewImages.vue +4 -4
- package/components/QuantityInput.vue +2 -2
- package/package.json +1 -1
- package/utils/filters.js +54 -3
- package/utils/google/gmaps.js +2 -2
- package/utils/parse-url-filters.js +19 -0
- package/components/Category/FilterMixin.js +0 -70
|
@@ -250,10 +250,10 @@
|
|
|
250
250
|
<script setup>
|
|
251
251
|
import { ref, computed, watch, onMounted } from 'vue'
|
|
252
252
|
import { useInitialState, useLocale, useT } from '../../composables/globals'
|
|
253
|
-
import
|
|
253
|
+
import contains from 'underscore/modules/contains.js'
|
|
254
254
|
import gmaps from '../../utils/google/gmaps'
|
|
255
255
|
import GmapsAutocomplete from '../Gmaps/GmapsAutocomplete.vue'
|
|
256
|
-
import { addressSchema } from './address.schema'
|
|
256
|
+
import { addressSchema, findCountry, findProvince } from './address.schema'
|
|
257
257
|
|
|
258
258
|
import PostalCode from './PostalCode.vue'
|
|
259
259
|
import Address from './Address.vue'
|
|
@@ -345,7 +345,7 @@ const onEditAutocompleteAddress = () => {
|
|
|
345
345
|
const gmapsPlaceInput = (pl) => {
|
|
346
346
|
showEditAutocompleteAddress.value = true
|
|
347
347
|
autocompleteAddress.value = pl.address
|
|
348
|
-
let country = findCountry(autocompleteAddress.value.country_iso)
|
|
348
|
+
let country = findCountry(autocompleteAddress.value.country_iso, props.countries)
|
|
349
349
|
if(country) {
|
|
350
350
|
autocompleteAddress.value.country_id = country.id
|
|
351
351
|
let province = findProvince(autocompleteAddress.value.state_abbr, country.states)
|
|
@@ -393,7 +393,7 @@ const onSelectCountry = (selected) => {
|
|
|
393
393
|
if (selected.iso == 'CA') {
|
|
394
394
|
fStateLabel.value = $t('address.stateCanada')
|
|
395
395
|
}
|
|
396
|
-
if (
|
|
396
|
+
if (contains(['US', 'CA'], selected.iso)) {
|
|
397
397
|
fStateVisible.value = true
|
|
398
398
|
}
|
|
399
399
|
props.addressData.country_id = selected.id
|
|
@@ -439,26 +439,6 @@ const setCoordinates = async () => {
|
|
|
439
439
|
props.addressData.coordinates = await gmaps.geocodeAddress(Address.getFormatted(props.addressData))
|
|
440
440
|
}
|
|
441
441
|
|
|
442
|
-
const findCountry = (query) => {
|
|
443
|
-
let field = 'iso'
|
|
444
|
-
if(Number.isInteger(query)) {
|
|
445
|
-
field = 'id'
|
|
446
|
-
}
|
|
447
|
-
return _.findWhere(props.countries, {
|
|
448
|
-
[field]: query
|
|
449
|
-
})
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
const findProvince = (query, states) => {
|
|
453
|
-
let field = 'abbr'
|
|
454
|
-
if(Number.isInteger(query)) {
|
|
455
|
-
field = 'id'
|
|
456
|
-
}
|
|
457
|
-
return _.findWhere(states, {
|
|
458
|
-
[field]: query
|
|
459
|
-
})
|
|
460
|
-
}
|
|
461
|
-
|
|
462
442
|
const onChangeIsBusiness = (e) => {
|
|
463
443
|
if(e) {
|
|
464
444
|
props.addressData.type = 'business'
|
|
@@ -477,16 +457,16 @@ onMounted(async () => {
|
|
|
477
457
|
|
|
478
458
|
if (internationalShipping === 0) {
|
|
479
459
|
if(props.addressData.country_id) {
|
|
480
|
-
initialCountry = findCountry(props.addressData.country_id)
|
|
460
|
+
initialCountry = findCountry(props.addressData.country_id, props.countries)
|
|
481
461
|
} else {
|
|
482
|
-
initialCountry = findCountry(localizedVersionCountryISO)
|
|
462
|
+
initialCountry = findCountry(localizedVersionCountryISO, props.countries)
|
|
483
463
|
}
|
|
484
464
|
countryInputDisabled.value = true
|
|
485
465
|
} else {
|
|
486
466
|
if (props.addressData.country_id) {
|
|
487
|
-
initialCountry = findCountry(props.addressData.country_id)
|
|
467
|
+
initialCountry = findCountry(props.addressData.country_id, props.countries)
|
|
488
468
|
} else {
|
|
489
|
-
initialCountry = findCountry($LC?.country_iso)
|
|
469
|
+
initialCountry = findCountry($LC?.country_iso, props.countries)
|
|
490
470
|
}
|
|
491
471
|
}
|
|
492
472
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import
|
|
2
|
+
import findWhere from 'underscore/modules/findWhere.js'
|
|
3
3
|
|
|
4
4
|
export const addressSchema = {
|
|
5
5
|
type: '',
|
|
@@ -28,7 +28,7 @@ export const findCountry = (query, countries) => {
|
|
|
28
28
|
if(Number.isInteger(query)) {
|
|
29
29
|
field = 'id'
|
|
30
30
|
}
|
|
31
|
-
return
|
|
31
|
+
return findWhere(countries, {
|
|
32
32
|
[field]: query
|
|
33
33
|
})
|
|
34
34
|
}
|
|
@@ -38,7 +38,7 @@ export const findProvince = (query, states) => {
|
|
|
38
38
|
if(Number.isInteger(query)) {
|
|
39
39
|
field = 'id'
|
|
40
40
|
}
|
|
41
|
-
return
|
|
41
|
+
return findWhere(states, {
|
|
42
42
|
[field]: query
|
|
43
43
|
})
|
|
44
44
|
}
|
|
@@ -54,7 +54,7 @@ export const createLocalizedVersionAddress = (initialState, localeSettings = {},
|
|
|
54
54
|
if (internationalShipping === 0) {
|
|
55
55
|
initialCountry = findCountry(localizedVersionCountryISO, countries)
|
|
56
56
|
} else {
|
|
57
|
-
initialCountry = findCountry(localeSettings.country_iso)
|
|
57
|
+
initialCountry = findCountry(localeSettings.country_iso, countries)
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
if (initialCountry) {
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
</template>
|
|
77
77
|
|
|
78
78
|
<script>
|
|
79
|
-
import
|
|
79
|
+
import range from 'underscore/modules/range.js'
|
|
80
80
|
|
|
81
81
|
export default {
|
|
82
82
|
name: 'Everyware',
|
|
@@ -112,7 +112,7 @@ export default {
|
|
|
112
112
|
computed: {
|
|
113
113
|
years: () => {
|
|
114
114
|
let currentYear = new Date().getFullYear()
|
|
115
|
-
return
|
|
115
|
+
return range(currentYear, currentYear + 11, 1)
|
|
116
116
|
}
|
|
117
117
|
},
|
|
118
118
|
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
</template>
|
|
88
88
|
|
|
89
89
|
<script>
|
|
90
|
-
import
|
|
90
|
+
import range from 'underscore/modules/range.js'
|
|
91
91
|
|
|
92
92
|
import PostalCode from '../../Address/PostalCode'
|
|
93
93
|
|
|
@@ -128,7 +128,7 @@ export default {
|
|
|
128
128
|
computed: {
|
|
129
129
|
years: () => {
|
|
130
130
|
let currentYear = new Date().getFullYear()
|
|
131
|
-
return
|
|
131
|
+
return range(currentYear, currentYear + 11, 1)
|
|
132
132
|
}
|
|
133
133
|
},
|
|
134
134
|
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
</template>
|
|
78
78
|
|
|
79
79
|
<script>
|
|
80
|
-
import
|
|
80
|
+
import range from 'underscore/modules/range.js'
|
|
81
81
|
|
|
82
82
|
export default {
|
|
83
83
|
name: 'StandardCreditCard',
|
|
@@ -109,7 +109,7 @@ export default {
|
|
|
109
109
|
computed: {
|
|
110
110
|
years: () => {
|
|
111
111
|
let currentYear = new Date().getFullYear()
|
|
112
|
-
return
|
|
112
|
+
return range(currentYear, currentYear + 11, 1)
|
|
113
113
|
}
|
|
114
114
|
},
|
|
115
115
|
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
|
|
85
85
|
<script>
|
|
86
86
|
|
|
87
|
-
import
|
|
87
|
+
import findWhere from 'underscore/modules/findWhere.js'
|
|
88
88
|
import { mapGetters, mapState, mapActions, mapMutations } from 'vuex'
|
|
89
89
|
|
|
90
90
|
import { Cart } from '../../../api'
|
|
@@ -201,7 +201,7 @@ export default {
|
|
|
201
201
|
this.deliveryType = pl
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
-
let deliveryType =
|
|
204
|
+
let deliveryType = findWhere(this.deliveryTypes, { type: pl })
|
|
205
205
|
if(deliveryType && deliveryType.methods.length > 0) {
|
|
206
206
|
//console.log('setDeliveryMethodId to', deliveryType.methods[0]['id'])
|
|
207
207
|
this.setDeliveryMethodId(deliveryType.methods[0]['id'])
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
|
|
29
29
|
<script>
|
|
30
30
|
|
|
31
|
-
import
|
|
31
|
+
import findWhere from 'underscore/modules/findWhere.js'
|
|
32
32
|
|
|
33
33
|
export default {
|
|
34
34
|
name: 'ReservationSlots',
|
|
@@ -78,9 +78,9 @@ export default {
|
|
|
78
78
|
},
|
|
79
79
|
mounted() {
|
|
80
80
|
if(this.modelValue && this.slots) {
|
|
81
|
-
this.selectedDate =
|
|
81
|
+
this.selectedDate = findWhere(this.slots, { day: this.modelValue.substr(0, this.modelValue.indexOf(' '))} )
|
|
82
82
|
if(this.selectedDate) {
|
|
83
|
-
this.selectedTime =
|
|
83
|
+
this.selectedTime = findWhere(this.selectedDate.slots, { start: this.modelValue.substr(this.modelValue.indexOf(' ')+1, 5) })
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
}
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
<script>
|
|
85
85
|
|
|
86
86
|
import { mapState, mapMutations, mapActions } from 'vuex'
|
|
87
|
-
import
|
|
87
|
+
import findWhere from 'underscore/modules/findWhere.js'
|
|
88
88
|
import animateCSS from '../../../utils/animate'
|
|
89
89
|
|
|
90
90
|
import { zsig } from '../../../utils/rc-token'
|
|
@@ -178,7 +178,7 @@ export default {
|
|
|
178
178
|
|
|
179
179
|
onPaymentMethodsInput(pl) {
|
|
180
180
|
this.paymentMethodError = false
|
|
181
|
-
this.paymentMethod =
|
|
181
|
+
this.paymentMethod = findWhere(this.paymentMethods, {id: pl})
|
|
182
182
|
},
|
|
183
183
|
|
|
184
184
|
billingAddressSameAsShippingChange(value) {
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
<script>
|
|
57
57
|
|
|
58
58
|
import { mapState, mapMutations, mapActions, mapGetters } from 'vuex'
|
|
59
|
-
import
|
|
59
|
+
import invert from 'underscore/modules/invert.js'
|
|
60
60
|
|
|
61
61
|
import GoogleAnalyticsEEC from '../../utils/google/google-analytics-eec.js'
|
|
62
62
|
|
|
@@ -137,7 +137,7 @@ export default {
|
|
|
137
137
|
|
|
138
138
|
if (this.initialState && this.initialState.cart) {
|
|
139
139
|
this.setCart(this.initialState.cart)
|
|
140
|
-
GoogleAnalyticsEEC.checkoutStep(
|
|
140
|
+
GoogleAnalyticsEEC.checkoutStep(invert(this.steps)[parseInt(this.activeStep)], this.cartStructureEEC)
|
|
141
141
|
}
|
|
142
142
|
if (this.initialState && this.initialState.accepted_payment_methods) {
|
|
143
143
|
this.setAcceptedPaymentMethods(this.initialState.accepted_payment_methods)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import invert from "underscore/modules/invert.js";
|
|
2
|
+
import findWhere from "underscore/modules/findWhere.js";
|
|
2
3
|
|
|
3
4
|
export default {
|
|
4
5
|
cartMode: (state) => {
|
|
@@ -41,7 +42,7 @@ export default {
|
|
|
41
42
|
},
|
|
42
43
|
|
|
43
44
|
activeStepLabel: (state) => {
|
|
44
|
-
return
|
|
45
|
+
return invert(state.steps)[parseInt(state.activeStep)]
|
|
45
46
|
},
|
|
46
47
|
|
|
47
48
|
stepsDisabled: (state) => {
|
|
@@ -71,7 +72,8 @@ export default {
|
|
|
71
72
|
|
|
72
73
|
advancedOrdering: (state) => {
|
|
73
74
|
if(state.checkoutRequestData.delivery_type && state.deliveryTypes && state.deliveryTypes.length > 0) {
|
|
74
|
-
|
|
75
|
+
let deliveryType = findWhere(state.deliveryTypes, { type: state.checkoutRequestData.delivery_type })
|
|
76
|
+
return deliveryType?.methods?.[0]?.advanced_ordering ?? false
|
|
75
77
|
} else {
|
|
76
78
|
return false
|
|
77
79
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
|
|
2
2
|
// noinspection DuplicatedCode
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import isString from 'underscore/modules/isString.js'
|
|
5
|
+
import invert from 'underscore/modules/invert.js'
|
|
6
|
+
import isEmpty from 'underscore/modules/isEmpty.js'
|
|
5
7
|
import randomId from '../../../utils/random-id'
|
|
6
8
|
import GoogleAnalyticsEEC from '../../../utils/google/google-analytics-eec'
|
|
7
9
|
import { addressSchema } from '../../Address/address.schema'
|
|
@@ -20,16 +22,16 @@ export default {
|
|
|
20
22
|
|
|
21
23
|
setActiveStep(state, step, siteName = '') {
|
|
22
24
|
let intStep = 0
|
|
23
|
-
if(
|
|
25
|
+
if(isString(step)) {
|
|
24
26
|
intStep = state.steps[step]
|
|
25
27
|
} else {
|
|
26
28
|
intStep = parseInt(step)
|
|
27
29
|
}
|
|
28
30
|
state.activeStep = intStep
|
|
29
|
-
history.pushState(null, siteName + ' Cart', '?step=' +
|
|
31
|
+
history.pushState(null, siteName + ' Cart', '?step=' + invert(state.steps)[intStep])
|
|
30
32
|
|
|
31
33
|
// `this` is the store in a mutation
|
|
32
|
-
GoogleAnalyticsEEC.checkoutStep(
|
|
34
|
+
GoogleAnalyticsEEC.checkoutStep(invert(state.steps)[intStep], this.getters.cartStructureEEC)
|
|
33
35
|
|
|
34
36
|
state.stepKey[state.activeStep]++
|
|
35
37
|
state.stepChangeIncrement++
|
|
@@ -59,7 +61,7 @@ export default {
|
|
|
59
61
|
},
|
|
60
62
|
|
|
61
63
|
setDeliveryAddress(state, address) {
|
|
62
|
-
if(!
|
|
64
|
+
if(!isEmpty(address)) {
|
|
63
65
|
if (address.id) {
|
|
64
66
|
state.checkoutRequestData.shipping_address_id = address.id
|
|
65
67
|
}
|
|
@@ -72,7 +74,7 @@ export default {
|
|
|
72
74
|
},
|
|
73
75
|
|
|
74
76
|
setBillingAddress(state, address) {
|
|
75
|
-
if(!
|
|
77
|
+
if(!isEmpty(address)) {
|
|
76
78
|
if (address.id) {
|
|
77
79
|
state.checkoutRequestData.billing_address_id = address.id
|
|
78
80
|
}
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
|
|
69
69
|
<script>
|
|
70
70
|
|
|
71
|
-
import
|
|
71
|
+
import debounce from 'underscore/modules/debounce.js'
|
|
72
72
|
|
|
73
73
|
import { request } from '../../api'
|
|
74
74
|
|
|
@@ -163,7 +163,7 @@ export default {
|
|
|
163
163
|
this.checkingEmail = false
|
|
164
164
|
},
|
|
165
165
|
|
|
166
|
-
checkTyping:
|
|
166
|
+
checkTyping: debounce(function () {
|
|
167
167
|
this.check()
|
|
168
168
|
}, 300),
|
|
169
169
|
|
|
@@ -52,27 +52,18 @@
|
|
|
52
52
|
<script>
|
|
53
53
|
import { ref, reactive, onBeforeMount, onBeforeUnmount } from 'vue'
|
|
54
54
|
import { useInitialState, useMq } from '../../composables/globals'
|
|
55
|
-
import
|
|
55
|
+
import debounce from 'underscore/modules/debounce.js'
|
|
56
|
+
import isEmpty from 'underscore/modules/isEmpty.js'
|
|
57
|
+
import pluck from 'underscore/modules/pluck.js'
|
|
58
|
+
import where from 'underscore/modules/where.js'
|
|
59
|
+
import findWhere from 'underscore/modules/findWhere.js'
|
|
56
60
|
import config from '../../config'
|
|
57
61
|
import { request } from '../../api'
|
|
58
62
|
import { eventBus } from '../../utils/event-bus'
|
|
63
|
+
import parseUrlFilters from '../../utils/parse-url-filters'
|
|
59
64
|
|
|
60
65
|
import RangeInput from '../../components/RangeInput.vue'
|
|
61
66
|
|
|
62
|
-
let getFiltersResultCount = _.debounce(
|
|
63
|
-
async (filtersQueryString) => {
|
|
64
|
-
let url = location.pathname + '?f=' + filtersQueryString
|
|
65
|
-
let frc = await request({
|
|
66
|
-
baseURL: config.BASE_URL,
|
|
67
|
-
url: url,
|
|
68
|
-
method: 'get'
|
|
69
|
-
})
|
|
70
|
-
return frc.data.results
|
|
71
|
-
},
|
|
72
|
-
1000,
|
|
73
|
-
{ leading: false }
|
|
74
|
-
)
|
|
75
|
-
|
|
76
67
|
const RANGE_TYPES = ['range_int', 'range_float', 'double_range']
|
|
77
68
|
|
|
78
69
|
export default {
|
|
@@ -150,26 +141,31 @@ export default {
|
|
|
150
141
|
filters.value[index] = Object.assign({}, filters.value[index], { selected: val })
|
|
151
142
|
}
|
|
152
143
|
|
|
153
|
-
|
|
144
|
+
// Underscore's debounce only runs the trailing call and hands callers the previous result,
|
|
145
|
+
// so the request writes its own result, and drops it if the selection changed while in flight
|
|
146
|
+
const fetchResultCount = debounce(async () => {
|
|
147
|
+
let filtersQueryString = checked.value
|
|
148
|
+
let frc = await request({
|
|
149
|
+
baseURL: config.BASE_URL,
|
|
150
|
+
url: location.pathname + '?f=' + filtersQueryString,
|
|
151
|
+
method: 'get'
|
|
152
|
+
})
|
|
153
|
+
if (filtersQueryString !== checked.value) {
|
|
154
|
+
return
|
|
155
|
+
}
|
|
156
|
+
filtersResultCount.value = frc.data.results
|
|
157
|
+
frcLoading.value = false
|
|
158
|
+
}, 1000)
|
|
159
|
+
|
|
160
|
+
const getResultCount = () => {
|
|
154
161
|
filtersResultCount.value = -1
|
|
155
162
|
frcLoading.value = true
|
|
156
|
-
|
|
157
|
-
frcLoading.value = false
|
|
163
|
+
fetchResultCount()
|
|
158
164
|
}
|
|
159
165
|
|
|
160
166
|
const getFiltersFromURL = () => {
|
|
161
167
|
let categoryUrl = new URL(window.location.href)
|
|
162
|
-
|
|
163
|
-
if (!urlFilters) {
|
|
164
|
-
filtersFromURL.value = []
|
|
165
|
-
return false
|
|
166
|
-
}
|
|
167
|
-
let filtersStruct = {}
|
|
168
|
-
urlFilters.split(';').forEach((filter) => {
|
|
169
|
-
let fvalues = filter.split(':')
|
|
170
|
-
filtersStruct[fvalues[0]] = fvalues[1].split(',')
|
|
171
|
-
})
|
|
172
|
-
filtersFromURL.value = filtersStruct
|
|
168
|
+
filtersFromURL.value = parseUrlFilters(categoryUrl.searchParams.get('f'))
|
|
173
169
|
}
|
|
174
170
|
|
|
175
171
|
const filterChange = () => {
|
|
@@ -182,12 +178,12 @@ export default {
|
|
|
182
178
|
|
|
183
179
|
filters.value.forEach((filter) => {
|
|
184
180
|
if (RANGE_TYPES.includes(filter.type)) {
|
|
185
|
-
if (!
|
|
181
|
+
if (!isEmpty(filter.selected)) {
|
|
186
182
|
aCheckedFilters.push(filter.id + ':' + filter.selected.join(','))
|
|
187
183
|
}
|
|
188
184
|
} else {
|
|
189
|
-
let selected =
|
|
190
|
-
if (!
|
|
185
|
+
let selected = pluck(where(filter.values, { selected: true }), 'value')
|
|
186
|
+
if (!isEmpty(selected)) {
|
|
191
187
|
aCheckedFilters.push(filter.id + ':' + selected.join(','))
|
|
192
188
|
}
|
|
193
189
|
}
|
|
@@ -203,7 +199,10 @@ export default {
|
|
|
203
199
|
}
|
|
204
200
|
|
|
205
201
|
const removeFilter = (filterData) => {
|
|
206
|
-
|
|
202
|
+
// Split on the first ':' only, as parseUrlFilters does, since values can contain colons
|
|
203
|
+
let sep = filterData.indexOf(':')
|
|
204
|
+
let filterId = filterData.slice(0, sep)
|
|
205
|
+
let filterValue = filterData.slice(sep + 1)
|
|
207
206
|
console.log('remove filter cf', filterId, filterValue)
|
|
208
207
|
filters.value.forEach((filter) => {
|
|
209
208
|
if (filter.id === parseInt(filterId)) {
|
|
@@ -212,7 +211,10 @@ export default {
|
|
|
212
211
|
filterChange()
|
|
213
212
|
applyFilters()
|
|
214
213
|
} else {
|
|
215
|
-
let found =
|
|
214
|
+
let found = findWhere(filter.values, { value: filterValue })
|
|
215
|
+
if (!found) {
|
|
216
|
+
return
|
|
217
|
+
}
|
|
216
218
|
found.selected = false
|
|
217
219
|
filterChange()
|
|
218
220
|
applyFilters()
|
|
@@ -243,6 +245,7 @@ export default {
|
|
|
243
245
|
|
|
244
246
|
onBeforeUnmount(() => {
|
|
245
247
|
eventBus.off('removeFilter', removeFilter)
|
|
248
|
+
fetchResultCount.cancel()
|
|
246
249
|
})
|
|
247
250
|
|
|
248
251
|
return {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
|
|
34
34
|
<script setup>
|
|
35
35
|
import { ref } from 'vue'
|
|
36
|
-
import
|
|
36
|
+
import debounce from 'underscore/modules/debounce.js'
|
|
37
37
|
// Defines window.customEventBus, which hosts call to announce that Maps has loaded
|
|
38
38
|
import '../../utils/custom-event-bus'
|
|
39
39
|
import gmaps from '../../utils/google/gmaps'
|
|
@@ -80,7 +80,7 @@ const formatSuggestion = (prediction) => prediction.text.toString()
|
|
|
80
80
|
|
|
81
81
|
const countryCodes = () => props.restrictToCountries.filter(c => typeof c === 'string' && c.length > 0)
|
|
82
82
|
|
|
83
|
-
const fetchSuggestions =
|
|
83
|
+
const fetchSuggestions = debounce(async (query) => {
|
|
84
84
|
const places = placesApi()
|
|
85
85
|
if (!query || !places?.AutocompleteSuggestion) {
|
|
86
86
|
suggestions.value = []
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
</template>
|
|
32
32
|
|
|
33
33
|
<script>
|
|
34
|
-
import
|
|
34
|
+
import pluck from 'underscore/modules/pluck.js'
|
|
35
35
|
|
|
36
36
|
import { formatNumber } from '../../utils/filters'
|
|
37
37
|
import '../../utils/custom-event-bus'
|
|
@@ -192,7 +192,7 @@ export default {
|
|
|
192
192
|
if (this.nearestLocations[0].distance < 0.1) {
|
|
193
193
|
boundsSlice = 1
|
|
194
194
|
}
|
|
195
|
-
this.updateMapBounds([this.userLocationMarker, ...
|
|
195
|
+
this.updateMapBounds([this.userLocationMarker, ...pluck(this.nearestLocations.slice(0, boundsSlice), 'marker')])
|
|
196
196
|
|
|
197
197
|
if (!address.address.postcode && !address.address.city) {
|
|
198
198
|
this.map.setCenter(address.coordinates)
|
|
@@ -17,7 +17,10 @@
|
|
|
17
17
|
<script setup>
|
|
18
18
|
import { ref, computed, onMounted, onBeforeUnmount, nextTick, getCurrentInstance } from 'vue'
|
|
19
19
|
import { useBuefy, useBus, useMq, useT } from '../../composables/globals'
|
|
20
|
-
import
|
|
20
|
+
import pluck from 'underscore/modules/pluck.js'
|
|
21
|
+
import findWhere from 'underscore/modules/findWhere.js'
|
|
22
|
+
import isEmpty from 'underscore/modules/isEmpty.js'
|
|
23
|
+
import contains from 'underscore/modules/contains.js'
|
|
21
24
|
import animateCSS from '../../utils/animate'
|
|
22
25
|
import GoogleAnalyticsEEC from '../../utils/google/google-analytics-eec.js'
|
|
23
26
|
import { Cart } from '../../api'
|
|
@@ -77,11 +80,11 @@ const eecProduct = () => {
|
|
|
77
80
|
if (selectedVariant.value) {
|
|
78
81
|
eecProduct = {
|
|
79
82
|
item_id: props.product.id, //selectedVariant.value.id
|
|
80
|
-
item_name: props.product.name, //props.product.name + ' - ' +
|
|
83
|
+
item_name: props.product.name, //props.product.name + ' - ' + pluck(selectedVariant.value.options, 'value').join(', '),
|
|
81
84
|
price: selectedVariant.value.price,
|
|
82
85
|
item_brand: props.product.brand ? props.product.brand.name : '',
|
|
83
86
|
item_category: props.product?.category?.path.startsWith('/') ? props.product?.category?.path.substr(1) : props.product?.category?.path,
|
|
84
|
-
item_variant:
|
|
87
|
+
item_variant: pluck(selectedVariant.value.options, 'value').join(', '),
|
|
85
88
|
quantity: parseInt(qty.value)
|
|
86
89
|
}
|
|
87
90
|
}
|
|
@@ -93,7 +96,7 @@ const productDetails = () => {
|
|
|
93
96
|
let product = eecProduct()
|
|
94
97
|
product.image_url = props.product.images && props.product.images[0] ? props.product.images[0].url : ''
|
|
95
98
|
if (selectedVariant.value) {
|
|
96
|
-
let variantImage =
|
|
99
|
+
let variantImage = findWhere(props.product.images, { id: selectedVariant.value.default_image_id })
|
|
97
100
|
product.image_url = variantImage?.url
|
|
98
101
|
}
|
|
99
102
|
return product
|
|
@@ -131,7 +134,7 @@ const updateCart = async () => {
|
|
|
131
134
|
const variantSelected = () => {
|
|
132
135
|
variantModalActive.value = false
|
|
133
136
|
//console.log('variant ids ', variantIds.value, 'product ', product_id.value)
|
|
134
|
-
if (!
|
|
137
|
+
if (!isEmpty(variantIds.value) && !contains(variantIds.value, product_id.value)) {
|
|
135
138
|
$bus.emit('noVariantSelected')
|
|
136
139
|
if (mq.value === 'mobile' && variantModalActive.value) {
|
|
137
140
|
animateCSS('.wkl-modal-container .variant-options', 'pulse')
|
|
@@ -203,7 +206,7 @@ const onSelectVariant = (variant_id) => {
|
|
|
203
206
|
submitEnabled.value = false
|
|
204
207
|
product_id.value = null
|
|
205
208
|
} else {
|
|
206
|
-
selectedVariant.value =
|
|
209
|
+
selectedVariant.value = findWhere(props.product.variants, {
|
|
207
210
|
id: parseInt(variant_id)
|
|
208
211
|
})
|
|
209
212
|
submitEnabled.value = true
|
|
@@ -267,7 +270,7 @@ onMounted(() => {
|
|
|
267
270
|
if (!product_id.value && props.product.id) {
|
|
268
271
|
product_id.value = props.product.id
|
|
269
272
|
if (props.product.variants && props.product.variants.length > 0) {
|
|
270
|
-
variantIds.value =
|
|
273
|
+
variantIds.value = pluck(props.product.variants, 'id')
|
|
271
274
|
}
|
|
272
275
|
}
|
|
273
276
|
cleanupScroll = handleScroll()
|
|
@@ -22,7 +22,9 @@
|
|
|
22
22
|
<script setup>
|
|
23
23
|
import { ref, onMounted, onBeforeUnmount } from 'vue'
|
|
24
24
|
import { useBuefy, useMq, useT } from '../../composables/globals'
|
|
25
|
-
import
|
|
25
|
+
import compact from 'underscore/modules/compact.js'
|
|
26
|
+
import reject from 'underscore/modules/reject.js'
|
|
27
|
+
import findWhere from 'underscore/modules/findWhere.js'
|
|
26
28
|
import Cookie from 'js-cookie'
|
|
27
29
|
import { eventBus } from '../../utils/event-bus'
|
|
28
30
|
|
|
@@ -58,7 +60,7 @@ const initCompareList = () => {
|
|
|
58
60
|
console.log('Cannot parse compareList', Cookie.get('compareList'))
|
|
59
61
|
}
|
|
60
62
|
if (cCompareList) {
|
|
61
|
-
products.value =
|
|
63
|
+
products.value = compact(cCompareList)
|
|
62
64
|
products.value.forEach((product) => {
|
|
63
65
|
setCompareIconStatus(product.id, 'on')
|
|
64
66
|
})
|
|
@@ -104,7 +106,7 @@ const compare = () => {
|
|
|
104
106
|
}
|
|
105
107
|
|
|
106
108
|
const removeProd = (id) => {
|
|
107
|
-
setProducts(
|
|
109
|
+
setProducts(reject(products.value, (product) => product.id == id))
|
|
108
110
|
setCompareIconStatus(id, 'off')
|
|
109
111
|
}
|
|
110
112
|
|
|
@@ -129,7 +131,7 @@ const hideCompareBox = () => {
|
|
|
129
131
|
}
|
|
130
132
|
|
|
131
133
|
const handleCompareProduct = (productData) => {
|
|
132
|
-
if (
|
|
134
|
+
if (findWhere(products.value, { id: productData.id })) {
|
|
133
135
|
removeProd(productData.id)
|
|
134
136
|
} else {
|
|
135
137
|
if (products.value.length > 0 && productData.att_template_id !== attTemplateId.value) {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
<script setup>
|
|
29
29
|
import { ref, onMounted, onBeforeUnmount } from 'vue'
|
|
30
30
|
import { useBuefy, useBus } from '../../composables/globals'
|
|
31
|
-
import
|
|
31
|
+
import debounce from 'underscore/modules/debounce.js'
|
|
32
32
|
import { request } from '../../api'
|
|
33
33
|
|
|
34
34
|
defineOptions({ name: 'ProductLookup' })
|
|
@@ -63,7 +63,7 @@ const isFetching = ref(false)
|
|
|
63
63
|
const selectedIds = ref([])
|
|
64
64
|
|
|
65
65
|
// Methods
|
|
66
|
-
const getAsyncData =
|
|
66
|
+
const getAsyncData = debounce(function (query) {
|
|
67
67
|
if (!query.length) {
|
|
68
68
|
data.value = []
|
|
69
69
|
return
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
</template>
|
|
40
40
|
<script setup>
|
|
41
41
|
import { ref, inject, onMounted } from 'vue'
|
|
42
|
-
import
|
|
42
|
+
import debounce from 'underscore/modules/debounce.js'
|
|
43
43
|
import liveAddEventListener from '../../utils/native-dom'
|
|
44
44
|
import { Product } from '../../api'
|
|
45
45
|
|
|
@@ -65,7 +65,7 @@ const isFetching = ref(false)
|
|
|
65
65
|
const enter = ref(true)
|
|
66
66
|
const active = ref(0)
|
|
67
67
|
|
|
68
|
-
const searchProducts =
|
|
68
|
+
const searchProducts = debounce((query_string) => {
|
|
69
69
|
if (!query_string.length) {
|
|
70
70
|
data.value = []
|
|
71
71
|
return
|
|
@@ -36,7 +36,6 @@
|
|
|
36
36
|
import { ref, reactive, computed, watch, onMounted, onBeforeUnmount, nextTick } from 'vue'
|
|
37
37
|
import { formatMoney } from '../../utils/filters'
|
|
38
38
|
import { useBus } from '../../composables/globals'
|
|
39
|
-
import _ from 'underscore'
|
|
40
39
|
import formatDate from '../../utils/format-date'
|
|
41
40
|
|
|
42
41
|
const props = defineProps({
|
|
@@ -97,7 +96,7 @@ watch(() => props.product, (val) => {
|
|
|
97
96
|
// Methods
|
|
98
97
|
function setOptionCombinations() {
|
|
99
98
|
optionCombinations.value = []
|
|
100
|
-
let allOptions =
|
|
99
|
+
let allOptions = productVariants.value.map((pv) => pv.options)
|
|
101
100
|
allOptions.forEach((options) => {
|
|
102
101
|
let v = []
|
|
103
102
|
options.forEach((o) => {
|
|
@@ -112,13 +111,15 @@ function setFittingUnselected() {
|
|
|
112
111
|
fittingUnselected.value = []
|
|
113
112
|
if (selectedEntries.value.length === 1) {
|
|
114
113
|
let selectedKey = parseInt(Object.keys(selectedOptions)[0])
|
|
115
|
-
let
|
|
116
|
-
|
|
114
|
+
let selectedKeyOption = productVariantOptions.value.find((pvo) => pvo.id === selectedKey)
|
|
115
|
+
if (selectedKeyOption) {
|
|
116
|
+
fitting = selectedKeyOption.values.map((skov) => selectedKey + '-' + skov)
|
|
117
|
+
}
|
|
117
118
|
}
|
|
118
119
|
selectedEntries.value.forEach((so) => {
|
|
119
|
-
fitting.push(
|
|
120
|
+
fitting.push(optionCombinations.value.filter((c) => c.includes(so)))
|
|
120
121
|
})
|
|
121
|
-
fittingUnselected.value =
|
|
122
|
+
fittingUnselected.value = [...new Set(fitting.flat(Infinity))]
|
|
122
123
|
}
|
|
123
124
|
|
|
124
125
|
function getMatchingVariant() {
|
|
@@ -126,13 +127,13 @@ function getMatchingVariant() {
|
|
|
126
127
|
return false
|
|
127
128
|
}
|
|
128
129
|
let match = false
|
|
129
|
-
|
|
130
|
+
productVariants.value.forEach((pv) => {
|
|
130
131
|
let pvoptions = pv.options
|
|
131
132
|
.map((pvo) => {
|
|
132
133
|
return pvo.attribute_id + '-' + pvo.value
|
|
133
134
|
})
|
|
134
135
|
.sort()
|
|
135
|
-
if (
|
|
136
|
+
if (selectedEntries.value.every((se) => pvoptions.includes(se))) {
|
|
136
137
|
match = pv
|
|
137
138
|
}
|
|
138
139
|
})
|
|
@@ -149,7 +150,7 @@ function removeUnfitting(optionValue, optionId) {
|
|
|
149
150
|
continue
|
|
150
151
|
}
|
|
151
152
|
let kv = selectedKey + '-' + selectedOptions[selectedKey]
|
|
152
|
-
let fits =
|
|
153
|
+
let fits = optionCombinations.value.some((c) => {
|
|
153
154
|
return c.includes(kv) && c.includes(akv)
|
|
154
155
|
})
|
|
155
156
|
if (fits === false) {
|
|
@@ -289,7 +290,7 @@ function getVariantByOption(optionId, optionValue) {
|
|
|
289
290
|
return {}
|
|
290
291
|
}
|
|
291
292
|
let match = {}
|
|
292
|
-
|
|
293
|
+
productVariants.value.forEach((pv) => {
|
|
293
294
|
if(pv.in_stock && pv.options[0].attribute_id === optionId && pv.options[0].value === optionValue) {
|
|
294
295
|
match = pv
|
|
295
296
|
}
|
|
@@ -301,7 +302,7 @@ function getVariantFromProp() {
|
|
|
301
302
|
if(!props.variantId) {
|
|
302
303
|
return
|
|
303
304
|
}
|
|
304
|
-
let variant =
|
|
305
|
+
let variant = productVariants.value.find((pv) => pv.id === props.variantId)
|
|
305
306
|
if (!variant) {
|
|
306
307
|
return
|
|
307
308
|
}
|
|
@@ -316,7 +317,7 @@ function getVariantFromURL() {
|
|
|
316
317
|
if (!variant_id) {
|
|
317
318
|
return
|
|
318
319
|
}
|
|
319
|
-
let variant =
|
|
320
|
+
let variant = productVariants.value.find((pv) => pv.id === variant_id)
|
|
320
321
|
if (!variant || !variant.in_stock) {
|
|
321
322
|
return
|
|
322
323
|
}
|
|
@@ -334,10 +335,9 @@ function preselect() {
|
|
|
334
335
|
if(urlVariant) {
|
|
335
336
|
setSelectedVariant(urlVariant)
|
|
336
337
|
} else {
|
|
337
|
-
let inStockVariants =
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
)
|
|
338
|
+
let inStockVariants = productVariants.value
|
|
339
|
+
.filter((item) => item.in_stock && item.price > 0)
|
|
340
|
+
.sort((a, b) => a.price - b.price)
|
|
341
341
|
|
|
342
342
|
if (inStockVariants.length === 0) {
|
|
343
343
|
return
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
<script setup>
|
|
73
73
|
import { ref, computed, onMounted, nextTick } from 'vue'
|
|
74
74
|
import { useMq, useT } from '../../../composables/globals'
|
|
75
|
-
import
|
|
75
|
+
import findIndex from 'underscore/modules/findIndex.js'
|
|
76
76
|
import { ProductReviews } from '../../../api'
|
|
77
77
|
import { eventBus } from '../../../utils/event-bus'
|
|
78
78
|
import Review from './Review.vue'
|
|
@@ -142,7 +142,7 @@ async function getImages() {
|
|
|
142
142
|
function updateCumulativeData(reviews) {
|
|
143
143
|
reviews.forEach((review) => {
|
|
144
144
|
if (review.images.length) {
|
|
145
|
-
let exists =
|
|
145
|
+
let exists = findIndex(cumulativeData.value, { id: review.id })
|
|
146
146
|
if (exists === -1) {
|
|
147
147
|
cumulativeData.value.push(review)
|
|
148
148
|
}
|
|
@@ -211,13 +211,13 @@ onMounted(async () => {
|
|
|
211
211
|
return
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
-
collectionIndex.value =
|
|
214
|
+
collectionIndex.value = findIndex(cumulativeData.value, {
|
|
215
215
|
id: pl.review_id
|
|
216
216
|
})
|
|
217
217
|
if (collectionIndex.value === -1) {
|
|
218
218
|
return false
|
|
219
219
|
}
|
|
220
|
-
reviewImageIndex.value =
|
|
220
|
+
reviewImageIndex.value = findIndex(cumulativeData.value[collectionIndex.value]['images'], { id: pl.image_id })
|
|
221
221
|
|
|
222
222
|
openModal(collectionIndex.value, reviewImageIndex.value)
|
|
223
223
|
})
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
</template>
|
|
13
13
|
|
|
14
14
|
<script>
|
|
15
|
-
import
|
|
15
|
+
import range from 'underscore/modules/range.js'
|
|
16
16
|
|
|
17
17
|
export default {
|
|
18
18
|
name: 'QuantityInput',
|
|
@@ -58,7 +58,7 @@ export default {
|
|
|
58
58
|
|
|
59
59
|
computed: {
|
|
60
60
|
selectRange() {
|
|
61
|
-
return
|
|
61
|
+
return range(this.selectMin, this.selectMax + 1)
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
64
|
|
package/package.json
CHANGED
package/utils/filters.js
CHANGED
|
@@ -81,10 +81,61 @@ export const hidecc = function (value) {
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
// 'Y-m-d', 'Y-m-d H:i', 'Y-m-d H:i:s.u', optionally with 'T' and a zone ('Z', '+00', '+05:30').
|
|
85
|
+
// Safari < 16 can't parse the space-separated forms, and native parsing reads a bare 'Y-m-d' as UTC,
|
|
86
|
+
// so these are built from their parts: local time unless a zone is given.
|
|
87
|
+
const YMD_HIS = /^(\d{4})-(\d{2})-(\d{2})(?:[ T](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(?:\s*(Z|[+-]\d{2}(?::?\d{2})?))?)?$/i
|
|
88
|
+
|
|
89
|
+
const parseYmdHis = function (str) {
|
|
90
|
+
const m = str.match(YMD_HIS)
|
|
91
|
+
if (!m) {
|
|
92
|
+
return null
|
|
93
|
+
}
|
|
94
|
+
const [y, mo, d, h, mi, s] = m.slice(1, 7).map((v) => +(v || 0))
|
|
95
|
+
const ms = +(m[7] || '0').slice(0, 3).padEnd(3, '0')
|
|
96
|
+
if (h > 23 || mi > 59 || s > 59) {
|
|
97
|
+
return new Date(NaN)
|
|
98
|
+
}
|
|
99
|
+
// setUTCFullYear/setFullYear instead of the Date constructor, which maps years 0-99 to 19xx
|
|
100
|
+
const data = new Date(0)
|
|
101
|
+
data.setUTCFullYear(y, mo - 1, d)
|
|
102
|
+
// Out-of-range parts roll over (Feb 30 -> Mar 1) instead of failing, so reject those
|
|
103
|
+
if (data.getUTCFullYear() !== y || data.getUTCMonth() !== mo - 1 || data.getUTCDate() !== d) {
|
|
104
|
+
return new Date(NaN)
|
|
105
|
+
}
|
|
106
|
+
const zone = m[8]
|
|
107
|
+
if (!zone) {
|
|
108
|
+
const local = new Date(0)
|
|
109
|
+
local.setFullYear(y, mo - 1, d)
|
|
110
|
+
local.setHours(h, mi, s, ms)
|
|
111
|
+
return local
|
|
112
|
+
}
|
|
113
|
+
data.setUTCHours(h, mi, s, ms)
|
|
114
|
+
if (zone.toUpperCase() !== 'Z') {
|
|
115
|
+
const [, sign, zh, zm = '0'] = zone.match(/([+-])(\d{2}):?(\d{2})?/)
|
|
116
|
+
if (zh > 23 || zm > 59) {
|
|
117
|
+
return new Date(NaN)
|
|
118
|
+
}
|
|
119
|
+
data.setTime(data.getTime() - (sign === '-' ? -1 : 1) * (zh * 60 + +zm) * 60000)
|
|
120
|
+
}
|
|
121
|
+
return data
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Built on first use so importing the filters has no side effects
|
|
125
|
+
let dateFormat
|
|
126
|
+
|
|
84
127
|
export const date = function (date) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
128
|
+
if (typeof date !== 'string' && typeof date !== 'number' && !(date instanceof Date)) {
|
|
129
|
+
// new Date(null) would be the 1970 epoch
|
|
130
|
+
return date
|
|
131
|
+
}
|
|
132
|
+
const data = (typeof date === 'string' && parseYmdHis(date)) || new Date(date)
|
|
133
|
+
if (isNaN(data)) {
|
|
134
|
+
// Intl throws a RangeError on an invalid date
|
|
135
|
+
return date
|
|
136
|
+
}
|
|
137
|
+
dateFormat = dateFormat || new Intl.DateTimeFormat('en-US', { year: 'numeric', month: 'long', day: 'numeric' })
|
|
138
|
+
return dateFormat.format(data)
|
|
88
139
|
}
|
|
89
140
|
|
|
90
141
|
export const nl2p = function (str) {
|
package/utils/google/gmaps.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Loader } from '@googlemaps/js-api-loader'
|
|
2
|
-
import
|
|
2
|
+
import sortBy from 'underscore/modules/sortBy.js'
|
|
3
3
|
|
|
4
4
|
let API_KEY = ''
|
|
5
5
|
let MAP_OPTIONS = {
|
|
@@ -187,7 +187,7 @@ function findNearest(coordinates, locations) {
|
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
-
let nearestLocations =
|
|
190
|
+
let nearestLocations = sortBy(locations, 'distance')
|
|
191
191
|
//console.log(nearest, nearestLocations)
|
|
192
192
|
return nearestLocations
|
|
193
193
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses the category ?f= param, e.g. '12:red,blue;7:10,20' -> { 12: ['red', 'blue'], 7: ['10', '20'] }.
|
|
3
|
+
* The param comes from the address bar, so segments without an 'id:' prefix are skipped instead of throwing,
|
|
4
|
+
* and the result has no prototype so ids like '__proto__' stay plain keys.
|
|
5
|
+
*/
|
|
6
|
+
export default function parseUrlFilters(urlFilters) {
|
|
7
|
+
let filtersStruct = Object.create(null)
|
|
8
|
+
if (!urlFilters) {
|
|
9
|
+
return filtersStruct
|
|
10
|
+
}
|
|
11
|
+
urlFilters.split(';').forEach((filter) => {
|
|
12
|
+
let sep = filter.indexOf(':')
|
|
13
|
+
if (sep <= 0) {
|
|
14
|
+
return
|
|
15
|
+
}
|
|
16
|
+
filtersStruct[filter.slice(0, sep)] = filter.slice(sep + 1).split(',')
|
|
17
|
+
})
|
|
18
|
+
return filtersStruct
|
|
19
|
+
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import _ from "underscore";
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
|
|
5
|
-
methods: {
|
|
6
|
-
|
|
7
|
-
filterMethod() {
|
|
8
|
-
console.log('filter mixin method called')
|
|
9
|
-
},
|
|
10
|
-
|
|
11
|
-
filterClick(e) {
|
|
12
|
-
//console.log(window.location.search)
|
|
13
|
-
let categoryUrl = new URL(window.location.href)
|
|
14
|
-
let urlFilters = categoryUrl.searchParams.get('f')
|
|
15
|
-
let filtersStruct = {}
|
|
16
|
-
urlFilters.split(';').forEach(
|
|
17
|
-
(filter) => {
|
|
18
|
-
let fvalues = filter.split(':')
|
|
19
|
-
filtersStruct[fvalues[0]] = fvalues[1].split(',')
|
|
20
|
-
}
|
|
21
|
-
)
|
|
22
|
-
console.log(e.target.dataset)
|
|
23
|
-
console.log(filtersStruct)
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
checkedFilters() {
|
|
27
|
-
let checked = document.querySelector('div.side-bar').querySelectorAll('input.checkbox:checked')
|
|
28
|
-
|
|
29
|
-
let checkedValues = Object.entries(_.groupBy(_.pluck(checked, 'dataset'), 'att'))
|
|
30
|
-
|
|
31
|
-
let checkedFlatten = []
|
|
32
|
-
checkedValues.forEach(
|
|
33
|
-
([attid, values]) => {
|
|
34
|
-
checkedFlatten.push(attid + ':' + _.pluck(values, 'val').join(','))
|
|
35
|
-
}
|
|
36
|
-
)
|
|
37
|
-
|
|
38
|
-
return checkedFlatten.join(';')
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
sortOrder() {
|
|
42
|
-
return document.getElementById('sort').value
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
getSearchString() {
|
|
46
|
-
let filters = checkedFilters()
|
|
47
|
-
if (filters === ''){
|
|
48
|
-
return '?sort='+sortOrder()
|
|
49
|
-
} else {
|
|
50
|
-
return '?f='+filters+'&sort='+sortOrder()
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
document.querySelector('div.side-bar').querySelectorAll('input.checkbox').forEach(
|
|
61
|
-
(input) => {
|
|
62
|
-
input.addEventListener('click', () => {
|
|
63
|
-
window.location.search = getSearchString()
|
|
64
|
-
})
|
|
65
|
-
}
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
document.querySelector('#sort').addEventListener('change', () => {
|
|
69
|
-
window.location.search = getSearchString()
|
|
70
|
-
})
|