@wikala/spmkt 2.31.0 → 3.0.0-beta.0

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.
Files changed (124) hide show
  1. package/MIGRATION_GUIDE.md +261 -0
  2. package/api/product.js +1 -0
  3. package/api/request.js +9 -4
  4. package/api/user.js +1 -1
  5. package/components/Account/AccountDashboard.vue +101 -101
  6. package/components/Account/AccountStore.js +57 -31
  7. package/components/Account/AffiliateReport.vue +56 -60
  8. package/components/Account/{OrderDetail.vue → Orders/OrderDetail.vue} +44 -30
  9. package/components/Account/Orders/Orders.vue +124 -0
  10. package/components/Account/{AccountSettings.vue → Settings/AccountSettings.vue} +4 -4
  11. package/components/Account/Settings/ChangeEmail.vue +136 -0
  12. package/components/Account/Settings/ChangeName.vue +82 -0
  13. package/components/Account/Settings/ChangePassword.vue +91 -0
  14. package/components/Address/Address.vue +38 -57
  15. package/components/Address/AddressBook.vue +77 -57
  16. package/components/Address/AddressSelect.vue +94 -87
  17. package/components/Address/Edit.vue +253 -265
  18. package/components/Address/PostalCode.vue +22 -21
  19. package/components/AgeGate.vue +11 -5
  20. package/components/Auth/Login.vue +62 -44
  21. package/components/Auth/Register.vue +82 -60
  22. package/components/Auth/ResetPassword.vue +45 -30
  23. package/components/Cart/AgeVerification/AgeChecker.vue +3 -3
  24. package/components/Cart/CartBadge.vue +15 -4
  25. package/components/Cart/CartBox.vue +19 -11
  26. package/components/Cart/CartItem.vue +3 -3
  27. package/components/Cart/CartMode.vue +6 -5
  28. package/components/Cart/CartPreview.vue +24 -18
  29. package/components/Cart/Coupon.vue +4 -5
  30. package/components/Cart/CreditCard/Everyware.vue +10 -10
  31. package/components/Cart/CreditCard/ExtendedCreditCard.vue +5 -5
  32. package/components/Cart/CreditCard/SquarePay.vue +18 -16
  33. package/components/Cart/CreditCard/StandardCreditCard.vue +9 -9
  34. package/components/Cart/Delivery/Delivery.vue +16 -12
  35. package/components/Cart/Delivery/DeliveryAddress.vue +1 -1
  36. package/components/Cart/Delivery/DeliveryMethods.vue +1 -1
  37. package/components/Cart/Delivery/DeliveryOptions.vue +15 -9
  38. package/components/Cart/Delivery/DeliveryTypes.vue +8 -5
  39. package/components/Cart/Delivery/ReservationSlots.vue +14 -8
  40. package/components/Cart/Disclaimer.vue +1 -1
  41. package/components/Cart/OrderConfirmation.vue +1 -1
  42. package/components/Cart/Payment/Payment.vue +37 -33
  43. package/components/Cart/Payment/PaymentMethods.vue +6 -4
  44. package/components/Cart/ReviewAndSubmit.vue +9 -7
  45. package/components/Cart/ShoppingCart.vue +42 -31
  46. package/components/Cart/Store/actions.js +1 -1
  47. package/components/Cart/Store/getters.js +2 -1
  48. package/components/Cart/Store/index.js +1 -1
  49. package/components/Cart/Store/mutations.js +7 -5
  50. package/components/Cart/UserIdentity.vue +1 -1
  51. package/components/Category/CategoryFilter.vue +128 -114
  52. package/components/Category/CategorySort.vue +44 -32
  53. package/components/Category/LoadMore.vue +39 -23
  54. package/components/DeliverTo.vue +10 -15
  55. package/components/DeliveryNotice.vue +72 -68
  56. package/components/DobInput.vue +23 -23
  57. package/components/Gmaps/GmapsAutocomplete.vue +139 -78
  58. package/components/Gmaps/GmapsLocations.vue +1 -1
  59. package/components/Gmaps/GmapsSingleLocation.vue +121 -87
  60. package/components/ModalContainer/ModalContainer.vue +12 -9
  61. package/components/ModalContainer/index.js +61 -18
  62. package/components/Product/AddToCart.vue +237 -221
  63. package/components/Product/BoxAddToCart.vue +114 -86
  64. package/components/Product/Compare.vue +68 -48
  65. package/components/Product/CompareBox.vue +128 -123
  66. package/components/Product/Lookup.vue +92 -65
  67. package/components/Product/Photo.vue +105 -66
  68. package/components/Product/Price.vue +64 -43
  69. package/components/Product/ProductAutocomplete.vue +52 -57
  70. package/components/Product/ProductBox.vue +61 -38
  71. package/components/Product/ProductImages.vue +83 -86
  72. package/components/Product/Quantity.vue +115 -53
  73. package/components/Product/QuickView.vue +52 -45
  74. package/components/Product/RelatedProducts.vue +88 -23
  75. package/components/Product/SKU.vue +27 -8
  76. package/components/Product/Variants.vue +335 -341
  77. package/components/Product/reviews-questions/ProductQuestions.vue +226 -198
  78. package/components/Product/reviews-questions/ProductReviews.vue +122 -107
  79. package/components/Product/reviews-questions/Review.vue +54 -59
  80. package/components/Product/reviews-questions/ReviewForm.vue +222 -170
  81. package/components/Product/reviews-questions/ReviewImages.vue +197 -216
  82. package/components/Product/reviews-questions/Vote.vue +83 -57
  83. package/components/QuantityInput.vue +18 -8
  84. package/components/RangeInput.vue +15 -8
  85. package/components/Recaptcha.vue +8 -1
  86. package/components/SelectShippingCountry.vue +81 -62
  87. package/components/TimedOffer.vue +59 -74
  88. package/composables/globals.js +53 -0
  89. package/config.js +5 -2
  90. package/index.js +41 -10
  91. package/install.js +75 -0
  92. package/locales/en.json +2 -1
  93. package/locales/sr.json +2 -1
  94. package/package.json +43 -30
  95. package/utils/directives.js +28 -45
  96. package/utils/event-bus.js +56 -0
  97. package/utils/filters.js +24 -7
  98. package/utils/{gmaps.js → google/gmaps.js} +43 -10
  99. package/utils/{google-analytics-eec.js → google/google-analytics-eec.js} +7 -7
  100. package/babel.config.js +0 -5
  101. package/components/Account/ChangeEmail.vue +0 -133
  102. package/components/Account/ChangeName.vue +0 -92
  103. package/components/Account/ChangePassword.vue +0 -94
  104. package/components/Account/CreditCards.vue +0 -18
  105. package/components/Account/Orders.vue +0 -110
  106. package/components/Account/Settings.vue +0 -18
  107. package/components/Cart/Delivery/DeliveryAddressGuest.spec.js +0 -128
  108. package/components/Cart/Delivery/DeliveryTypes.spec.js +0 -83
  109. package/components/Cart/PCIBadge/SecurityMetrics.vue +0 -11
  110. package/components/Instagram.vue +0 -49
  111. package/components/ProductImageModal.vue +0 -41
  112. package/jest.config.js +0 -16
  113. package/test/e2e/.babelrc.js +0 -8
  114. package/test/e2e/.eslintrc.js +0 -11
  115. package/test/e2e/accAuth.spec.js +0 -64
  116. package/test/e2e/ageGate.spec.js +0 -26
  117. package/test/e2e/checkout.spec.js +0 -106
  118. package/test/e2e/compare.spec.js +0 -52
  119. package/test/e2e/config/data.js +0 -21
  120. package/test/e2e/config/routes.js +0 -11
  121. package/test/e2e/region.spec.js +0 -46
  122. package/test/e2e/search.spec.js +0 -32
  123. package/tests/vueBuefy.js +0 -4
  124. package/tsconfig.json +0 -8
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <div v-if="images.length" class="userimg-gallery">
3
3
  <div v-if="images.length" class="columns userimg-cols is-multiline is-mobile is-flex">
