1
|
|
|
import template from './sw-event-action-list.html.twig'; |
2
|
|
|
import './sw-event-action-list.scss'; |
3
|
|
|
|
4
|
|
|
const snakeCase = Shopware.Utils.string.snakeCase; |
|
|
|
|
5
|
|
|
const { Component, Mixin, Data: { Criteria } } = Shopware; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* @internal (flag:FEATURE_NEXT_9351) |
9
|
|
|
*/ |
10
|
|
|
Component.register('sw-event-action-list', { |
11
|
|
|
template, |
12
|
|
|
|
13
|
|
|
inject: [ |
14
|
|
|
'repositoryFactory', |
15
|
|
|
'acl' |
16
|
|
|
], |
17
|
|
|
|
18
|
|
|
mixins: [ |
19
|
|
|
Mixin.getByName('listing') |
20
|
|
|
], |
21
|
|
|
|
22
|
|
|
metaInfo() { |
23
|
|
|
return { |
24
|
|
|
title: this.$createTitle() |
25
|
|
|
}; |
26
|
|
|
}, |
27
|
|
|
|
28
|
|
|
data() { |
29
|
|
|
return { |
30
|
|
|
items: null, |
31
|
|
|
sortBy: 'eventName', |
32
|
|
|
sortDirection: 'ASC', |
33
|
|
|
isLoading: false, |
34
|
|
|
mailTemplates: null, |
35
|
|
|
total: 0 |
36
|
|
|
}; |
37
|
|
|
}, |
38
|
|
|
|
39
|
|
|
computed: { |
40
|
|
|
mailTemplateRepository() { |
41
|
|
|
return this.repositoryFactory.create('mail_template'); |
42
|
|
|
}, |
43
|
|
|
|
44
|
|
|
eventActionRepository() { |
45
|
|
|
return this.repositoryFactory.create('event_action'); |
46
|
|
|
}, |
47
|
|
|
|
48
|
|
|
mailTemplateCriteria() { |
49
|
|
|
const criteria = new Criteria(); |
|
|
|
|
50
|
|
|
criteria.addAssociation('mailTemplateType'); |
51
|
|
|
|
52
|
|
|
return criteria; |
53
|
|
|
}, |
54
|
|
|
|
55
|
|
|
eventActionCriteria() { |
56
|
|
|
const criteria = new Criteria(); |
|
|
|
|
57
|
|
|
|
58
|
|
|
criteria.setTerm(null); |
59
|
|
|
if (this.term) { |
60
|
|
|
// php implementation splits the term by each dot, so we do a custom search |
61
|
|
|
const terms = this.term.split(' '); |
62
|
|
|
const fields = ['eventName', 'actionName', 'rules.name']; |
63
|
|
|
|
64
|
|
|
fields.forEach((field) => { |
65
|
|
|
terms.forEach((term) => { |
66
|
|
|
if (term.length > 1) { |
67
|
|
|
criteria.addQuery(Criteria.contains(field, term), 500); |
|
|
|
|
68
|
|
|
} |
69
|
|
|
}); |
70
|
|
|
}); |
71
|
|
|
} |
72
|
|
|
criteria.addAssociation('salesChannels'); |
73
|
|
|
criteria.addAssociation('rules'); |
74
|
|
|
criteria.addSorting(Criteria.sort(this.sortBy, this.sortDirection)); |
75
|
|
|
criteria.addFilter(Criteria.equals('actionName', 'action.mail.send')); |
76
|
|
|
criteria.addFilter(Criteria.not('and', [ |
77
|
|
|
Criteria.equals('config.mail_template_id', null) |
78
|
|
|
])); |
79
|
|
|
|
80
|
|
|
return criteria; |
81
|
|
|
}, |
82
|
|
|
|
83
|
|
|
eventActionColumns() { |
84
|
|
|
return [{ |
85
|
|
|
property: 'eventName', |
86
|
|
|
dataIndex: 'eventName', |
87
|
|
|
label: 'sw-event-action.list.columnEventName', |
88
|
|
|
routerLink: 'sw.event.action.detail', |
89
|
|
|
multiLine: true, |
90
|
|
|
allowResize: true, |
91
|
|
|
primary: true |
92
|
|
|
}, { |
93
|
|
|
property: 'title', |
94
|
|
|
dataIndex: 'title', |
95
|
|
|
label: 'sw-event-action.list.columnTitle', |
96
|
|
|
routerLink: 'sw.event.action.detail', |
97
|
|
|
multiLine: true, |
98
|
|
|
allowResize: true |
99
|
|
|
}, { |
100
|
|
|
property: 'salesChannels', |
101
|
|
|
dataIndex: 'salesChannels', |
102
|
|
|
label: 'sw-event-action.list.columnSalesChannel', |
103
|
|
|
sortable: false, |
104
|
|
|
allowResize: true, |
105
|
|
|
multiLine: true |
106
|
|
|
}, { |
107
|
|
|
property: 'rules', |
108
|
|
|
dataIndex: 'rules', |
109
|
|
|
label: 'sw-event-action.list.columnRules', |
110
|
|
|
sortable: false, |
111
|
|
|
allowResize: true, |
112
|
|
|
multiLine: true |
113
|
|
|
}, { |
114
|
|
|
property: 'mailTemplate', |
115
|
|
|
label: 'sw-event-action.list.columnMailTemplate', |
116
|
|
|
multiLine: true, |
117
|
|
|
sortable: false |
118
|
|
|
}, { |
119
|
|
|
property: 'active', |
120
|
|
|
dataIndex: 'active', |
121
|
|
|
label: 'sw-event-action.list.columnActive', |
122
|
|
|
align: 'center', |
123
|
|
|
allowResize: true |
124
|
|
|
}]; |
125
|
|
|
} |
126
|
|
|
}, |
127
|
|
|
|
128
|
|
|
methods: { |
129
|
|
|
getList() { |
130
|
|
|
this.isLoading = true; |
131
|
|
|
|
132
|
|
|
return this.eventActionRepository |
133
|
|
|
.search(this.eventActionCriteria, Shopware.Context.api) |
|
|
|
|
134
|
|
|
.then((response) => { |
135
|
|
|
this.items = response; |
136
|
|
|
this.total = response.total; |
137
|
|
|
this.isLoading = false; |
138
|
|
|
}); |
139
|
|
|
}, |
140
|
|
|
|
141
|
|
|
fetchMailTemplates(eventActions) { |
142
|
|
|
this.isLoading = true; |
143
|
|
|
|
144
|
|
|
const mailTemplateIds = eventActions.map((item) => { |
145
|
|
|
return item.config.mail_template_id; |
146
|
|
|
}); |
147
|
|
|
|
148
|
|
|
this.mailTemplateCriteria.setIds(mailTemplateIds); |
149
|
|
|
|
150
|
|
|
return this.mailTemplateRepository |
151
|
|
|
.search(this.mailTemplateCriteria, Shopware.Context.api) |
|
|
|
|
152
|
|
|
.then((mailTemplates) => { |
153
|
|
|
this.mailTemplates = mailTemplates; |
154
|
|
|
this.isLoading = false; |
155
|
|
|
}); |
156
|
|
|
}, |
157
|
|
|
|
158
|
|
|
renderMailTemplate(eventAction) { |
159
|
|
|
const id = eventAction.config.mail_template_id; |
160
|
|
|
|
161
|
|
|
const mailTemplate = this.mailTemplates.find((item) => { |
162
|
|
|
return item.id === id; |
163
|
|
|
}); |
164
|
|
|
|
165
|
|
|
if (!mailTemplate) { |
166
|
|
|
return ''; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
return mailTemplate; |
170
|
|
|
}, |
171
|
|
|
|
172
|
|
|
snakeCaseEventName(value) { |
173
|
|
|
return snakeCase(value); |
174
|
|
|
} |
175
|
|
|
} |
176
|
|
|
}); |
177
|
|
|
|
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.