Total Complexity | 10 |
Complexity/F | 1 |
Lines of Code | 102 |
Function Count | 10 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import template from './sw-promotion-v2-list.html.twig'; |
||
2 | import './sw-promotion-v2-list.scss'; |
||
3 | |||
4 | const { Component } = Shopware; |
||
|
|||
5 | const { Criteria } = Shopware.Data; |
||
6 | |||
7 | Component.register('sw-promotion-v2-list', { |
||
8 | template, |
||
9 | |||
10 | inject: [ |
||
11 | 'repositoryFactory', |
||
12 | 'acl' |
||
13 | ], |
||
14 | |||
15 | mixins: [ |
||
16 | 'listing' |
||
17 | ], |
||
18 | |||
19 | data() { |
||
20 | return { |
||
21 | isLoading: true, |
||
22 | promotions: null, |
||
23 | total: 0, |
||
24 | showDeleteModal: false, |
||
25 | sortBy: 'createdAt', |
||
26 | sortDirection: 'DESC' |
||
27 | }; |
||
28 | }, |
||
29 | |||
30 | metaInfo() { |
||
31 | return { |
||
32 | title: this.$createTitle() |
||
33 | }; |
||
34 | }, |
||
35 | |||
36 | computed: { |
||
37 | promotionRepository() { |
||
38 | return this.repositoryFactory.create('promotion'); |
||
39 | }, |
||
40 | |||
41 | promotionCriteria() { |
||
42 | return (new Criteria(this.page, this.limit)) |
||
43 | .setTerm(this.term) |
||
44 | .addSorting(Criteria.sort(this.sortBy, this.sortDirection)); |
||
45 | }, |
||
46 | |||
47 | promotionColumns() { |
||
48 | return this.getPromotionColumns(); |
||
49 | } |
||
50 | }, |
||
51 | |||
52 | methods: { |
||
53 | getList() { |
||
54 | this.isLoading = true; |
||
55 | |||
56 | return this.promotionRepository.search(this.promotionCriteria, Shopware.Context.api).then((searchResult) => { |
||
57 | this.isLoading = false; |
||
58 | this.total = searchResult.total; |
||
59 | this.promotions = searchResult; |
||
60 | |||
61 | return this.promotions; |
||
62 | }); |
||
63 | }, |
||
64 | |||
65 | onChangeLanguage() { |
||
66 | this.getList(); |
||
67 | }, |
||
68 | |||
69 | getPromotionColumns() { |
||
70 | return [{ |
||
71 | property: 'name', |
||
72 | label: 'sw-promotion-v2.list.columnName', |
||
73 | routerLink: 'sw.promotion.v2.detail', |
||
74 | inlineEdit: 'string', |
||
75 | allowResize: true, |
||
76 | primary: true |
||
77 | }, { |
||
78 | property: 'active', |
||
79 | label: 'sw-promotion-v2.list.columnActive', |
||
80 | inlineEdit: 'boolean', |
||
81 | allowResize: true, |
||
82 | align: 'center' |
||
83 | }, { |
||
84 | property: 'validFrom', |
||
85 | label: 'sw-promotion-v2.list.columnValidFrom', |
||
86 | inlineEdit: 'date', |
||
87 | allowResize: true, |
||
88 | align: 'center' |
||
89 | }, { |
||
90 | property: 'validUntil', |
||
91 | label: 'sw-promotion-v2.list.columnValidUntil', |
||
92 | inlineEdit: 'date', |
||
93 | allowResize: true, |
||
94 | align: 'center' |
||
95 | }]; |
||
96 | }, |
||
97 | |||
98 | updateTotal({ total }) { |
||
99 | this.total = total; |
||
100 | } |
||
101 | } |
||
102 | }); |
||
103 |
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.