1
|
|
|
import template from './sw-extension-store-listing.html.twig'; |
2
|
|
|
import './sw-extension-store-listing.scss'; |
3
|
|
|
|
4
|
|
|
const { Component } = Shopware; |
|
|
|
|
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* @private |
8
|
|
|
*/ |
9
|
|
|
Component.register('sw-extension-store-listing', { |
10
|
|
|
name: 'sw-extension-store-listing', |
11
|
|
|
template, |
12
|
|
|
|
13
|
|
|
inject: ['feature'], |
14
|
|
|
|
15
|
|
|
mixins: ['sw-extension-error'], |
16
|
|
|
|
17
|
|
|
data() { |
18
|
|
|
return { |
19
|
|
|
isLoading: false |
20
|
|
|
}; |
21
|
|
|
}, |
22
|
|
|
|
23
|
|
|
computed: { |
24
|
|
|
extensions() { |
25
|
|
|
return Shopware.State.get('shopwareExtensions').extensionListing; |
|
|
|
|
26
|
|
|
}, |
27
|
|
|
|
28
|
|
|
currentSearch() { |
29
|
|
|
return Shopware.State.get('shopwareExtensions').search; |
|
|
|
|
30
|
|
|
}, |
31
|
|
|
|
32
|
|
|
page() { |
33
|
|
|
return this.currentSearch.page; |
34
|
|
|
}, |
35
|
|
|
|
36
|
|
|
limit() { |
37
|
|
|
return this.currentSearch.limit; |
38
|
|
|
}, |
39
|
|
|
|
40
|
|
|
total() { |
41
|
|
|
return this.extensions.total || 0; |
42
|
|
|
}, |
43
|
|
|
|
44
|
|
|
category() { |
45
|
|
|
return this.currentSearch.category; |
46
|
|
|
}, |
47
|
|
|
|
48
|
|
|
rating() { |
49
|
|
|
return this.currentSearch.rating; |
50
|
|
|
}, |
51
|
|
|
|
52
|
|
|
languageId() { |
53
|
|
|
return Shopware.State.get('session').languageId; |
|
|
|
|
54
|
|
|
}, |
55
|
|
|
|
56
|
|
|
assetFilter() { |
57
|
|
|
return Shopware.Filter.getByName('asset'); |
|
|
|
|
58
|
|
|
}, |
59
|
|
|
|
60
|
|
|
currentLocale() { |
61
|
|
|
return Shopware.State.get('session').currentLocale === 'de-DE' ? 'de' : 'en'; |
|
|
|
|
62
|
|
|
} |
63
|
|
|
}, |
64
|
|
|
|
65
|
|
|
watch: { |
66
|
|
|
currentSearch: { |
67
|
|
|
deep: true, |
68
|
|
|
handler() { |
69
|
|
|
this.getList(); |
70
|
|
|
} |
71
|
|
|
}, |
72
|
|
|
languageId(newValue) { |
73
|
|
|
if (newValue !== '') { |
74
|
|
|
this.getStoreCategories(); |
75
|
|
|
this.getList(); |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
}, |
79
|
|
|
|
80
|
|
|
created() { |
81
|
|
|
this.createdComponent(); |
82
|
|
|
}, |
83
|
|
|
|
84
|
|
|
methods: { |
85
|
|
|
createdComponent() { |
86
|
|
|
this.getStoreCategories(); |
87
|
|
|
}, |
88
|
|
|
|
89
|
|
|
async getList() { |
90
|
|
|
this.isLoading = true; |
91
|
|
|
|
92
|
|
|
if (this.languageId === '') { |
93
|
|
|
return; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
try { |
97
|
|
|
await Shopware.State.dispatch('shopwareExtensions/search'); |
|
|
|
|
98
|
|
|
} catch (e) { |
99
|
|
|
this.showExtensionErrors(e); |
100
|
|
|
} finally { |
101
|
|
|
this.isLoading = false; |
102
|
|
|
} |
103
|
|
|
}, |
104
|
|
|
|
105
|
|
|
setPage({ limit, page }) { |
106
|
|
|
Shopware.State.commit('shopwareExtensions/setSearchValue', { key: 'limit', value: limit }); |
|
|
|
|
107
|
|
|
Shopware.State.commit('shopwareExtensions/setSearchValue', { key: 'page', value: page }); |
108
|
|
|
}, |
109
|
|
|
|
110
|
|
|
async getStoreCategories() { |
111
|
|
|
if (this.languageId === '') { |
112
|
|
|
return; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
try { |
116
|
|
|
await Shopware.State.dispatch('shopwareExtensions/getStoreCategories'); |
|
|
|
|
117
|
|
|
} catch (e) { |
118
|
|
|
this.showExtensionErrors(e); |
119
|
|
|
} |
120
|
|
|
} |
121
|
|
|
} |
122
|
|
|
}); |
123
|
|
|
|
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.