@viur/shop-components 0.1.7 → 0.1.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viur/shop-components",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Frontend Vue components for the shop module of ViUR",
5
5
  "repository": {
6
6
  "type": "git",
package/src/Shop.vue CHANGED
@@ -30,7 +30,9 @@
30
30
  </div>
31
31
  </div>
32
32
  <template v-if="shopStore.state.debug">
33
+ <br>
33
34
  <sl-details summary="Debug">
35
+ <sl-icon slot="prefix" name="bug"></sl-icon>
34
36
  order: {{ shopStore.state.orderKey }}<br>
35
37
  cart: {{ shopStore.state.cartRoot?.['key'] }}<br><br>
36
38
 
@@ -51,8 +53,7 @@
51
53
  paid: {{ shopStore.state.order?.['is_paid'] }}<br><br>
52
54
 
53
55
  OrderObject: {{shopStore.state.order}}
54
-
55
-
56
+
56
57
  </sl-details>
57
58
  </template>
58
59
  <div id="dialogs"></div>
@@ -14,7 +14,7 @@
14
14
  <template v-if="tab?.['loaded']">
15
15
 
16
16
 
17
- <component :is="tab['component']">
17
+ <component :is="tab['component']" :params="tab['params']">
18
18
  <template #['template_'+name]>
19
19
  <slot :name="'template_'+name"></slot>
20
20
  </template>
@@ -100,8 +100,29 @@ function active(obj){
100
100
 
101
101
  <style scoped>
102
102
 
103
+ sl-tab-group {
104
+ flex-grow: 1;
105
+ &::part(base) {
106
+ height: 100%;
107
+ }
108
+ &::part(body) {
109
+ height: 100%;
110
+ }
111
+ }
112
+
113
+ sl-tap-panel {
114
+ height: 100%;
115
+ &::part(base) {
116
+ height: 100%;
117
+ display: flex;
118
+ flex-direction: column;
119
+ }
120
+ }
121
+
103
122
  .viur-shop-stepper-bar {
104
- margin-top: var(--shop-leaf-gap, var(--ignt-spacing-small))
123
+ margin-top: var(--shop-leaf-gap, var(--ignt-spacing-small));
124
+ justify-self: flex-end;
125
+ margin-top: auto;
105
126
  }
106
127
 
107
128
  .hint{
@@ -20,7 +20,7 @@
20
20
  <slot
21
21
  :nextName="$t('shop.proceed-checkout')"
22
22
  :activefunction="()=>state.items.length>0"
23
- :nextfunction="()=>true"
23
+ :nextfunction="nextStep"
24
24
  >
25
25
  </slot>
26
26
 
@@ -34,9 +34,18 @@ import LoadingHandler from '../components/LoadingHandler.vue';
34
34
  import CartItem from '../components/CartItem.vue';
35
35
  import CartItemSmall from '../components/CartItemSmall.vue';
36
36
  import ShopAlert from '../components/ShopAlert.vue';
37
+ import { useOrder } from '../composables/order';
37
38
 
38
39
  const shopStore = useViurShopStore()
39
40
  const {fetchCart,addItem, state:cartState} = useCart()
41
+ const {addOrUpdateOrder} = useOrder()
42
+
43
+ const props = defineProps({
44
+ params:{
45
+ type:Object,
46
+ default:{}
47
+ }
48
+ })
40
49
 
41
50
  const state = reactive({
42
51
  items: computed(()=>shopStore.state.cartList.filter(i=>i['skel_type']==='leaf'))
@@ -46,6 +55,17 @@ onBeforeMount(()=>{
46
55
  fetchCart()
47
56
  })
48
57
 
58
+ async function nextStep(){
59
+ try{
60
+ let resp = await addOrUpdateOrder()
61
+ console.log(resp)
62
+ return true
63
+
64
+ } catch(error){
65
+ return false
66
+ }
67
+ }
68
+
49
69
  </script>
50
70
  <style scoped>
51
71
 
@@ -29,4 +29,12 @@ import {computed, reactive} from 'vue'
29
29
  import { useViurShopStore } from '../shop';
30
30
  import ShopSummary from '../ShopSummary.vue';
31
31
  const shopStore = useViurShopStore()
32
+
33
+ const props = defineProps({
34
+ params:{
35
+ type:Object,
36
+ default:{}
37
+ }
38
+ })
39
+
32
40
  </script>
@@ -68,6 +68,9 @@
68
68
  </sl-details>
69
69
  </div>
70
70
 
71
+ <component :is="params['additionalComponent']" v-if="params['additionalComponent']" ref="additionalComponent">
72
+ </component>
73
+
71
74
  <div class="wrapper">
72
75
  <sl-button size="small" @click="startCheckout" :disabled="!shopStore.state.canCheckout" variant="success">{{ $t('shop.order_pay') }}</sl-button>
73
76
  </div>
@@ -82,7 +85,7 @@
82
85
  </slot>
83
86
  </template>
84
87
  <script setup>
85
- import {computed, onBeforeMount, reactive, watch} from 'vue'
88
+ import {computed, onBeforeMount, reactive, watch, useTemplateRef} from 'vue'
86
89
  import { useViurShopStore } from '../shop';
87
90
  import boneUtils from '@viur/vue-utils/bones/utils'
88
91
  import {Request} from '@viur/vue-utils'
@@ -90,6 +93,14 @@ import CartItemSmall from '../components/CartItemSmall.vue';
90
93
  import PaymentProviderUnzer from '../components/PaymentProviderUnzer.vue';
91
94
  const shopStore = useViurShopStore()
92
95
 
96
+ const additionalComponent = useTemplateRef('additionalComponent')
97
+
98
+ const props = defineProps({
99
+ params:{
100
+ type:Object,
101
+ default:{}
102
+ }
103
+ })
93
104
 
94
105
  // collected data from order Object > Session cart is not available anymore
95
106
  const state = reactive({
@@ -124,7 +135,13 @@ function paymentCanceled(){
124
135
  }
125
136
 
126
137
  //open popup and freeze cart
127
- function startCheckout(){
138
+ async function startCheckout(){
139
+ if (props.params?.additionalComponent){
140
+ let valid = await additionalComponent.value.valid()
141
+ if (!valid){
142
+ return false
143
+ }
144
+ }
128
145
  state.paymentPopup=true
129
146
  shopStore.checkout()
130
147
  }
@@ -38,6 +38,13 @@ const {state:paymentState, fetchPaymentData} = usePayment()
38
38
  const {addOrUpdateOrder} = useOrder()
39
39
  const shopStore = useViurShopStore()
40
40
 
41
+ const props = defineProps({
42
+ params:{
43
+ type:Object,
44
+ default:{}
45
+ }
46
+ })
47
+
41
48
  const state = reactive({
42
49
  selection:null,
43
50
  })
@@ -40,6 +40,13 @@ const {updateCart} = useCart();
40
40
  const {fetchOrder} = useOrder();
41
41
  const {state: shippingState,fetchShippingData} = useShipping();
42
42
 
43
+ const props = defineProps({
44
+ params:{
45
+ type:Object,
46
+ default:{}
47
+ }
48
+ })
49
+
43
50
  const state = reactive({
44
51
  selectedShippingMethod: null
45
52
  })
@@ -16,6 +16,10 @@
16
16
  <address-form formtype="shipping" >
17
17
  </address-form>
18
18
  </div>
19
+
20
+ <component :is="params['additionalComponent']" v-if="params['additionalComponent']" ref="additionalComponent">
21
+ </component>
22
+
19
23
  <slot name="template_userdata">
20
24
  </slot>
21
25
 
@@ -31,12 +35,19 @@
31
35
 
32
36
 
33
37
  <script setup>
34
- import {reactive, onBeforeMount, watch} from 'vue'
38
+ import {reactive, onBeforeMount, watch, useTemplateRef} from 'vue'
35
39
  import AddressForm from '../components/AddressForm.vue'
36
40
  import {useAddress} from "../composables/address";
37
41
  import {useViurShopStore} from "../shop";
38
42
  const shopStore = useViurShopStore();
39
43
  const {state:addressState,saveAddresses} = useAddress()
44
+ const additionalComponent = useTemplateRef('additionalComponent')
45
+ const props = defineProps({
46
+ params:{
47
+ type:Object,
48
+ default:{}
49
+ }
50
+ })
40
51
 
41
52
  const state = reactive({
42
53
  })
@@ -61,12 +72,20 @@ onBeforeMount(()=>{
61
72
  async function nextStep(){
62
73
  // form is only valid if the action field ends with Success
63
74
  try{
75
+ if (props.params?.additionalComponent){
76
+ let valid = await additionalComponent.value.valid()
77
+ if (!valid){
78
+ return false
79
+ }
80
+ }
81
+
64
82
  let result = await saveAddresses(addressState.billingIsShipping)
65
83
  if (result['action'] && result['action'].endsWith('Success')){
66
84
  return true
67
85
  }
68
86
  return false
69
87
  } catch(error){
88
+ console.log(error)
70
89
  return false
71
90
  }
72
91
  }
@@ -15,10 +15,16 @@
15
15
  <h5 v-if="item.shop_art_no_or_gtin" class="viur-shop-cart-leaf-artno" slot="header">
16
16
  {{ getValue(item.shop_art_no_or_gtin) }}
17
17
  </h5>
18
- <h4
19
- class="viur-shop-cart-leaf-headline headline"
20
- v-html="getValue(item.shop_name)"
21
- ></h4>
18
+ <a class="viur-shop-cart-leaf-headline-link" :href="item.article.dest.view_url" v-if="item.article?.dest?.view_url">
19
+ <h4
20
+ class="viur-shop-cart-leaf-headline headline"
21
+ v-html="getValue(item.shop_name)"
22
+ ></h4>
23
+ </a>
24
+ <h4 v-else
25
+ class="viur-shop-cart-leaf-headline headline"
26
+ v-html="getValue(item.shop_name)"
27
+ ></h4>
22
28
  <div
23
29
  class="viur-shop-cart-leaf-description"
24
30
  v-html="getValue(item.shop_description)"
@@ -129,7 +135,11 @@ function removeArticle(){
129
135
  </script>
130
136
  <style scoped>
131
137
  @layer foundation.shop {
132
-
138
+ .viur-shop-cart-leaf-headline-link{
139
+ grid-column: 1 / span 4;
140
+ margin: 0;
141
+ font-size: var(--shop-leaf-headline-font-size);
142
+ }
133
143
  .availability {
134
144
  display: flex;
135
145
  flex-basis: 70%;
package/src/shop.js CHANGED
@@ -24,6 +24,7 @@ export const useViurShopStore = defineStore("viurshopStore", () => {
24
24
  tabs:{
25
25
  cart: {
26
26
  component: shallowRef(ShopCart),
27
+ params:{},
27
28
  displayName: "shop.order_step_cart", //Warenkorb
28
29
  icon: { name: "cart3" },
29
30
  active:computed(()=>!state.order?.['is_checkout_in_progress'] && !state.order?.['is_ordered']), //active if no orderkey or checkout not startet
@@ -32,6 +33,7 @@ export const useViurShopStore = defineStore("viurshopStore", () => {
32
33
  },
33
34
  userdata: {
34
35
  component: shallowRef(ShopUserDataGuest),
36
+ params:{},
35
37
  displayName: "shop.order_step_data", //Daten Eingeben
36
38
  icon: { name: "card-list" },
37
39
  active:computed(()=>!state.order?.['is_checkout_in_progress'] && !state.order?.['is_ordered'] && state.cartList.length>0), //active if checkout not startet and cart is not empty
@@ -40,6 +42,7 @@ export const useViurShopStore = defineStore("viurshopStore", () => {
40
42
  },
41
43
  shippingmethod: {
42
44
  component: shallowRef(ShopShippingMethod),
45
+ params:{},
43
46
  displayName: "shop.order_step_shipping", // Versandart
44
47
  icon: { name: "truck" },
45
48
  active:computed(()=>!state.order?.['is_checkout_in_progress'] && !state.order?.['is_ordered'] && state.cartRoot?.['shipping_address']), // we need a shipping country
@@ -48,6 +51,7 @@ export const useViurShopStore = defineStore("viurshopStore", () => {
48
51
  },
49
52
  paymentprovider: {
50
53
  component: shallowRef(ShopPaymentProvider),
54
+ params:{},
51
55
  displayName: "shop.order_step_payment", //Zahlungsart auswählen
52
56
  icon: { name: "credit-card" },
53
57
  active:computed(()=>!state.order?.['is_checkout_in_progress'] && state.order && state.cartRoot?.['shipping']), // we need a active order
@@ -56,6 +60,7 @@ export const useViurShopStore = defineStore("viurshopStore", () => {
56
60
  },
57
61
  confirm: {
58
62
  component: shallowRef(ShopOrderConfirm),
63
+ params:{},
59
64
  displayName: "shop.order_step_verify", //Bestellung prüfen
60
65
  icon: { name: "clipboard-check" },
61
66
  active:computed(()=>!state.order?.['is_paid'] && state.canCheckout?.['status']), // active if canCheckout and not already paid
@@ -64,6 +69,7 @@ export const useViurShopStore = defineStore("viurshopStore", () => {
64
69
  },
65
70
  complete: {
66
71
  component: shallowRef(ShopOrderComplete),
72
+ params:{},
67
73
  displayName: "shop.order_step_complete", //Bestellung Abgeschlossen
68
74
  icon: { name: "bag-check" },
69
75
  active:computed(()=>state.order?.['is_ordered']), // active if ordered