1 | import template from './sw-app-actions.html.twig'; |
||
2 | import './sw-app-actions.scss'; |
||
3 | |||
4 | const { Component, Mixin, Utils } = Shopware; |
||
0 ignored issues
–
show
|
|||
5 | |||
6 | Component.register('sw-app-actions', { |
||
7 | template, |
||
8 | |||
9 | inject: ['feature', 'appActionButtonService'], |
||
10 | |||
11 | mixins: [Mixin.getByName('notification')], |
||
12 | |||
13 | data() { |
||
14 | return { |
||
15 | actions: [], |
||
16 | matchedRoutes: [] |
||
17 | }; |
||
18 | }, |
||
19 | |||
20 | computed: { |
||
21 | entity() { |
||
22 | return Utils.get(this.$route, 'meta.$module.entity'); |
||
23 | }, |
||
24 | |||
25 | view() { |
||
26 | const matchedRoute = this.matchedRoutes.filter((match) => { |
||
27 | return !!Utils.get(match, 'meta.appSystem.view'); |
||
28 | }).pop(); |
||
29 | |||
30 | return Utils.get(matchedRoute, 'meta.appSystem.view'); |
||
31 | }, |
||
32 | |||
33 | areActionsAvailable() { |
||
34 | return !!this.actions |
||
35 | && this.actions.length > 0 |
||
36 | && this.params.length > 0; |
||
37 | }, |
||
38 | |||
39 | params() { |
||
40 | return Shopware.State.get('shopwareApps').selectedIds; |
||
0 ignored issues
–
show
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...
|
|||
41 | } |
||
42 | }, |
||
43 | |||
44 | watch: { |
||
45 | $route: { |
||
46 | immediate: true, |
||
47 | handler() { |
||
48 | this.matchedRoutes = this.$router.currentRoute.matched; |
||
49 | this.loadActions(); |
||
50 | } |
||
51 | } |
||
52 | }, |
||
53 | |||
54 | methods: { |
||
55 | runAction(actionId) { |
||
56 | this.appActionButtonService.runAction(actionId, { ids: this.params }); |
||
57 | }, |
||
58 | |||
59 | async loadActions() { |
||
60 | try { |
||
61 | this.actions = await this.appActionButtonService.getActionButtonsPerView(this.entity, this.view); |
||
62 | } catch (e) { |
||
63 | this.actions = []; |
||
64 | |||
65 | // ignore missing parameter exception for pages without correct view |
||
66 | if (!!e.name && e.name === 'InvalidActionButtonParameterError') { |
||
67 | return; |
||
68 | } |
||
69 | |||
70 | this.createNotificationError({ |
||
71 | message: this.$tc('sw-app.component.sw-app-actions.messageErrorFetchButtons') |
||
72 | }); |
||
73 | } |
||
74 | } |
||
75 | } |
||
76 | }); |
||
77 |
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.