Total Complexity | 9 |
Complexity/F | 1.29 |
Lines of Code | 67 |
Function Count | 7 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import template from './sw-cms-el-buy-box.html.twig'; |
||
2 | import './sw-cms-el-buy-box.scss'; |
||
3 | |||
4 | const { Component, Mixin, Utils } = Shopware; |
||
|
|||
5 | |||
6 | Component.register('sw-cms-el-buy-box', { |
||
7 | template, |
||
8 | |||
9 | mixins: [ |
||
10 | Mixin.getByName('cms-element'), |
||
11 | Mixin.getByName('placeholder') |
||
12 | ], |
||
13 | |||
14 | computed: { |
||
15 | product() { |
||
16 | if (!this.element.data || !this.element.data.product) { |
||
17 | return { |
||
18 | name: 'Lorem Ipsum dolor', |
||
19 | productNumber: 'XXXXXX', |
||
20 | minPurchase: 1, |
||
21 | deliveryTime: { |
||
22 | name: '1-3 days' |
||
23 | }, |
||
24 | price: [ |
||
25 | { gross: 0.00 } |
||
26 | ] |
||
27 | }; |
||
28 | } |
||
29 | |||
30 | return this.element.data.product; |
||
31 | }, |
||
32 | |||
33 | pageType() { |
||
34 | return Utils.get(this.cmsPageState, 'currentPage.type', ''); |
||
35 | }, |
||
36 | |||
37 | isProductPageType() { |
||
38 | return this.pageType === 'product_detail'; |
||
39 | }, |
||
40 | |||
41 | alignStyle() { |
||
42 | if (!this.element.config.alignment || !this.element.config.alignment.value) { |
||
43 | return null; |
||
44 | } |
||
45 | |||
46 | return `justify-content: ${this.element.config.alignment.value};`; |
||
47 | } |
||
48 | }, |
||
49 | |||
50 | watch: { |
||
51 | pageType(newPageType) { |
||
52 | this.$set(this.element, 'locked', newPageType === 'product_detail'); |
||
53 | } |
||
54 | }, |
||
55 | |||
56 | created() { |
||
57 | this.createdComponent(); |
||
58 | }, |
||
59 | |||
60 | methods: { |
||
61 | createdComponent() { |
||
62 | this.initElementConfig('buy-box'); |
||
63 | this.initElementData('buy-box'); |
||
64 | this.$set(this.element, 'locked', this.isProductPageType); |
||
65 | } |
||
66 | } |
||
67 | }); |
||
68 |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.