@viur/shop-components 0.0.1-dev.6 → 0.0.1-dev.60

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 (77) hide show
  1. package/.editorconfig +16 -0
  2. package/.github/workflows/npm-publish.yml +42 -0
  3. package/.gitmodules +3 -0
  4. package/LICENSE +21 -0
  5. package/README.md +13 -2
  6. package/package.json +25 -23
  7. package/src/components/ShopCart.vue +512 -0
  8. package/src/components/ShopOrderComplete.vue +73 -0
  9. package/src/components/ShopOrderConfirm.vue +291 -0
  10. package/src/components/ShopOrderStepper.vue +264 -0
  11. package/src/components/ShopUserData.vue +232 -0
  12. package/src/components/cart/CartLeaf.vue +277 -0
  13. package/src/components/cart/CartLeafModel.vue +304 -0
  14. package/src/components/cart/CartNode.vue +25 -0
  15. package/src/components/cart/CartTree.vue +54 -0
  16. package/src/components/cart/CartTreeWrapper.vue +73 -0
  17. package/src/components/cart/CartView.vue +205 -174
  18. package/src/components/cart/Discount.vue +91 -0
  19. package/src/components/lib/utils.js +0 -0
  20. package/src/components/order/OrderSidebar.vue +102 -0
  21. package/src/components/order/item/ItemView.vue +0 -1
  22. package/src/components/{cart → order/process}/ConfirmView.vue +94 -96
  23. package/src/components/order/process/ExampleUsage.vue +79 -66
  24. package/src/components/order/process/OrderTabHeader.vue +10 -1
  25. package/src/components/order/process/SelectPaymentProvider.vue +62 -0
  26. package/src/components/order/process/Shipping.vue +46 -0
  27. package/src/components/ui/ShopSummary.vue +145 -0
  28. package/src/components/ui/generic/ArticleList.vue +222 -0
  29. package/src/components/ui/generic/ExamplePagination.vue +236 -0
  30. package/src/components/ui/generic/ShopPriceFormatter.vue +41 -0
  31. package/src/components/ui/generic/alerts/ShopAlert.vue +19 -0
  32. package/src/components/ui/generic/makeData.js +39 -0
  33. package/src/components/ui/stepper/StepperItem.vue +39 -0
  34. package/src/components/ui/stepper/StepperTab.vue +133 -0
  35. package/src/components/ui/stepper/StepperTrigger.vue +35 -0
  36. package/src/components/ui/userdata/AddForm.vue +125 -0
  37. package/src/components/ui/userdata/AddressBox.vue +117 -0
  38. package/src/components/ui/userdata/BaseLayout.vue +94 -0
  39. package/src/components/ui/userdata/CustomBooleanBone.vue +58 -0
  40. package/src/components/ui/userdata/CustomSelectBone.vue +91 -0
  41. package/src/components/ui/userdata/CustomStringBone.vue +71 -0
  42. package/src/components/ui/userdata/DefaultLayout.vue +126 -0
  43. package/src/components/ui/userdata/SelectAddress.vue +21 -0
  44. package/src/components/ui/userdata/multi/ActionBar.vue +38 -0
  45. package/src/components/ui/userdata/multi/CartSelection.vue +42 -0
  46. package/src/main.js +50 -0
  47. package/src/router/index.js +1 -1
  48. package/src/stores/cart.js +267 -42
  49. package/src/style/ignite/.editorconfig +20 -0
  50. package/src/style/ignite/.github/workflows/ignite.yml +64 -0
  51. package/src/style/ignite/.github/workflows/node.yml +30 -0
  52. package/src/style/ignite/.postcssrc.cjs +25 -0
  53. package/src/style/ignite/CHANGELOG.md +244 -0
  54. package/src/style/ignite/LICENSE +21 -0
  55. package/src/style/ignite/README.md +92 -0
  56. package/src/style/ignite/dist/ignite.css +2019 -0
  57. package/src/style/ignite/dist/ignite.min.css +4 -0
  58. package/src/style/ignite/foundation/basic.css +371 -0
  59. package/src/style/ignite/foundation/color.css +323 -0
  60. package/src/style/ignite/foundation/config.css +188 -0
  61. package/src/style/ignite/foundation/grid.css +78 -0
  62. package/src/style/ignite/foundation/mediaqueries.css +71 -0
  63. package/src/style/ignite/foundation/reset.css +261 -0
  64. package/src/style/ignite/ignite.css +29 -0
  65. package/src/style/ignite/ignite.css.map +1 -0
  66. package/src/style/ignite/package-lock.json +5530 -0
  67. package/src/style/ignite/package.json +58 -0
  68. package/src/style/ignite/shoelace.css +19 -0
  69. package/src/style/ignite/themes/dark.css +12 -0
  70. package/src/style/ignite/themes/light.css +11 -0
  71. package/src/style/ignite/utilities/shoelace.css +537 -0
  72. package/src/style/ignite/utilities/utilities.css +24 -0
  73. package/vite.config.js +53 -0
  74. package/src/components/order/information/UserInfoMulti.vue +0 -427
  75. package/src/components/order/information/UserInformation.vue +0 -332
  76. package/src/components/order/process/OrderComplete.vue +0 -41
  77. package/src/components/order/process/OrderView.vue +0 -210
