|
1
|
|
|
import template from './sw-extension-listing-card.html.twig'; |
|
2
|
|
|
import './sw-extension-listing-card.scss'; |
|
3
|
|
|
|
|
4
|
|
|
const { Utils, Filter } = Shopware; |
|
|
|
|
|
|
5
|
|
|
|
|
6
|
|
|
const { Component } = Shopware; |
|
7
|
|
|
|
|
8
|
|
|
Component.register('sw-extension-listing-card', { |
|
9
|
|
|
template, |
|
10
|
|
|
|
|
11
|
|
|
inject: [ |
|
12
|
|
|
'shopwareExtensionService' |
|
13
|
|
|
], |
|
14
|
|
|
|
|
15
|
|
|
props: { |
|
16
|
|
|
extension: { |
|
17
|
|
|
type: Object, |
|
18
|
|
|
required: true |
|
19
|
|
|
} |
|
20
|
|
|
}, |
|
21
|
|
|
|
|
22
|
|
|
computed: { |
|
23
|
|
|
previewMedia() { |
|
24
|
|
|
const image = Utils.get(this.extension, 'images[0]', null); |
|
25
|
|
|
|
|
26
|
|
|
if (!image) { |
|
27
|
|
|
return { |
|
28
|
|
|
'background-image': this.defaultThemeAsset |
|
29
|
|
|
}; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
return { |
|
33
|
|
|
'background-image': `url('${image.remoteLink}')`, |
|
34
|
|
|
'background-size': 'cover' |
|
35
|
|
|
}; |
|
36
|
|
|
}, |
|
37
|
|
|
|
|
38
|
|
|
defaultThemeAsset() { |
|
39
|
|
|
return `url('${this.assetFilter('/administration/static/img/theme/default_theme_preview.jpg')}')`; |
|
40
|
|
|
}, |
|
41
|
|
|
|
|
42
|
|
|
recommendedVariant() { |
|
43
|
|
|
return this.shopwareExtensionService.orderVariantsByRecommendation(this.extension.variants)[0]; |
|
44
|
|
|
}, |
|
45
|
|
|
|
|
46
|
|
|
hasActiveDiscount() { |
|
47
|
|
|
return this.shopwareExtensionService.isVariantDiscounted(this.recommendedVariant); |
|
48
|
|
|
}, |
|
49
|
|
|
|
|
50
|
|
|
discountClass() { |
|
51
|
|
|
return { |
|
52
|
|
|
'sw-extension-listing-card__info-price-discounted': this.hasActiveDiscount |
|
53
|
|
|
}; |
|
54
|
|
|
}, |
|
55
|
|
|
|
|
56
|
|
|
calculatedPrice() { |
|
57
|
|
|
if (!this.recommendedVariant) { |
|
58
|
|
|
return null; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
return this.$tc( |
|
62
|
|
|
'sw-extension-store.general.labelPrice', |
|
63
|
|
|
this.shopwareExtensionService.mapVariantToRecommendation(this.recommendedVariant), |
|
64
|
|
|
{ |
|
65
|
|
|
price: Utils.format.currency( |
|
66
|
|
|
this.shopwareExtensionService.getPriceFromVariant(this.recommendedVariant), 'EUR' |
|
67
|
|
|
) |
|
68
|
|
|
} |
|
69
|
|
|
); |
|
70
|
|
|
}, |
|
71
|
|
|
|
|
72
|
|
|
isInstalled() { |
|
73
|
|
|
return !!Shopware.State.get('shopwareExtensions').installedExtensions.data.find((installedExtension) => { |
|
|
|
|
|
|
74
|
|
|
return installedExtension.name === this.extension.name; |
|
75
|
|
|
}); |
|
76
|
|
|
}, |
|
77
|
|
|
|
|
78
|
|
|
isLicensed() { |
|
79
|
|
|
return !!Shopware.State.get('shopwareExtensions').licensedExtensions.data.find((license) => { |
|
|
|
|
|
|
80
|
|
|
return license.licensedExtension.name === this.extension.name; |
|
81
|
|
|
}); |
|
82
|
|
|
}, |
|
83
|
|
|
|
|
84
|
|
|
assetFilter() { |
|
85
|
|
|
return Filter.getByName('asset'); |
|
86
|
|
|
} |
|
87
|
|
|
}, |
|
88
|
|
|
|
|
89
|
|
|
methods: { |
|
90
|
|
|
openDetailPage() { |
|
91
|
|
|
this.$router.push({ |
|
92
|
|
|
name: 'sw.extension.store.detail', |
|
93
|
|
|
params: { id: this.extension.id.toString() } |
|
94
|
|
|
}); |
|
95
|
|
|
} |
|
96
|
|
|
} |
|
97
|
|
|
}); |
|
98
|
|
|
|
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.