Passed
Push — master ( 0c064b...50f875 )
by Christian
15:00 queued 10s
created

src/Administration/Resources/app/administration/src/module/sw-extension/page/sw-extension-store-listing/index.js   A

Complexity

Total Complexity 24
Complexity/F 1.33

Size

Lines of Code 122
Function Count 18

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 24
eloc 66
mnd 6
bc 6
fnc 18
dl 0
loc 122
rs 10
bpm 0.3333
cpm 1.3333
noi 9
c 0
b 0
f 0
1
import template from './sw-extension-store-listing.html.twig';
2
import './sw-extension-store-listing.scss';
3
4
const { Component } = Shopware;
0 ignored issues
show
Bug introduced by
The variable Shopware seems to be never declared. If this is a global, consider adding a /** global: Shopware */ comment.

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.

Loading history...
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;
0 ignored issues
show
Bug introduced by
The variable Shopware seems to be never declared. If this is a global, consider adding a /** global: Shopware */ comment.

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.

Loading history...
26
        },
27
28
        currentSearch() {
29
            return Shopware.State.get('shopwareExtensions').search;
0 ignored issues
show
Bug introduced by
The variable Shopware seems to be never declared. If this is a global, consider adding a /** global: Shopware */ comment.

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.

Loading history...
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;
0 ignored issues
show
Bug introduced by
The variable Shopware seems to be never declared. If this is a global, consider adding a /** global: Shopware */ comment.

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.

Loading history...
54
        },
55
56
        assetFilter() {
57
            return Shopware.Filter.getByName('asset');
0 ignored issues
show
Bug introduced by
The variable Shopware seems to be never declared. If this is a global, consider adding a /** global: Shopware */ comment.

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.

Loading history...
58
        },
59
60
        currentLocale() {
61
            return Shopware.State.get('session').currentLocale === 'de-DE' ? 'de' : 'en';
0 ignored issues
show
Bug introduced by
The variable Shopware seems to be never declared. If this is a global, consider adding a /** global: Shopware */ comment.

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.

Loading history...
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');
0 ignored issues
show
Bug introduced by
The variable Shopware seems to be never declared. If this is a global, consider adding a /** global: Shopware */ comment.

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.

Loading history...
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 });
0 ignored issues
show
Bug introduced by
The variable Shopware seems to be never declared. If this is a global, consider adding a /** global: Shopware */ comment.

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.

Loading history...
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');
0 ignored issues
show
Bug introduced by
The variable Shopware seems to be never declared. If this is a global, consider adding a /** global: Shopware */ comment.

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.

Loading history...
117
            } catch (e) {
118
                this.showExtensionErrors(e);
119
            }
120
        }
121
    }
122
});
123