@@ -1,40 +1,93 @@
1
- import { reactive } from "vue";
2
- import { Request, ListRequest } from "@viur/vue-utils";
1
+ import { reactive, computed, watch } from "vue";
3
2
  import { defineStore } from "pinia";
4
3
  import { ViURShopClient } from "@viur/viur-shop-client";
5
4
 
6
5
  export const useCartStore = defineStore("cartstore", () => {
7
6
  const shopClient = new ViURShopClient({
8
- host_url: window.location.origin === "http://localhost:8081"
9
- ? "http://localhost:8080"
10
- : window.location.origin,
7
+ host_url:
8
+ window.location.origin === "http://localhost:8081"
9
+ ? "http://localhost:8080"
10
+ : window.location.origin,
11
11
  });
12
-
12
+ let isFetching = false;
13
+ const waitForFetching = [];
14
+ const waitForFetchingResolver = [];
13
15
  const state = reactive({
14
- basket: "",
15
- carts: {},
16
+ basketRootNode: {},
17
+ basket: [],
18
+ wishlistRootNodes: [],
19
+ childrenByNode: {},
16
20
  structure: { address: {}, cart: {} },
21
+ paymentProviders: {},
22
+ billingAddressList: [],
23
+ shippingAddressList: [],
24
+ cloneBilling: true,
25
+ activeBillingAddress: {},
26
+ activeShippingAddress: {},
27
+ selectedPaymentProvider: {},
28
+ selectedPaymentProviderName: "",
29
+ customer: {},
30
+ isLoggedIn: false,
31
+ placeholder: "",
17
32
  });
18
33
 
19
- async function init() {
20
- await getCarts();
21
- }
34
+ async function init(placeholder = "") {
35
+ if (!isFetching) {
36
+ isFetching = true;
37
+ await getRootNodes();
38
+ await getCustomer();
39
+ await getAddress();
40
+ await getBasket();
22
41
 
23
- async function getCarts() {
24
- let carts = await shopClient.cart_list();
25
- carts.forEach(async (cart) => {
26
- state.carts[cart.key] = {};
27
- state.carts[cart.key].info = cart;
28
- if (cart.cart_type === "basket") {
29
- state.basket = cart.key;
42
+ isFetching = false;
43
+ for (const waiter of waitForFetchingResolver) {
44
+ waiter();
30
45
  }
31
- await getCartItems(cart.key);
32
- });
46
+ waitForFetchingResolver.splice(0, waitForFetchingResolver.length);
47
+ waitForFetching.splice(0, waitForFetchingResolver.length);
48
+ } else {
49
+ const p = new Promise((resolve, reject) => {
50
+ waitForFetchingResolver.push(resolve);
51
+ });
52
+ waitForFetching.push(p);
53
+ return p;
54
+ }
55
+ state.placeholder = placeholder;
56
+ }
57
+
58
+ async function getCustomer() {
59
+ try {
60
+ const resp = await shopClient.user_view();
61
+ state.customer = resp;
62
+ state.isLoggedIn = true;
63
+ } catch (e) {
64
+ state.isLoggedIn = false;
65
+ }
66
+
67
+ console.log("passiert", state.customer);
33
68
  }
69
+ async function getBasket() {
70
+ state.basket = await shopClient.basket_list();
71
+ }
72
+
73
+ async function getChildren(parentKey) {
74
+ return await shopClient.cart_list({ cart_key: parentKey });
75
+ }
76
+
77
+ async function getRootNodes() {
78
+ let resp = await shopClient.cart_list();
34
79
 
35
- async function getCartItems(cartKey) {
36
- let cartItems = await shopClient.cart_list({ cart_key: cartKey });
37
- state.carts[cartKey].items = cartItems;
80
+ resp.forEach(async (rootNode) => {
81
+ if (rootNode.is_root_node) {
82
+ if (rootNode.cart_type === "basket") {
83
+ state.basketRootNode = rootNode;
84
+ const rootChildren = await getChildren(rootNode.key);
85
+ state.childrenByNode[rootNode.key] = rootChildren;
86
+ } else {
87
+ state.whishlistRootNodes.push(rootNode);
88
+ }
89
+ }
90
+ });
38
91
  }
39
92
 
40
93
  async function addToCart(articleKey, cartKey) {
@@ -43,7 +96,7 @@ export const useCartStore = defineStore("cartstore", () => {
43
96
  parent_cart_key: cartKey,
44
97
  });
45
98
 
46
- await updateCart(cartKey);
99
+ // await updateCart(cartKey);
47
100
  console.log("addToCart", resp); //TODO: Errorhandling as soon as shop module works again
48
101
  }
49
102
 
@@ -62,42 +115,204 @@ export const useCartStore = defineStore("cartstore", () => {
62
115
  parent_cart_key: cartKey,
63
116
  });
64
117
 
65
- await updateCart(cartKey);
66
-
67
118
  console.log("remove Resp", resp); //TODO: Errorhandling as soon as shop module works again
68
119
  }
69
120
 
70
121
  async function updateItem(articleKey, cartKey, quantity) {
71
- let resp = await shopClient.article_update({
122
+ const resp = await shopClient.article_update({
72
123
  article_key: articleKey,
73
124
  parent_cart_key: cartKey,
74
125
  quantity: quantity,
75
126
  quantity_mode: "replace",
76
127
  });
77
128
 
78
- if (quantity === 0) {
79
- await updateCart(cartKey);
80
- }
81
129
  console.log("update Resp", resp); //TODO: Errorhandling as soon as shop module works again
82
130
  }
83
131
 
84
- async function updateCart(cartKey) {
85
- await getCartItems(cartKey);
132
+ // async function updateCart(cartKey) {
133
+ // await getChildren(cartKey);
134
+ // }
135
+
136
+ async function getAddressStructure() {
137
+ const structure = await shopClient.address_structure();
138
+ state.structure.address = struct2dict(structure.addSkel);
139
+ }
140
+
141
+ function getDefaultAddress() {
142
+ if (!!state.billingAddressList) {
143
+ state.billingAddressList.forEach((address) => {
144
+ if (address.is_default) {
145
+ state.activeBillingAddress = address;
146
+ }
147
+ });
148
+ } else {
149
+ state.activeBillingAddress = setAddressValues("billing");
150
+ }
151
+ if (!!state.shippingAddressList) {
152
+ state.shippingAddressList.forEach((address) => {
153
+ if (address.is_default && !state.cloneBilling) {
154
+ state.activeShippingAddress = address;
155
+ }
156
+ });
157
+ } else {
158
+ if (state.cloneBilling) {
159
+ state.activeShippingAddress = { ...state.activeBillingAddress };
160
+ } else {
161
+ state.activeShippingAddress = setAddressValues("shipping");
162
+ }
163
+ }
164
+ }
165
+
166
+ function setAddressValues(mode) {
167
+ let structure = state.structure.address;
168
+ let skel = {};
169
+
170
+ Object.entries(structure).forEach(([boneName, boneValue]) => {
171
+ if (boneName === "customer") {
172
+ skel[boneName] = state.customer.key;
173
+ } else if (boneName === "address_type") {
174
+ skel[boneName] = mode;
175
+ } else {
176
+ skel[boneName] = boneValue.emptyvalue;
177
+ }
178
+ });
179
+
180
+ return skel;
181
+ }
182
+
183
+ async function getAddress() {
184
+ if (!state.isLoggedIn) {
185
+ return;
186
+ }
187
+ try {
188
+ const addressList = await shopClient.address_list();
189
+ } catch (e) {
190
+ console.log("error", e);
191
+ return;
192
+ }
193
+
194
+ const addressList = await shopClient.address_list();
195
+ state.billingAddressList = [];
196
+ state.shippingAddressList = [];
197
+
198
+ for (const address of addressList) {
199
+ if (address.address_type === "billing") {
200
+ console.log("add to bill address ?", address);
201
+ state.billingAddressList.push(address);
202
+ }
203
+ if (address.address_type === "shipping") {
204
+ state.shippingAddressList.push(address);
205
+ }
206
+ }
207
+
208
+ getDefaultAddress();
209
+ }
210
+
211
+ async function addDiscount(code) {
212
+ await shopClient.discount_add({ code });
213
+ }
214
+
215
+ async function addNode(
216
+ parentCart,
217
+ cartType = "whishlist",
218
+ cartName = undefined,
219
+ comment = undefined,
220
+ shipping_key = undefined,
221
+ shipping_address_key = undefined,
222
+ discount_key = undefined,
223
+ ) {
224
+ return await shopClient.cart_add({
225
+ parent_cart_key: parentCart,
226
+ // cart_type: cartType, // "basket" for main cart, "whishlist" for everything else
227
+ // name: cartName,
228
+ // customer_comment: comment,
229
+ // shipping_address_key: shipping_address_key,
230
+ // shipping_key: shipping_key,
231
+ // discount_key: discount_key,
232
+ });
233
+ }
234
+
235
+ async function getShippingData() {
236
+ return await shopClient.shipping_list({
237
+ cart_key: state.basketRootNode.key,
238
+ });
239
+ }
240
+ async function setShiping() {
241
+ return await shopClient.shipping_set();
242
+ }
243
+
244
+ async function getPaymentProviders() {
245
+ const paymentProvieders = await shopClient.payment_providers_list();
246
+ state.paymentProviders = paymentProvieders;
247
+ //select first paymentprovider as default
248
+ state.selectedPaymentProvider =
249
+ paymentProvieders[Object.keys(paymentProvieders)[0]];
250
+ state.selectedPaymentProviderName = Object.keys(paymentProvieders)[0];
86
251
  }
87
252
 
88
- async function getAdressStructure() {
89
- let addSkel = await shopClient.address_structure()
90
- state.structure.address = addSkel.addSkel
253
+ function struct2dict(structure) {
254
+ if (!Array.isArray(structure)) {
255
+ return structure;
256
+ }
91
257
 
92
- console.log("adress add", state.structure.address);
258
+ let result = {};
259
+ structure.forEach((bone) => (result[bone[0]] = bone[1]));
93
260
 
94
- // Request.getStructure("shop.address").then(async (resp) => {
95
- // let data = await resp.json();
96
- // state.structure.address = data.addSkel;
261
+ return result;
262
+ }
97
263
 
98
- // console.log("adress add", state.structure.address);
99
- // });
264
+ async function orderAdd() {
265
+ const order = await shopClient.order_add({
266
+ cart_key: state.basketRootNode.key,
267
+ payment_provider: state.selectedPaymentProviderName,
268
+ billing_address_key: state.activeBillingAddress["key"],
269
+ customer_key: state.customer["key"],
270
+ });
271
+ return order;
100
272
  }
273
+ async function setShipping() {
274
+ const shipping_skel = shopClient;
275
+ }
276
+
277
+ watch(
278
+ () => state.activeBillingAddress,
279
+ (newValue, oldValue) => {
280
+ if (oldValue) {
281
+ const isAddress = (address) => address.key === newValue.key;
282
+
283
+ let index = state.billingAddressList.findIndex(isAddress);
284
+
285
+ state.billingAddressList[index] = newValue;
286
+ }
287
+ if (state.cloneBilling) {
288
+ state.activeShippingAddress = newValue;
289
+ }
290
+ },
291
+ );
292
+
293
+ watch(
294
+ () => state.activeShippingAddress,
295
+ (newValue, oldValue) => {
296
+ if (oldValue) {
297
+ const isAddress = (address) => address.key === newValue.key;
298
+
299
+ let index = state.shippingAddressList.findIndex(isAddress);
300
+
301
+ state.shippingAddressList[index] = newValue;
302
+ }
303
+ },
304
+ );
305
+
306
+ watch(
307
+ () => state.cloneBilling,
308
+ (newValue, oldValue) => {
309
+ if (newValue) {
310
+ let temp = { ...state.activeBillingAddress };
311
+ temp.address_type = "shipping";
312
+ state.activeShippingAddress = { ...temp };
313
+ }
314
+ },
315
+ );
101
316
 
102
317
  return {
103
318
  state,
@@ -106,6 +321,16 @@ export const useCartStore = defineStore("cartstore", () => {
106
321
  removeItem,
107
322
  updateItem,
108
323
  init,
109
- getAdressStructure,
324
+ getAddressStructure,
325
+ getChildren,
326
+ addDiscount,
327
+ getPaymentProviders,
328
+ getAddress,
329
+ addNode,
330
+ getShippingData,
331
+ getDefaultAddress,
332
+ orderAdd,
333
+ getBasket,
334
+ setShiping,
110
335
  };
111
336
  });
@@ -0,0 +1,20 @@
1
+ # editorconfig.org
2
+ # source: https://gist.github.com/sveneberth/b30d6639067177a31b5ab68af63a23e9
3
+
4
+ root = true
5
+
6
+ [*]
7
+ indent_style = tab
8
+ tab_width = 4
9
+ end_of_line = lf
10
+ charset = utf-8
11
+ trim_trailing_whitespace = true
12
+ insert_final_newline = true
13
+ max_line_length = 120
14
+
15
+ [*.{css,less,yml,yaml,json}]
16
+ indent_style = space
17
+ indent_size = 2
18
+
19
+ [*.md]
20
+ trim_trailing_whitespace = false
@@ -0,0 +1,64 @@
1
+ name: Build Ignite
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v5.*"
7
+
8
+ jobs:
9
+ build:
10
+ runs-on: ubuntu-latest
11
+
12
+ strategy:
13
+ matrix:
14
+ node-version: [16.x]
15
+
16
+ steps:
17
+ - uses: actions/checkout@v2
18
+ with:
19
+ submodules: true
20
+ path: "app/sources"
21
+
22
+ - name: Use Node.js ${{ matrix.node-version }}
23
+ uses: actions/setup-node@v2
24
+ with:
25
+ node-version: ${{ matrix.node-version }}
26
+ cache: 'npm'
27
+ cache-dependency-path: 'package-lock.json'
28
+ - run: npm install
29
+ - run: npm run build
30
+ - uses: actions/upload-artifact@master
31
+ with:
32
+ name: buildfiles
33
+ path: dist
34
+
35
+
36
+ release:
37
+ runs-on: ubuntu-latest
38
+ needs: [ build ]
39
+
40
+ steps:
41
+ - name: Checkout code
42
+ uses: actions/checkout@v2
43
+
44
+ - uses: actions/download-artifact@master
45
+ with:
46
+ name: buildfiles
47
+ path: ./dist
48
+
49
+ - name: archive
50
+ run: cd ./dist && zip viur-ignite.zip -r ./*
51
+
52
+ - name: Get version from tag
53
+ id: tag_name
54
+ run: |
55
+ echo ::set-output name=current_version::${GITHUB_REF#refs/tags/v}
56
+
57
+ - name: create release
58
+ uses: softprops/action-gh-release@v1
59
+ with:
60
+ files: ./dist/viur-ignite.zip
61
+ env:
62
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63
+
64
+
@@ -0,0 +1,30 @@
1
+ name: Node.js CI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v5.*"
7
+
8
+ jobs:
9
+ build:
10
+ runs-on: ubuntu-latest
11
+
12
+ strategy:
13
+ matrix:
14
+ node-version: [16.x]
15
+
16
+ steps:
17
+ - uses: actions/checkout@v2
18
+ with:
19
+ submodules: true
20
+ - name: Use Node.js ${{ matrix.node-version }}
21
+ uses: actions/setup-node@v2
22
+ with:
23
+ node-version: ${{ matrix.node-version }}
24
+ cache: 'npm'
25
+ - run: npm install
26
+ - run: npm run build
27
+ - uses: JS-DevTools/npm-publish@v1
28
+ with:
29
+ access: "public"
30
+ token: ${{ secrets.NPM_TOKEN }}
@@ -0,0 +1,25 @@
1
+ const enableBuild = process.env.mode === 'build'
2
+
3
+ module.exports = ({ ctx }) => ({
4
+ map: enableBuild ? false : 'inline',
5
+ plugins: {
6
+ 'postcss-discard-comments': enableBuild ? {} : false,
7
+ '@csstools/postcss-bundler': {},
8
+ 'postcss-preset-env': {
9
+ stage: 3,
10
+ minimumVendorImplementations: 2,
11
+ autoprefixer: {},
12
+ debug: true,
13
+ features: {
14
+ 'color-mix': true,
15
+ 'nesting-rules': true,
16
+ 'oklab-function': true,
17
+ //'cascade-layers': true,
18
+ 'custom-media-queries': true,
19
+ }
20
+ },
21
+ 'postcss-focus': {},
22
+ 'postcss-sort-media-queries': {},
23
+ 'cssnano': enableBuild ? {} : false,
24
+ }
25
+ })