4
- <div v-for="(image, image_idx) in images.slice(0, $mq === 'mobile' ? 3 : 9)" class="column userimg-image is-2-desktop is-paddingless">
4
+ <div v-for="(image, image_idx) in images.slice(0, mq === 'mobile' ? 3 : 9)" class="column userimg-image is-2-desktop is-paddingless">
5
5
  <img :key="image.id" :src="image.thumb_url" :alt="image.alt" @click="openModal(image.collection_idx, image.review_images_idx)" />
6
6
  </div>
7
7
  <div v-if="images.length > 9 || data.meta.last_page > 1" class="column userimg-viewall is-2 is-paddingless has-margin-right-sm has-margin-bottom-sm">
@@ -9,240 +9,221 @@
9
9
  </div>
10
10
  </div>
11
11
 
12
- <b-modal :active.sync="carouselModal" :can-cancel="['escape']" :custom-class="bringToFrontClass" @close="bringToFrontClass = ''" scroll="clip">
13
- <button type="button" class="modal-close is-large" style="" @click="carouselModal = false"></button>
14
- <b-carousel
15
- v-if="single"
16
- v-model="collectionIndex"
17
- @change="carouselChange($event)"
18
- :repeat="false"
19
- :arrow="true"
20
- :arrow-hover="false"
21
- :has-drag="true"
22
- :autoplay="false"
23
- :indicator="false"
24
- >
25
- <template v-for="(review, i) in cumulativeData">
26
- <b-carousel-item :key="review.id">
27
- <div class="columns">
28
- <div class="column is-6 img-full">
29
- <img
30
- v-if="review.images[reviewImageIndex]"
31
- :src="review.images[reviewImageIndex].url"
32
- :alt="review.images[reviewImageIndex].alt"
33
- :id="'image-' + i"
34
- />
35
- </div>
36
- <div class="column is-6">
37
- <Review :review="review" :active-image-index="reviewImageIndex" @input="reviewImageIndex = $event" />
38
- </div>
39
- </div>
40
- </b-carousel-item>
41
- </template>
42
- </b-carousel>
43
- </b-modal>
44
-
45
- <b-modal :active.sync="allImagesModal" :can-cancel="['escape']" scroll="clip">
46
- <button type="button" class="modal-close is-large" style="" @click="allImagesModal = false"></button>
47
- <div class="all-images-c">
48
- <div class="columns is-multiline is-mobile all-images">
49
- <template v-for="(review, c) in cumulativeData">
50
- <template v-if="review.images.length">
51
- <div v-for="(image, r) in review.images" class="column all-images-col">
52
- <img :key="image.id" :src="image.thumb_url" :alt="image.alt" @click="openModal(c, r)" />
53
- </div>
12
+ <!-- In body, out of the product page's stacking contexts (the fixed product nav covered it
13
+ on mobile); the wrapper keeps the theme's .userimg-gallery modal styles applying, and
14
+ display: contents keeps the theme's .userimg-gallery box rules off the empty wrapper -->
15
+ <Teleport to="body">
16
+ <div ref="modalsContainer" class="userimg-gallery userimg-gallery-modals" style="display: contents">
17
+ <b-modal v-model="carouselModal" :can-cancel="['escape']" :custom-class="bringToFrontClass" @close="bringToFrontClass = ''" scroll="clip">
18
+ <button type="button" class="modal-close is-large" style="" @click="carouselModal = false"></button>
19
+ <b-carousel
20
+ v-if="single"
21
+ v-model="collectionIndex"
22
+ @change="carouselChange($event)"
23
+ :repeat="false"
24
+ :arrow="true"
25
+ :arrow-hover="false"
26
+ :has-drag="true"
27
+ :autoplay="false"
28
+ :indicator="false"
29
+ >
30
+ <template v-for="(review, i) in cumulativeData" :key="review.id">
31
+ <b-carousel-item>
32
+ <div class="columns">
33
+ <div class="column is-6 img-full">
34
+ <img
35
+ v-if="review.images[reviewImageIndex]"
36
+ :src="review.images[reviewImageIndex].url"
37
+ :alt="review.images[reviewImageIndex].alt"
38
+ :id="'image-' + i"
39
+ />
40
+ </div>
41
+ <div class="column is-6">
42
+ <Review :review="review" :active-image-index="reviewImageIndex" @update:modelValue="reviewImageIndex = $event" />
43
+ </div>
44
+ </div>
45
+ </b-carousel-item>
54
46
  </template>
