|
1
|
|
|
import type EntityCollection from '@shopware-ag/admin-extension-sdk/es/data/_internals/EntityCollection'; |
|
2
|
|
|
import type { Entity } from '@shopware-ag/admin-extension-sdk/es/data/_internals/Entity'; |
|
3
|
|
|
import type { MetaInfo } from 'vue-meta'; |
|
4
|
|
|
import type Repository from '../../../../../core/data/repository.data'; |
|
5
|
|
|
import type CriteriaType from '../../../../../core/data/criteria.data'; |
|
6
|
|
|
import template from './sw-flow-list-flow-templates.html.twig'; |
|
7
|
|
|
import './sw-flow-list-flow-templates.scss'; |
|
8
|
|
|
|
|
9
|
|
|
interface GridColumn { |
|
10
|
|
|
property: string, |
|
11
|
|
|
dataIndex?: string, |
|
12
|
|
|
label: string, |
|
13
|
|
|
allowResize?: boolean, |
|
14
|
|
|
sortable?: boolean, |
|
15
|
|
|
} |
|
16
|
|
|
|
|
17
|
|
|
const { Mixin, Data: { Criteria } } = Shopware; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @private |
|
21
|
|
|
* @package business-ops |
|
22
|
|
|
*/ |
|
23
|
|
|
// eslint-disable-next-line sw-deprecation-rules/private-feature-declarations |
|
24
|
|
|
export default Shopware.Component.wrapComponentConfig({ |
|
25
|
|
|
template, |
|
26
|
|
|
|
|
27
|
|
|
inject: ['acl', 'repositoryFactory'], |
|
28
|
|
|
|
|
29
|
|
|
mixins: [ |
|
30
|
|
|
Mixin.getByName('listing'), |
|
31
|
|
|
], |
|
32
|
|
|
|
|
33
|
|
|
props: { |
|
34
|
|
|
searchTerm: { |
|
35
|
|
|
type: String, |
|
36
|
|
|
required: false, |
|
37
|
|
|
default: '', |
|
38
|
|
|
}, |
|
39
|
|
|
}, |
|
40
|
|
|
|
|
41
|
|
|
data(): { |
|
42
|
|
|
sortBy: string, |
|
43
|
|
|
sortDirection: string, |
|
44
|
|
|
total: number, |
|
45
|
|
|
isLoading: boolean, |
|
46
|
|
|
flowTemplates: EntityCollection<'flow_template'>|[], |
|
47
|
|
|
} { |
|
48
|
|
|
return { |
|
49
|
|
|
sortBy: 'createdAt', |
|
50
|
|
|
sortDirection: 'DESC', |
|
51
|
|
|
total: 0, |
|
52
|
|
|
isLoading: false, |
|
53
|
|
|
flowTemplates: [], |
|
54
|
|
|
}; |
|
55
|
|
|
}, |
|
56
|
|
|
|
|
57
|
|
|
metaInfo(): MetaInfo { |
|
58
|
|
|
return { |
|
59
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call |
|
60
|
|
|
title: this.$createTitle(), |
|
61
|
|
|
}; |
|
62
|
|
|
}, |
|
63
|
|
|
|
|
64
|
|
|
computed: { |
|
65
|
|
|
flowTemplateRepository(): Repository<'flow_template'> { |
|
66
|
|
|
return this.repositoryFactory.create('flow_template'); |
|
67
|
|
|
}, |
|
68
|
|
|
|
|
69
|
|
|
flowTemplateCriteria(): CriteriaType { |
|
70
|
|
|
const criteria = new Criteria(1, 25); |
|
71
|
|
|
|
|
72
|
|
|
if (this.searchTerm) { |
|
73
|
|
|
criteria.setTerm(this.searchTerm); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
// @ts-expect-error - Mixin methods are not recognized |
|
77
|
|
|
criteria.addSorting(Criteria.sort(this.sortBy, this.sortDirection)) |
|
78
|
|
|
.addSorting(Criteria.sort('updatedAt', 'DESC')); |
|
79
|
|
|
|
|
80
|
|
|
return criteria; |
|
81
|
|
|
}, |
|
82
|
|
|
|
|
83
|
|
|
flowTemplateColumns(): GridColumn[] { |
|
84
|
|
|
return [ |
|
85
|
|
|
{ |
|
86
|
|
|
property: 'name', |
|
87
|
|
|
dataIndex: 'name', |
|
88
|
|
|
label: this.$tc('sw-flow.list.labelColumnName'), |
|
89
|
|
|
allowResize: false, |
|
90
|
|
|
}, |
|
91
|
|
|
{ |
|
92
|
|
|
property: 'config.description', |
|
93
|
|
|
label: this.$tc('sw-flow.list.labelColumnDescription'), |
|
94
|
|
|
allowResize: false, |
|
95
|
|
|
sortable: false, |
|
96
|
|
|
}, |
|
97
|
|
|
{ |
|
98
|
|
|
property: 'createFlow', |
|
99
|
|
|
label: '', |
|
100
|
|
|
allowResize: false, |
|
101
|
|
|
sortable: false, |
|
102
|
|
|
}, |
|
103
|
|
|
]; |
|
104
|
|
|
}, |
|
105
|
|
|
}, |
|
106
|
|
|
|
|
107
|
|
|
watch: { |
|
108
|
|
|
searchTerm: { |
|
109
|
|
|
immediate: true, |
|
110
|
|
|
handler(value): void { |
|
111
|
|
|
// @ts-expect-error - Mixin methods are not recognized |
|
112
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call |
|
113
|
|
|
this.onSearch(value); |
|
114
|
|
|
}, |
|
115
|
|
|
}, |
|
116
|
|
|
}, |
|
117
|
|
|
|
|
118
|
|
|
created(): void { |
|
119
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call |
|
120
|
|
|
this.createComponent(); |
|
121
|
|
|
}, |
|
122
|
|
|
|
|
123
|
|
|
methods: { |
|
124
|
|
|
createComponent(): void { |
|
125
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call |
|
126
|
|
|
this.getList(); |
|
127
|
|
|
}, |
|
128
|
|
|
|
|
129
|
|
|
getList(): void { |
|
130
|
|
|
this.isLoading = true; |
|
131
|
|
|
|
|
132
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access |
|
133
|
|
|
this.flowTemplateRepository.search(this.flowTemplateCriteria) |
|
134
|
|
|
.then((data: EntityCollection<'flow_template'>) => { |
|
135
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access |
|
136
|
|
|
this.total = data.total as number; |
|
137
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment |
|
138
|
|
|
this.flowTemplates = data; |
|
139
|
|
|
}) |
|
140
|
|
|
.finally(() => { |
|
141
|
|
|
this.isLoading = false; |
|
142
|
|
|
}); |
|
143
|
|
|
}, |
|
144
|
|
|
|
|
145
|
|
|
createFlowFromTemplate(item: Entity<'flow_template'>): void { |
|
146
|
|
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises,@typescript-eslint/no-unsafe-assignment |
|
147
|
|
|
this.$router.push({ name: 'sw.flow.create', params: { flowTemplateId: item.id } }); |
|
148
|
|
|
}, |
|
149
|
|
|
|
|
150
|
|
|
onEditFlow(item: Entity<'flow_template'>): void { |
|
151
|
|
|
if (!item?.id) { |
|
152
|
|
|
return; |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises |
|
156
|
|
|
this.$router.push({ |
|
157
|
|
|
name: 'sw.flow.detail', |
|
158
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment |
|
159
|
|
|
params: { id: item.id }, |
|
160
|
|
|
query: { type: 'template' }, |
|
161
|
|
|
}); |
|
162
|
|
|
}, |
|
163
|
|
|
}, |
|
164
|
|
|
}); |
|
165
|
|
|
|