@wikala/spmkt 3.0.0-beta.0 → 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/MIGRATION_GUIDE.md +50 -1
- package/api/request.js +3 -2
- 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 +10 -8
- package/components/Cart/Store/state.js +2 -2
- package/components/Cart/UserIdentity.vue +2 -2
- package/components/Category/CategoryFilter.vue +37 -34
- package/components/DobInput.vue +1 -1
- package/components/Gmaps/GmapsAutocomplete.vue +2 -2
- package/components/Gmaps/GmapsLocations.vue +2 -2
- 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 +8 -4
- package/components/ModalContainer/index.js +3 -2
- package/components/Product/AddToCart.vue +10 -7
- package/components/Product/Compare.vue +32 -10
- 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 +17 -17
- package/components/Product/reviews-questions/ReviewImages.vue +4 -4
- package/components/QuantityInput.vue +2 -2
- package/install.js +17 -4
- package/package.json +8 -9
- package/utils/animate.css +50 -0
- package/utils/animate.js +1 -1
- package/utils/buefy.js +62 -0
- package/utils/filters.js +54 -3
- package/utils/format-date.js +17 -0
- package/utils/google/gmaps.js +2 -2
- package/utils/parse-url-filters.js +19 -0
- package/utils/random-id.js +10 -0
- package/components/Category/FilterMixin.js +0 -70
package/MIGRATION_GUIDE.md
CHANGED
|
@@ -11,7 +11,7 @@ This document outlines the changes made and remaining work needed to complete th
|
|
|
11
11
|
| `vue@^2.6.14` | `vue@^3.4.0` |
|
|
12
12
|
| `vuex@^3.6.2` | `vuex@^4.1.0` |
|
|
13
13
|
| `buefy@^0.9.10` | `buefy@^3.0.3` (Vue 3 compatible) |
|
|
14
|
-
| `vue-mq@^1.0.1` |
|
|
14
|
+
| `vue-mq@^1.0.1` | removed: the host provides `$mq` |
|
|
15
15
|
| `vue-template-compiler` | `@vue/compiler-sfc` |
|
|
16
16
|
| `@vue/test-utils@^1.3.6` | `@vue/test-utils@^2.4.3` |
|
|
17
17
|
|
|
@@ -192,6 +192,55 @@ the same `setAddressList` / `setCountryList` mutations, which would collide.
|
|
|
192
192
|
longer calls `Vue.use(Buefy)`, `registerFilters(Vue)` or `registerDirectives(Vue)`
|
|
193
193
|
itself; pass Buefy and modal container options through `installSpmkt` instead.
|
|
194
194
|
|
|
195
|
+
Of Buefy, `installSpmkt` installs only the components spmkt uses (`buefyPlugins`
|
|
196
|
+
in `utils/buefy.js`), not all of it, so the unused ones stay out of the host's
|
|
197
|
+
bundle. A host whose own templates use another Buefy component installs that
|
|
198
|
+
plugin itself after `installSpmkt`:
|
|
199
|
+
|
|
200
|
+
```javascript
|
|
201
|
+
import { Tooltip } from 'buefy'
|
|
202
|
+
|
|
203
|
+
app.use(installSpmkt, { buefy: { defaultIconPack: 'fas' } })
|
|
204
|
+
app.use(Tooltip)
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
Buefy's `module` entry is one file that bundlers can't tree-shake well, so even
|
|
208
|
+
that subset costs ~82 KB gzipped. Alias `buefy` to its per-component build and it
|
|
209
|
+
drops to ~47 KB. Alias the bare `buefy` import only (CSS imports like
|
|
210
|
+
`buefy/dist/css/buefy.css` stay as they are), and set it in the host's config so the
|
|
211
|
+
host and spmkt share one Buefy, and with it one config:
|
|
212
|
+
|
|
213
|
+
```javascript
|
|
214
|
+
// vite.config.js
|
|
215
|
+
resolve: {
|
|
216
|
+
alias: [{ find: /^buefy$/, replacement: 'buefy/dist/esm/index.js' }]
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// webpack.config.js
|
|
220
|
+
resolve: {
|
|
221
|
+
alias: { buefy$: 'buefy/dist/esm/index.js' }
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### Bundle size
|
|
226
|
+
|
|
227
|
+
`package.json` marks spmkt's modules side-effect free (`"sideEffects"`), so the
|
|
228
|
+
host's bundler keeps only the components a page imports and their dependencies:
|
|
229
|
+
a page using just `Price` no longer bundles axios, underscore or the Cart. Don't
|
|
230
|
+
rely on spmkt's imports for anything a page doesn't import itself:
|
|
231
|
+
|
|
232
|
+
- `animate.css` is no longer a dependency. spmkt ships only the `pulse` and
|
|
233
|
+
`slideInUp` animations it uses (`utils/animate.css`); a host whose templates
|
|
234
|
+
use other `animate__*` classes installs and imports `animate.css` itself.
|
|
235
|
+
- `window._post` / `window._get` are set by `installSpmkt`, not on import, and
|
|
236
|
+
load the request module on their first call.
|
|
237
|
+
- `window.customEventBus` and `window.GoogleAnalyticsEEC` are still set on
|
|
238
|
+
every page that imports `installSpmkt`.
|
|
239
|
+
- `bulma-divider`, `shortid`, `intl-dateformat` and `scrollmonitor` are no longer
|
|
240
|
+
dependencies. A host theme that `@import`s `bulma-divider` (for Login's
|
|
241
|
+
`.is-divider`) installs it itself.
|
|
242
|
+
- No spmkt component uses Sass, so the host no longer needs `sass` to compile them.
|
|
243
|
+
|
|
195
244
|
## Host Application Requirements
|
|
196
245
|
|
|
197
246
|
spmkt components rely on things the host app provides. In the Vue 2 host these
|
package/api/request.js
CHANGED
|
@@ -53,7 +53,8 @@ service.interceptors.response.use(
|
|
|
53
53
|
}
|
|
54
54
|
)
|
|
55
55
|
|
|
56
|
-
window._post
|
|
56
|
+
// The host's inline scripts call these as window._post / window._get; installSpmkt sets them
|
|
57
|
+
export const _post = (url, params, callback) => {
|
|
57
58
|
service({
|
|
58
59
|
baseURL: config.BASE_URL,
|
|
59
60
|
url: url,
|
|
@@ -72,7 +73,7 @@ window._post = (url, params, callback) => {
|
|
|
72
73
|
return true
|
|
73
74
|
}
|
|
74
75
|
|
|
75
|
-
|
|
76
|
+
export const _get = (url, params, callback) => {
|
|
76
77
|
let queryString = ''
|
|
77
78
|
if (params) {
|
|
78
79
|
queryString = Object.keys(params)
|
|
@@ -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,8 +1,10 @@
|
|
|
1
1
|
|
|
2
2
|
// noinspection DuplicatedCode
|
|
3
3
|
|
|
4
|
-
import
|
|
5
|
-
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'
|
|
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'
|
|
8
10
|
import { Address } from '../../../api'
|
|
@@ -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
|
}
|
|
@@ -142,7 +144,7 @@ export default {
|
|
|
142
144
|
},
|
|
143
145
|
|
|
144
146
|
setIdempotencyKey(state) {
|
|
145
|
-
state.checkoutRequestData.idempotency_key =
|
|
147
|
+
state.checkoutRequestData.idempotency_key = randomId()
|
|
146
148
|
},
|
|
147
149
|
|
|
148
150
|
setDateOfBirth(state, date_of_birth) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import { User } from '../../../api'
|
|
3
3
|
import { addressSchema } from '../../Address/address.schema'
|
|
4
|
-
import
|
|
4
|
+
import randomId from '../../../utils/random-id'
|
|
5
5
|
|
|
6
6
|
export default () => ({
|
|
7
7
|
cart: {
|
|
@@ -71,7 +71,7 @@ export default () => ({
|
|
|
71
71
|
card_postal_code: '',
|
|
72
72
|
recaptcha_token: '',
|
|
73
73
|
date_of_birth: '',
|
|
74
|
-
idempotency_key:
|
|
74
|
+
idempotency_key: randomId(),
|
|
75
75
|
reservation_slot: '',
|
|
76
76
|
note: '',
|
|
77
77
|
affiliate: {}
|
|
@@ -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 {
|
package/components/DobInput.vue
CHANGED
|
@@ -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)
|