55
- </template>
56
- </div>
57
- <div style="margin: 2rem; display: flex; justify-content: center">
58
- <button v-if="this.data.meta && cumulativeData.length < this.data.meta.total" class="button" @click="loadMore">{{ $t('review.loadMore') }}</button>
59
- </div>
47
+ </b-carousel>
48
+ </b-modal>
49
+
50
+ <b-modal v-model="allImagesModal" :can-cancel="['escape']" scroll="clip">
51
+ <button type="button" class="modal-close is-large" style="" @click="allImagesModal = false"></button>
52
+ <div class="all-images-c">
53
+ <div class="columns is-multiline is-mobile all-images">
54
+ <template v-for="(review, c) in cumulativeData">
55
+ <template v-if="review.images.length">
56
+ <div v-for="(image, r) in review.images" class="column all-images-col">
57
+ <img :key="image.id" :src="image.thumb_url" :alt="image.alt" @click="openModal(c, r)" />
58
+ </div>
59
+ </template>
60
+ </template>
61
+ </div>
62
+ <div style="margin: 2rem; display: flex; justify-content: center">
63
+ <button v-if="data.meta && cumulativeData.length < data.meta.total" class="button" @click="loadMore">{{ $t('review.loadMore') }}</button>
64
+ </div>
65
+ </div>
66
+ </b-modal>
60
67
  </div>
