Total Complexity | 14 |
Complexity/F | 2 |
Lines of Code | 77 |
Function Count | 7 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import template from './sw-cms-el-image.html.twig'; |
||
2 | import './sw-cms-el-image.scss'; |
||
3 | |||
4 | const { Component, Mixin, Filter } = Shopware; |
||
|
|||
5 | |||
6 | Component.register('sw-cms-el-image', { |
||
7 | template, |
||
8 | |||
9 | mixins: [ |
||
10 | Mixin.getByName('cms-element') |
||
11 | ], |
||
12 | |||
13 | computed: { |
||
14 | displayModeClass() { |
||
15 | if (this.element.config.displayMode.value === 'standard') { |
||
16 | return null; |
||
17 | } |
||
18 | |||
19 | return `is--${this.element.config.displayMode.value}`; |
||
20 | }, |
||
21 | |||
22 | styles() { |
||
23 | return { |
||
24 | 'min-height': this.element.config.displayMode.value === 'cover' && |
||
25 | this.element.config.minHeight.value !== 0 ? this.element.config.minHeight.value : '340px', |
||
26 | 'align-self': !this.element.config.verticalAlign.value ? null : this.element.config.verticalAlign.value |
||
27 | }; |
||
28 | }, |
||
29 | |||
30 | mediaUrl() { |
||
31 | const elemData = this.element.data.media; |
||
32 | const mediaSource = this.element.config.media.source; |
||
33 | |||
34 | if (mediaSource === 'mapped') { |
||
35 | const demoMedia = this.getDemoValue(this.element.config.media.value); |
||
36 | |||
37 | if (demoMedia && demoMedia.url) { |
||
38 | return demoMedia.url; |
||
39 | } |
||
40 | } |
||
41 | |||
42 | if (elemData && elemData.id) { |
||
43 | return this.element.data.media.url; |
||
44 | } |
||
45 | |||
46 | if (elemData && elemData.url) { |
||
47 | return this.assetFilter(elemData.url); |
||
48 | } |
||
49 | |||
50 | return this.assetFilter('administration/static/img/cms/preview_mountain_large.jpg'); |
||
51 | }, |
||
52 | |||
53 | assetFilter() { |
||
54 | return Filter.getByName('asset'); |
||
55 | } |
||
56 | }, |
||
57 | |||
58 | watch: { |
||
59 | cmsPageState: { |
||
60 | deep: true, |
||
61 | handler() { |
||
62 | this.$forceUpdate(); |
||
63 | } |
||
64 | } |
||
65 | }, |
||
66 | |||
67 | created() { |
||
68 | this.createdComponent(); |
||
69 | }, |
||
70 | |||
71 | methods: { |
||
72 | createdComponent() { |
||
73 | this.initElementConfig('image'); |
||
74 | this.initElementData('image'); |
||
75 | } |
||
76 | } |
||
77 | }); |
||
78 |
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.