@afeefa/vue-app 0.0.85 → 0.0.86
Sign up to get free protection for your applications and to get access to all the features.
- package/.afeefa/package/release/version.txt +1 -1
- package/package.json +1 -1
- package/src/api-resources/ApiActions.js +13 -309
- package/src/api-resources/DeleteAction.js +5 -1
- package/src/components/form/FormFieldMixin.js +2 -3
- package/src/components/list/ListViewMixin.js +3 -3
- package/src/components/list/filters/ListFilterSelect.vue +2 -3
- package/src/api-resources/ApiActions2.js +0 -14
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.86
|
package/package.json
CHANGED
@@ -1,310 +1,14 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
}
|
15
|
-
|
16
|
-
setId (id) {
|
17
|
-
this.id = id
|
18
|
-
return this
|
19
|
-
}
|
20
|
-
|
21
|
-
setFields (fields) {
|
22
|
-
this.fields = fields
|
23
|
-
return this
|
24
|
-
}
|
25
|
-
|
26
|
-
noEvents (noEvents) {
|
27
|
-
this.events = noEvents === undefined ? false : !noEvents
|
28
|
-
return this
|
29
|
-
}
|
30
|
-
|
31
|
-
async load () {
|
32
|
-
if (this.events) {
|
33
|
-
eventBus.dispatch(new LoadingEvent(LoadingEvent.START_LOADING))
|
34
|
-
}
|
35
|
-
|
36
|
-
const result = await this.action.createRequest()
|
37
|
-
.params({
|
38
|
-
id: this.id
|
39
|
-
})
|
40
|
-
.fields(this.fields)
|
41
|
-
.send()
|
42
|
-
|
43
|
-
if (this.events) {
|
44
|
-
eventBus.dispatch(new LoadingEvent(LoadingEvent.STOP_LOADING))
|
45
|
-
}
|
46
|
-
|
47
|
-
if (result.error) {
|
48
|
-
eventBus.dispatch(new AlertEvent(AlertEvent.ERROR, {
|
49
|
-
headline: 'Die Daten konntent nicht geladen werden.',
|
50
|
-
message: result.message,
|
51
|
-
detail: result.detail
|
52
|
-
}))
|
53
|
-
}
|
54
|
-
|
55
|
-
return result.data || false
|
56
|
-
}
|
57
|
-
}
|
58
|
-
|
59
|
-
export class SaveAction {
|
60
|
-
action = null
|
61
|
-
id = null
|
62
|
-
fields = null
|
63
|
-
data = null
|
64
|
-
afterSaveHook = null
|
65
|
-
returnAfterSaveHookResult = false
|
66
|
-
dialog = null
|
67
|
-
|
68
|
-
setAction (action) {
|
69
|
-
this.action = action
|
70
|
-
return this
|
71
|
-
}
|
72
|
-
|
73
|
-
setId (id) {
|
74
|
-
this.id = id
|
75
|
-
return this
|
76
|
-
}
|
77
|
-
|
78
|
-
setFields (fields) {
|
79
|
-
this.fields = fields
|
80
|
-
return this
|
81
|
-
}
|
82
|
-
|
83
|
-
setData (data) {
|
84
|
-
this.data = data
|
85
|
-
return this
|
86
|
-
}
|
87
|
-
|
88
|
-
setAfterSaveHook (afterSaveHook, returnAfterSaveHookResult = false) {
|
89
|
-
this.afterSaveHook = afterSaveHook
|
90
|
-
this.returnAfterSaveHookResult = returnAfterSaveHookResult
|
91
|
-
return this
|
92
|
-
}
|
93
|
-
|
94
|
-
setDialog (dialog) {
|
95
|
-
this.dialog = dialog
|
96
|
-
return this
|
97
|
-
}
|
98
|
-
|
99
|
-
async save () {
|
100
|
-
if (this.dialog) {
|
101
|
-
const result = await eventBus.dispatch(new DialogEvent(DialogEvent.SHOW, this.dialog))
|
102
|
-
|
103
|
-
if (result !== DialogEvent.RESULT_YES) {
|
104
|
-
return null
|
105
|
-
}
|
106
|
-
}
|
107
|
-
|
108
|
-
eventBus.dispatch(new SaveEvent(SaveEvent.START_SAVING))
|
109
|
-
|
110
|
-
const startTime = Date.now()
|
111
|
-
|
112
|
-
const result = await this.action.createRequest()
|
113
|
-
.params({
|
114
|
-
id: this.id || undefined
|
115
|
-
})
|
116
|
-
.fields(this.fields)
|
117
|
-
.data(this.data)
|
118
|
-
.send()
|
119
|
-
|
120
|
-
const model = result.data
|
121
|
-
|
122
|
-
let afterSaveHookResult = null
|
123
|
-
|
124
|
-
if (!result.error) {
|
125
|
-
if (this.afterSaveHook) {
|
126
|
-
afterSaveHookResult = await this.afterSaveHook(model)
|
127
|
-
}
|
128
|
-
}
|
129
|
-
|
130
|
-
const diffTime = Date.now() - startTime
|
131
|
-
const restTime = Math.max(0, 400 - diffTime)
|
132
|
-
if (restTime) {
|
133
|
-
await sleep(restTime / 1000)
|
134
|
-
}
|
135
|
-
|
136
|
-
eventBus.dispatch(new SaveEvent(SaveEvent.STOP_SAVING))
|
137
|
-
|
138
|
-
if (result.error) {
|
139
|
-
eventBus.dispatch(new SaveEvent(SaveEvent.STOP_SAVING))
|
140
|
-
|
141
|
-
eventBus.dispatch(new AlertEvent(AlertEvent.ERROR, {
|
142
|
-
headline: 'Die Daten wurden nicht gespeichert',
|
143
|
-
message: result.message,
|
144
|
-
detail: result.detail
|
145
|
-
}))
|
146
|
-
return null
|
147
|
-
}
|
148
|
-
|
149
|
-
eventBus.dispatch(new AlertEvent(AlertEvent.MESSAGE, {
|
150
|
-
message: 'Die Daten wurden gespeichert.'
|
151
|
-
}))
|
152
|
-
|
153
|
-
if (this.returnAfterSaveHookResult) {
|
154
|
-
return afterSaveHookResult
|
155
|
-
}
|
156
|
-
|
157
|
-
return model
|
158
|
-
}
|
159
|
-
}
|
160
|
-
|
161
|
-
export class RemoveAction {
|
162
|
-
action = null
|
163
|
-
id = null
|
164
|
-
fields = null
|
165
|
-
afterRemoveHook = null
|
166
|
-
dialog = null
|
167
|
-
|
168
|
-
setAction (action) {
|
169
|
-
this.action = action
|
170
|
-
return this
|
171
|
-
}
|
172
|
-
|
173
|
-
setId (id) {
|
174
|
-
this.id = id
|
175
|
-
return this
|
176
|
-
}
|
177
|
-
|
178
|
-
setAfterRemoveHook (afterRemoveHook) {
|
179
|
-
this.afterRemoveHook = afterRemoveHook
|
180
|
-
return this
|
181
|
-
}
|
182
|
-
|
183
|
-
setDialog (dialog) {
|
184
|
-
this.dialog = dialog
|
185
|
-
return this
|
186
|
-
}
|
187
|
-
|
188
|
-
async delete () {
|
189
|
-
const result = await eventBus.dispatch(new DialogEvent(DialogEvent.SHOW, this.dialog))
|
190
|
-
|
191
|
-
if (result === DialogEvent.RESULT_YES) {
|
192
|
-
eventBus.dispatch(new SaveEvent(SaveEvent.START_SAVING))
|
193
|
-
|
194
|
-
const startTime = Date.now()
|
195
|
-
|
196
|
-
const result = await this.action.createRequest()
|
197
|
-
.params({
|
198
|
-
id: this.id
|
199
|
-
})
|
200
|
-
.data(null)
|
201
|
-
.send()
|
202
|
-
|
203
|
-
if (this.afterRemoveHook) {
|
204
|
-
await this.afterRemoveHook()
|
205
|
-
}
|
206
|
-
|
207
|
-
const diffTime = Date.now() - startTime
|
208
|
-
const restTime = Math.max(0, 400 - diffTime)
|
209
|
-
if (restTime) {
|
210
|
-
await sleep(restTime / 1000)
|
211
|
-
}
|
212
|
-
|
213
|
-
eventBus.dispatch(new SaveEvent(SaveEvent.STOP_SAVING))
|
214
|
-
|
215
|
-
if (result) {
|
216
|
-
eventBus.dispatch(new AlertEvent(AlertEvent.MESSAGE, {
|
217
|
-
message: 'Die Daten wurden gelöscht.'
|
218
|
-
}))
|
219
|
-
return true
|
220
|
-
} else {
|
221
|
-
eventBus.dispatch(new AlertEvent(AlertEvent.ERROR, {
|
222
|
-
message: 'Die Daten wurden nicht gelöscht.'
|
223
|
-
}))
|
224
|
-
}
|
225
|
-
}
|
226
|
-
return false
|
227
|
-
}
|
228
|
-
}
|
229
|
-
|
230
|
-
export class ListAction {
|
231
|
-
action = null
|
232
|
-
request = null
|
233
|
-
params = {}
|
234
|
-
fields = {}
|
235
|
-
filters = {}
|
236
|
-
events = true
|
237
|
-
|
238
|
-
setAction (action) {
|
239
|
-
this.action = action
|
240
|
-
return this
|
241
|
-
}
|
242
|
-
|
243
|
-
setRequest (request) {
|
244
|
-
this.request = request
|
245
|
-
return this
|
246
|
-
}
|
247
|
-
|
248
|
-
setParams (params) {
|
249
|
-
this.params = params
|
250
|
-
return this
|
251
|
-
}
|
252
|
-
|
253
|
-
setFields (fields) {
|
254
|
-
this.fields = fields
|
255
|
-
return this
|
256
|
-
}
|
257
|
-
|
258
|
-
setFilters (filters) {
|
259
|
-
this.filters = filters
|
260
|
-
return this
|
261
|
-
}
|
262
|
-
|
263
|
-
noEvents (noEvents) {
|
264
|
-
this.events = noEvents === undefined ? false : !noEvents
|
265
|
-
return this
|
266
|
-
}
|
267
|
-
|
268
|
-
async load () {
|
269
|
-
if (this.events) {
|
270
|
-
eventBus.dispatch(new LoadingEvent(LoadingEvent.START_LOADING))
|
271
|
-
}
|
272
|
-
|
273
|
-
if (!this.request) {
|
274
|
-
this.request = this.action.createRequest()
|
275
|
-
.params(this.params)
|
276
|
-
.fields(this.fields)
|
277
|
-
.filters(this.filters)
|
278
|
-
}
|
279
|
-
|
280
|
-
const result = await this.request.send()
|
281
|
-
|
282
|
-
if (result.error) {
|
283
|
-
if (this.events) {
|
284
|
-
eventBus.dispatch(new LoadingEvent(LoadingEvent.STOP_LOADING))
|
285
|
-
}
|
286
|
-
|
287
|
-
eventBus.dispatch(new AlertEvent(AlertEvent.ERROR, {
|
288
|
-
headline: 'Die Daten konntent nicht geladen werden.',
|
289
|
-
message: result.message,
|
290
|
-
detail: result.detail
|
291
|
-
}))
|
292
|
-
|
293
|
-
return false
|
294
|
-
}
|
295
|
-
|
296
|
-
const models = result.data
|
297
|
-
const meta = result.meta
|
298
|
-
|
299
|
-
// await sleep(2)
|
300
|
-
|
301
|
-
if (this.events) {
|
302
|
-
eventBus.dispatch(new LoadingEvent(LoadingEvent.STOP_LOADING))
|
303
|
-
}
|
304
|
-
|
305
|
-
return {
|
306
|
-
models,
|
307
|
-
meta
|
308
|
-
}
|
309
|
-
}
|
1
|
+
import { BulkAction, SequentialBulkAction } from './ApiAction'
|
2
|
+
import { DeleteAction } from './DeleteAction'
|
3
|
+
import { GetAction } from './GetAction'
|
4
|
+
import { ListAction } from './ListAction'
|
5
|
+
import { SaveAction } from './SaveAction'
|
6
|
+
|
7
|
+
export {
|
8
|
+
BulkAction,
|
9
|
+
SequentialBulkAction,
|
10
|
+
ListAction,
|
11
|
+
GetAction,
|
12
|
+
SaveAction,
|
13
|
+
DeleteAction
|
310
14
|
}
|
@@ -58,9 +58,8 @@ export class FormFieldMixin extends Vue {
|
|
58
58
|
.addParams(this.optionRequestParams || {})
|
59
59
|
.addFilters(filters)
|
60
60
|
|
61
|
-
const {models} = await
|
62
|
-
.
|
63
|
-
.noEvents()
|
61
|
+
const {models} = await ListAction
|
62
|
+
.fromRequest(request)
|
64
63
|
.load()
|
65
64
|
|
66
65
|
return models.map(model => ({
|
@@ -143,9 +143,9 @@ export class ListViewMixin extends Vue {
|
|
143
143
|
|
144
144
|
const request = this.listViewModel.getApiRequest()
|
145
145
|
|
146
|
-
const {models, meta} = await
|
147
|
-
.
|
148
|
-
.
|
146
|
+
const {models, meta} = await ListAction
|
147
|
+
.fromRequest(request)
|
148
|
+
.dispatchGlobalLoadingEvents(this.events)
|
149
149
|
.load()
|
150
150
|
|
151
151
|
if (!models) { // error happened
|
@@ -55,9 +55,8 @@ export default class ListFilterSelect extends Mixins(ListFilterMixin) {
|
|
55
55
|
}
|
56
56
|
|
57
57
|
async loadRequestOptions () {
|
58
|
-
const {models} = await
|
59
|
-
.
|
60
|
-
.noEvents()
|
58
|
+
const {models} = await ListAction
|
59
|
+
.fromRequest(this.filter.createOptionsRequest())
|
61
60
|
.load()
|
62
61
|
|
63
62
|
return [
|
@@ -1,14 +0,0 @@
|
|
1
|
-
import { BulkAction, SequentialBulkAction } from './ApiAction'
|
2
|
-
import { DeleteAction } from './DeleteAction'
|
3
|
-
import { GetAction } from './GetAction'
|
4
|
-
import { ListAction } from './ListAction'
|
5
|
-
import { SaveAction } from './SaveAction'
|
6
|
-
|
7
|
-
export {
|
8
|
-
BulkAction,
|
9
|
-
SequentialBulkAction,
|
10
|
-
ListAction,
|
11
|
-
GetAction,
|
12
|
-
SaveAction,
|
13
|
-
DeleteAction
|
14
|
-
}
|