61
- </b-modal>
68
+ </Teleport>
62
69
  </div>
63
70
  </template>
64
71
 
65
- <script>
72
+ <script setup>
73
+ import { ref, computed, onMounted, nextTick } from 'vue'
74
+ import { useMq, useT } from '../../../composables/globals'
66
75
  import _ from 'underscore'
67
-
68
76
  import { ProductReviews } from '../../../api'
69
- import Review from './Review'
70
-
71
- export default {
72
- name: 'ReviewImages',
73
- components: { Review },
74
- data() {
75
- return {
76
- single: true,
77
- collectionIndex: 0,
78
- reviewImageIndex: 0,
79
- imageIndex: 0,
80
- carouselModal: false,
81
- allImagesModal: false,
82
- bringToFrontClass: '',
83
- filterParams: {
84
- images: 1,
85
- review_id: null,
86
- previous: null,
87
- next: null,
88
- thumb_size: this.$mq === 'mobile' ? '100x100' : '200x200',
89
- per_page: 20,
90
- page: 1
91
- },
92
- cumulativeData: [],
93
- data: {
94
- data: [],
95
- meta: null
96
- }
77
+ import { eventBus } from '../../../utils/event-bus'
78
+ import Review from './Review.vue'
79
+
80
+ // Access global properties
81
+ const { t: $t } = useT()
82
+ const mq = useMq()
83
+
84
+ // State
85
+ const single = ref(true)
86
+ const collectionIndex = ref(0)
87
+ const reviewImageIndex = ref(0)
88
+ const imageIndex = ref(0)
89
+ const carouselModal = ref(false)
90
+ const allImagesModal = ref(false)
91
+ const bringToFrontClass = ref('')
92
+ const modalsContainer = ref(null)
93
+ const filterParams = ref({
94
+ images: 1,
95
+ review_id: null,
96
+ previous: null,
97
+ next: null,
98
+ thumb_size: mq.value === 'mobile' ? '100x100' : '200x200',
99
+ per_page: 20,
100
+ page: 1
101
+ })
102
+ const cumulativeData = ref([])
103
+ const data = ref({
104
+ data: [],
105
+ meta: null
106
+ })
107
+
108
+ // Computed
109
+ const images = computed(() => {
110
+ let imagesList = []
111
+ if (!cumulativeData.value.length) {
112
+ return imagesList
113
+ }
114
+ cumulativeData.value.map((review, data_idx) => {
115
+ if (review.images.length > 0) {
116
+ review.images.forEach((reviewImage, idx) => {
117
+ imagesList.push({
118
+ id: reviewImage.id,
119
+ review_id: review.id,
120
+ review_images_idx: idx,
121
+ collection_idx: data_idx,
122
+ thumb_url: reviewImage.thumb_url,
123
+ alt: reviewImage.alt
124
+ })
125
+ })
97
126
  }
98
- },
127
+ })
128
+ return imagesList
129
+ })
130
+
131
+ // Methods
132
+ async function getImages() {
133
+ const response = await ProductReviews.getList(window.wkl_product.id, filterParams.value)
134
+ data.value.data = response.data.data
135
+ if (response.data.meta) {
136
+ data.value.meta = response.data.meta
137
+ }
138
+ updateCumulativeData(response.data.data)
139
+ return response.data.data.length
140
+ }
99
141
 
100
- computed: {
101
- images() {
102
- let images = []
103
- if (!this.cumulativeData.length) {
104
- return images
142
+ function updateCumulativeData(reviews) {
143
+ reviews.forEach((review) => {
144
+ if (review.images.length) {
145
+ let exists = _.findIndex(cumulativeData.value, { id: review.id })
146
+ if (exists === -1) {
147
+ cumulativeData.value.push(review)
105
148
  }
106
- this.cumulativeData.map((review, data_idx) => {
107
- if (review.images.length > 0) {
108
- review.images.forEach((reviewImage, idx) => {
109
- images.push({
110
- id: reviewImage.id,
111
- review_id: review.id,
112
- review_images_idx: idx,
113
- collection_idx: data_idx,
114
- thumb_url: reviewImage.thumb_url,
115
- alt: reviewImage.alt
116
- })
117
- })
118
- }
119
- })
120
- return images
121
149
  }
122
- },
123
-
124
- methods: {
125
- async getImages() {
126
- const { data } = await ProductReviews.getList(window.wkl_product.id, this.filterParams)
127
- this.data.data = data.data
128
- if (data.meta) {
129
- this.data.meta = data.meta
130
- }
131
- this.updateCumulativeData(data.data)
132
- return data.data.length
133
- },
134
-
135
- updateCumulativeData(data) {
136
- data.forEach((review) => {
137
- if (review.images.length) {
138
- let exists = _.findIndex(this.cumulativeData, { id: review.id })
139
- if (exists === -1) {
140
- this.cumulativeData.push(review)
141
- //console.log('Added ', review.id, 'to cumulativeData')
142
- }
143
- }
144
- })
145
- },
146
-
147
- setArrowsVisibility(collectionIndex) {
148
- let leftArrow = document.querySelector('.userimg-gallery div.carousel-arrow > span.icon.has-icons-left')
149
- let rightArrow = document.querySelector('.userimg-gallery div.carousel-arrow > span.icon.has-icons-right')
150
- if(!leftArrow || !rightArrow) {
151
- return
152
- }
153
- if (collectionIndex === 0) {
154
- leftArrow.style.visibility = 'hidden'
155
- } else {
156
- leftArrow.style.visibility = 'visible'
157
- }
158
- if (collectionIndex === this.cumulativeData.length - 1) {
159
- rightArrow.style.visibility = 'hidden'
160
- } else {
161
- rightArrow.style.visibility = 'visible'
162
- }
163
- },
150
+ })
151
+ }
164
152
 
165
- attachModalToBody() { //fixes z-index issues
166
- const modal = document.getElementsByClassName('modal');
167
- if(modal.length) {
168
- document.body.insertAdjacentElement('afterbegin', modal[0])
169
- }
170
- },
171
-
172
- async carouselChange(e) {
173
- this.collectionIndex = e
174
- this.reviewImageIndex = 0
175
- this.setArrowsVisibility(e)
176
- if (this.cumulativeData.length < this.data.meta.total && (this.cumulativeData.length === 2 || this.cumulativeData.length - e <= 3)) {
177
- //console.log('get next reviews with images ', this.cumulativeData.length)
178
- this.filterParams.review_id = this.cumulativeData[this.collectionIndex]['id']
179
- this.filterParams.previous = 5
180
- await this.getImages()
181
- this.$nextTick(() => {
182
- this.setArrowsVisibility(this.collectionIndex)
183
- })
184
- }
185
- },
186
-
187
- openModal(collection_idx, image_idx) {
188
- this.collectionIndex = collection_idx
189
- this.reviewImageIndex = image_idx
190
- this.bringToFrontClass = 'bring-to-front'
191
- this.carouselModal = true
192
- this.$nextTick(() => {
193
- this.setArrowsVisibility(collection_idx)
194
- this.attachModalToBody()
195
- })
196
- },
197
-
198
- viewAll() {
199
- this.allImagesModal = true
200
- },
201
-
202
- async loadMore() {
203
- //console.log('Load more', this.cumulativeData[this.cumulativeData.length - 1]['id'])
204
- //console.log(this.cumulativeData.length, this.data.meta.total)
205
- this.filterParams.review_id = this.cumulativeData[this.cumulativeData.length - 1]['id']
206
- this.filterParams.previous = 5
207
- await this.getImages()
208
- },
209
-
210
- viewImage(e) {
211
- console.log('ReviewImages.viewImage ', e)
153
+ function setArrowsVisibility(index) {
154
+ // The carousel is teleported to body, so look in its own wrapper, not the first .userimg-gallery
155
+ let leftArrow = modalsContainer.value?.querySelector('div.carousel-arrow > span.icon.has-icons-left')
156
+ let rightArrow = modalsContainer.value?.querySelector('div.carousel-arrow > span.icon.has-icons-right')
157
+ if (leftArrow && rightArrow) {
158
+ if (index === 0) {
159
+ leftArrow.style.visibility = 'hidden'
160
+ } else {
161
+ leftArrow.style.visibility = 'visible'
212
162
  }
213
- },
163
+ if (index === cumulativeData.value.length - 1) {
164
+ rightArrow.style.visibility = 'hidden'
165
+ } else {
166
+ rightArrow.style.visibility = 'visible'
167
+ }
168
+ }
169
+ }
214
170
 
215
- async mounted() {
216
- //console.log('mq', this.$mq)
217
- await this.getImages()
218
- //console.log('cd ', this.cumulativeData.length)
171
+ async function carouselChange(e) {
172
+ collectionIndex.value = e
173
+ reviewImageIndex.value = 0
174
+ setArrowsVisibility(e)
175
+ if (cumulativeData.value.length < data.value.meta.total && (cumulativeData.value.length === 2 || cumulativeData.value.length - e <= 3)) {
176
+ filterParams.value.review_id = cumulativeData.value[collectionIndex.value]['id']
177
+ filterParams.value.previous = 5
178
+ await getImages()
179
+ nextTick(() => {
180
+ setArrowsVisibility(collectionIndex.value)
181
+ })
182
+ }
183
+ }
219
184
 
220
- this.$bus.$on('viewImage', (pl) => {
221
- if (!pl.review_id || !pl.image_id) {
222
- //console.log('ReviewImages.onViewImage ', 'Invalid params')
223
- return
224
- }
185
+ function openModal(collection_idx, image_idx) {
186
+ collectionIndex.value = collection_idx
187
+ reviewImageIndex.value = image_idx
188
+ bringToFrontClass.value = 'bring-to-front'
189
+ carouselModal.value = true
190
+ nextTick(() => {
191
+ setArrowsVisibility(collection_idx)
192
+ })
193
+ }
225
194
 
226
- //console.log('ReviewImages.onViewImage ', this.cumulativeData)
195
+ function viewAll() {
196
+ allImagesModal.value = true
197
+ }
227
198
 
228
- this.collectionIndex = _.findIndex(this.cumulativeData, {
229
- id: pl.review_id
230
- })
231
- if (this.collectionIndex === -1) {
232
- //this.filterParams.review_id = pl.review_id
233
- //console.log('ReviewImages.onViewImage ', 'Review is not in cumulativeData', pl.review_id)
234
- return false
235
- }
236
- this.reviewImageIndex = _.findIndex(this.cumulativeData[this.collectionIndex]['images'], { id: pl.image_id })
199
+ async function loadMore() {
200
+ filterParams.value.review_id = cumulativeData.value[cumulativeData.value.length - 1]['id']
201
+ filterParams.value.previous = 5
202
+ await getImages()
203
+ }
237
204
 
238
- //console.log('ci', this.collectionIndex, this.reviewImageIndex)
205
+ // Lifecycle
206
+ onMounted(async () => {
207
+ await getImages()
239
208
 
240
- this.openModal(this.collectionIndex, this.reviewImageIndex)
241
- })
209
+ eventBus.on('viewImage', (pl) => {
210
+ if (!pl.review_id || !pl.image_id) {
211
+ return
212
+ }
242
213
 
243
- this.$bus.$on('addToCumulativeData', (data, page) => {
244
- this.updateCumulativeData(data)
214
+ collectionIndex.value = _.findIndex(cumulativeData.value, {
215
+ id: pl.review_id
245
216
  })
246
- }
247
- }
217
+ if (collectionIndex.value === -1) {
218
+ return false
219
+ }
220
+ reviewImageIndex.value = _.findIndex(cumulativeData.value[collectionIndex.value]['images'], { id: pl.image_id })
221
+
222
+ openModal(collectionIndex.value, reviewImageIndex.value)
223
+ })
224
+
225
+ eventBus.on('addToCumulativeData', (reviews, page) => {
226
+ updateCumulativeData(reviews)
227
+ })
228
+ })
248
229
  </script>
@@ -3,76 +3,102 @@
3
3
  <div :class="['is-flex', 'vote-actions', { 'vote-actions-loading': loading }]">
4
4
  <div class="vote-title">{{ title }}</div>
5
5
  <div class="vote-action" @click="addVote(1)">
6
- <i class="fa-light fa-thumbs-up"></i><span> {{ upvotes }} </span>
6
+ <i class="fas fa-thumbs-up"></i><span> {{ upvotes }} </span>
7
7
  </div>
8
8
  <div class="vote-action" @click="addVote(0)">
9
- <i class="fa-light fa-thumbs-down"></i><span> {{ downvotes }}</span>
9
+ <i class="fas fa-thumbs-down"></i><span> {{ downvotes }}</span>
10
10
  </div>
11
11
  </div>
12
12
  </div>
13
13
  </template>
14
14
 
15
- <script>
16
- export default {
17
- name: 'Vote',
18
-
19
- props: {
20
- title: {
21
- type: String,
22
- default: ''
23
- },
24
- item: {
25
- type: Object
26
- },
27
- result: {
28
- type: Object
29
- }
30
- },
31
15
 
32
- data() {
33
- return {
34
- submitted: false,
35
- loading: false
36
- }
37
- },
16
+ <script setup>
17
+ import { ref, computed, watch } from 'vue';
18
+ import { useBuefy } from '../../../composables/globals';
38
19
 
39
- computed: {
40
- upvotes() {
41
- if (this.item.up_votes) {
42
- return this.item.up_votes
43
- } else {
44
- return 0
45
- }
46
- },
47
- downvotes() {
48
- if (this.item.down_votes) {
49
- return this.item.down_votes
50
- } else {
51
- return 0
52
- }
53
- }
20
+ const props = defineProps({
21
+ title: {
22
+ type: String,
23
+ default: ''
54
24
  },
55
-
56
- watch: {
57
- // whenever question changes, this function will run
58
- result: function (newResult, oldResult) {
59
- if (newResult && newResult.status === 1) {
60
- this.$buefy.snackbar.open(newResult.msg)
61
- this.item.up_votes = newResult.data.up_votes
62
- this.item.down_votes = newResult.data.down_votes
63
- this.submitted = true
64
- } else {
65
- this.$buefy.snackbar.open(newResult.msg)
66
- }
67
- this.loading = false
68
- }
25
+ item: {
26
+ type: Object,
27
+ required: true
69
28
  },
29
+ result: {
30
+ type: Object,
31
+ default: () => ({})
32
+ }
33
+ });
34
+
35
+ const emit = defineEmits(['vote']);
36
+
37
+ const submitted = ref(false);
38
+ const loading = ref(false);
39
+
40
+ const upvotes = computed(() => props.item.up_votes ? props.item.up_votes : 0);
41
+ const downvotes = computed(() => props.item.down_votes ? props.item.down_votes : 0);
70
42
 
71
- methods: {
72
- addVote(vote) {
73
- this.loading = true
74
- this.$emit('vote', vote)
43
+ const $buefy = useBuefy();
44
+
45
+ watch(() => props.result, (newResult) => {
46
+ if (newResult && newResult.status === 1) {
47
+ $buefy.snackbar.open(newResult.msg);
48
+ if (newResult.data) {
49
+ props.item.up_votes = newResult.data.up_votes;
50
+ props.item.down_votes = newResult.data.down_votes;
75
51
  }
52
+ submitted.value = true;
53
+ } else if (newResult && newResult.msg) {
54
+ $buefy.snackbar.open(newResult.msg);
76
55
  }
56
+ loading.value = false;
57
+ });
58
+
59
+ function addVote(vote) {
60
+ loading.value = true;
61
+ emit('vote', vote);
77
62
  }
78
63
  </script>
64
+
65
+ <style scoped>
66
+ .vote-actions {
67
+ align-items: center;
68
+ gap: 1rem;
69
+ padding: 0.5rem 0;
70
+ }
71
+
72
+ .vote-actions-loading {
73
+ opacity: 0.6;
74
+ pointer-events: none;
75
+ }
76
+
77
+ .vote-title {
78
+ font-weight: 500;
79
+ margin-right: 0.5rem;
80
+ }
81
+
82
+ .vote-action {
83
+ display: flex;
84
+ align-items: center;
85
+ gap: 0.25rem;
86
+ cursor: pointer;
87
+ padding: 0.25rem 0.5rem;
88
+ border-radius: 4px;
89
+ transition: background-color 0.2s;
90
+ }
91
+
92
+ .vote-action:hover {
93
+ background-color: #f5f5f5;
94
+ }
95
+
96
+ .vote-action i {
97
+ font-size: 1rem;
98
+ }
99
+
100
+ .vote-action span {
101
+ font-size: 0.9rem;
102
+ font-weight: 500;
103
+ }
104
+ </style>
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <div style="display: flex; justify-content: flex-end; flex-direction: column;">
3
3
  <select data-test="cart-item-qty" class="select" v-if="showSelect" @change="qtySelectChange($event)" v-model="qty" style="text-align:center;">
4
- <option v-for="qty in selectRange" :value="qty" :key="qty">{{ qty }}</option>
4
+ <option v-for="q in selectRange" :value="q" :key="q">{{ q }}</option>
5
5
  <option value="smp">{{ selectMax + 1 }}+</option>
6
6
  </select>
7
7
  <form @submit.prevent="qtyUpdate" style="display:flex; flex-direction: column;">
@@ -16,8 +16,10 @@ import _ from 'underscore'
16
16
 
17
17
  export default {
18
18
  name: 'QuantityInput',
19
+
20
+ // Vue 3: Use modelValue instead of value for v-model
19
21
  props: {
20
- value: {
22
+ modelValue: {
21
23
  type: Number,
22
24
  required: false,
23
25
  default: 0,
@@ -43,6 +45,9 @@ export default {
43
45
  }
44
46
  },
45
47
 
48
+ // Vue 3: Declare emitted events
49
+ emits: ['update:modelValue'],
50
+
46
51
  data() {
47
52
  return {
48
53
  showSelect: true,
@@ -58,10 +63,13 @@ export default {
58
63
  },
59
64
 
60
65
  watch: {
61
- value: function (nv, ov) {
62
- this.qty = nv
63
- if (this.qty > this.selectMax) {
64
- this.showSelect = false
66
+ modelValue: {
67
+ immediate: true,
68
+ handler(nv) {
69
+ this.qty = nv
70
+ if (this.qty > this.selectMax) {
71
+ this.showSelect = false
72
+ }
65
73
  }
66
74
  }
67
75
  },
@@ -88,13 +96,15 @@ export default {
88
96
  this.$refs.textInput.focus()
89
97
  }, 100)
90
98
  } else {
91
- this.$emit('input', event.target.value)
99
+ // Vue 3: emit update:modelValue instead of input
100
+ this.$emit('update:modelValue', parseInt(event.target.value))
92
101
  }
93
102
  },
94
103
 
95
104
  qtyUpdate() {
96
105
  this.showUpdateButton = false
97
- this.$emit('input', this.qty)
106
+ // Vue 3: emit update:modelValue instead of input
107
+ this.$emit('update:modelValue', parseInt(this.qty))
98
108
  }
99
109
  }
100
110
  }