Total Complexity | 10 |
Complexity/F | 1.11 |
Lines of Code | 66 |
Function Count | 9 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import template from './sw-app-actions.html.twig'; |
||
2 | import './sw-app-actions.scss'; |
||
3 | |||
4 | const { Component, Utils } = Shopware; |
||
|
|||
5 | |||
6 | Component.register('sw-app-actions', { |
||
7 | template, |
||
8 | |||
9 | inject: ['feature', 'appActionButtonService'], |
||
10 | |||
11 | data() { |
||
12 | return { |
||
13 | actions: [], |
||
14 | matchedRoutes: [] |
||
15 | }; |
||
16 | }, |
||
17 | |||
18 | computed: { |
||
19 | entity() { |
||
20 | return Utils.get(this.$route, 'meta.$module.entity'); |
||
21 | }, |
||
22 | |||
23 | view() { |
||
24 | const matchedRoute = this.matchedRoutes.filter((match) => { |
||
25 | return !!Utils.get(match, 'meta.appSystem.view'); |
||
26 | }).pop(); |
||
27 | |||
28 | return Utils.get(matchedRoute, 'meta.appSystem.view'); |
||
29 | }, |
||
30 | |||
31 | areActionsAvailable() { |
||
32 | return this.feature.isActive('FEATURE_NEXT_10286') |
||
33 | && !!this.actions |
||
34 | && this.actions.length > 0 |
||
35 | && this.params.length > 0; |
||
36 | }, |
||
37 | |||
38 | params() { |
||
39 | return Shopware.State.get('shopwareApps').selectedIds; |
||
40 | } |
||
41 | }, |
||
42 | |||
43 | watch: { |
||
44 | $route: { |
||
45 | immediate: true, |
||
46 | handler() { |
||
47 | this.matchedRoutes = this.$router.currentRoute.matched; |
||
48 | this.loadActions(); |
||
49 | } |
||
50 | } |
||
51 | }, |
||
52 | |||
53 | methods: { |
||
54 | runAction(actionId) { |
||
55 | this.appActionButtonService.runAction(actionId, { ids: this.params }); |
||
56 | }, |
||
57 | |||
58 | async loadActions() { |
||
59 | try { |
||
60 | this.actions = await this.appActionButtonService.getActionButtonsPerView(this.entity, this.view); |
||
61 | } catch (e) { |
||
62 | this.actions = []; |
||
63 | } |
||
64 | } |
||
65 | } |
||
66 | }); |
||
67 |
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.