adminforth 1.2.36 → 1.2.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/configValidator.js +4 -0
- package/dist/modules/restApi.js +3 -6
- package/dist/spa/spa/src/components/ResourceListTable.vue +12 -10
- package/dist/spa/spa/src/views/ListView.vue +5 -7
- package/modules/configValidator.ts +6 -0
- package/modules/restApi.ts +2 -2
- package/package.json +1 -1
- package/spa/src/components/ResourceListTable.vue +12 -10
- package/spa/src/views/ListView.vue +5 -7
|
@@ -248,6 +248,7 @@ export default class ConfigValidator {
|
|
|
248
248
|
allowed: (_b) => __awaiter(this, [_b], void 0, function* ({ resource, adminUser, allowedActions }) { return allowedActions.delete; }),
|
|
249
249
|
action: (_c) => __awaiter(this, [_c], void 0, function* ({ selectedIds, adminUser }) {
|
|
250
250
|
const connector = this.adminforth.connectors[res.dataSource];
|
|
251
|
+
// for now if at least one error, stop and return error
|
|
251
252
|
let error = null;
|
|
252
253
|
yield Promise.all(selectedIds.map((recordId) => __awaiter(this, void 0, void 0, function* () {
|
|
253
254
|
const record = yield connector.getRecordByPrimaryKey(res, recordId);
|
|
@@ -257,6 +258,9 @@ export default class ConfigValidator {
|
|
|
257
258
|
error = resp.error;
|
|
258
259
|
}
|
|
259
260
|
})));
|
|
261
|
+
if (error) {
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
260
264
|
yield connector.deleteRecord({ resource: res, recordId });
|
|
261
265
|
// call afterDelete hook
|
|
262
266
|
yield Promise.all(res.hooks.delete.afterSave.map((hook) => __awaiter(this, void 0, void 0, function* () {
|
package/dist/modules/restApi.js
CHANGED
|
@@ -622,13 +622,10 @@ export default class AdminForthRestAPI {
|
|
|
622
622
|
if (!execAllowed) {
|
|
623
623
|
return { error: `Action '${actionId}' is not allowed` };
|
|
624
624
|
}
|
|
625
|
-
yield action.action({ selectedIds: recordIds, adminUser, resource });
|
|
626
|
-
return {
|
|
627
|
-
actionId,
|
|
625
|
+
const response = yield action.action({ selectedIds: recordIds, adminUser, resource });
|
|
626
|
+
return Object.assign({ actionId,
|
|
628
627
|
recordIds,
|
|
629
|
-
resourceId,
|
|
630
|
-
status: 'success'
|
|
631
|
-
};
|
|
628
|
+
resourceId }, response);
|
|
632
629
|
})
|
|
633
630
|
});
|
|
634
631
|
// setup endpoints for all plugins
|
|
@@ -228,7 +228,7 @@ import { callAdminForthApi, getIcon } from '@/utils';
|
|
|
228
228
|
import ValueRenderer from '@/components/ValueRenderer.vue';
|
|
229
229
|
import { getCustomComponent } from '@/utils';
|
|
230
230
|
import { useCoreStore } from '@/stores/core';
|
|
231
|
-
import { showSuccesTost } from '@/composables/useFrontendApi';
|
|
231
|
+
import { showSuccesTost, showErrorTost } from '@/composables/useFrontendApi';
|
|
232
232
|
import SkeleteLoader from '@/components/SkeleteLoader.vue';
|
|
233
233
|
|
|
234
234
|
import {
|
|
@@ -368,22 +368,24 @@ async function deleteRecord(row) {
|
|
|
368
368
|
if (data) {
|
|
369
369
|
try {
|
|
370
370
|
const res = await callAdminForthApi({
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
371
|
+
path: '/delete_record',
|
|
372
|
+
method: 'POST',
|
|
373
|
+
body: {
|
|
374
|
+
resourceId: props.resource.resourceId,
|
|
375
|
+
primaryKey: row._primaryKeyValue,
|
|
376
|
+
}
|
|
377
|
+
});
|
|
377
378
|
if (!res.error){
|
|
378
379
|
emits('update:records', true)
|
|
379
380
|
showSuccesTost('Record deleted successfully')
|
|
380
381
|
} else {
|
|
381
|
-
|
|
382
|
+
showErrorTost(res.error)
|
|
382
383
|
}
|
|
383
384
|
|
|
384
385
|
} catch (e) {
|
|
386
|
+
showErrorTost(`Something went wrong, please try again later`);
|
|
385
387
|
console.error(e);
|
|
386
|
-
|
|
387
|
-
|
|
388
|
+
};
|
|
389
|
+
}
|
|
388
390
|
}
|
|
389
391
|
</script>
|
|
@@ -200,11 +200,6 @@ async function getList() {
|
|
|
200
200
|
totalRows.value = data.total;
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
203
|
async function startBulkAction(actionId) {
|
|
209
204
|
const data = await callAdminForthApi({
|
|
210
205
|
path: '/start_bulk_action',
|
|
@@ -216,10 +211,13 @@ async function startBulkAction(actionId) {
|
|
|
216
211
|
|
|
217
212
|
}
|
|
218
213
|
});
|
|
219
|
-
if (data?.
|
|
214
|
+
if (data?.ok) {
|
|
220
215
|
checkboxes.value = [];
|
|
216
|
+
await getList();
|
|
217
|
+
}
|
|
218
|
+
if (data?.error) {
|
|
219
|
+
showErrorTost(data.error);
|
|
221
220
|
}
|
|
222
|
-
await getList();
|
|
223
221
|
}
|
|
224
222
|
|
|
225
223
|
|
|
@@ -269,6 +269,8 @@ export default class ConfigValidator implements IConfigValidator {
|
|
|
269
269
|
allowed: async ({ resource, adminUser, allowedActions }) => { return allowedActions.delete },
|
|
270
270
|
action: async ({ selectedIds, adminUser }) => {
|
|
271
271
|
const connector = this.adminforth.connectors[res.dataSource];
|
|
272
|
+
|
|
273
|
+
// for now if at least one error, stop and return error
|
|
272
274
|
let error = null;
|
|
273
275
|
|
|
274
276
|
await Promise.all(
|
|
@@ -285,6 +287,10 @@ export default class ConfigValidator implements IConfigValidator {
|
|
|
285
287
|
}
|
|
286
288
|
)
|
|
287
289
|
)
|
|
290
|
+
|
|
291
|
+
if (error) {
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
288
294
|
|
|
289
295
|
await connector.deleteRecord({ resource: res, recordId });
|
|
290
296
|
// call afterDelete hook
|
package/modules/restApi.ts
CHANGED
|
@@ -712,13 +712,13 @@ export default class AdminForthRestAPI {
|
|
|
712
712
|
if (!execAllowed) {
|
|
713
713
|
return { error: `Action '${actionId}' is not allowed` };
|
|
714
714
|
}
|
|
715
|
-
await action.action({selectedIds: recordIds, adminUser, resource});
|
|
715
|
+
const response = await action.action({selectedIds: recordIds, adminUser, resource});
|
|
716
716
|
|
|
717
717
|
return {
|
|
718
718
|
actionId,
|
|
719
719
|
recordIds,
|
|
720
720
|
resourceId,
|
|
721
|
-
|
|
721
|
+
...response
|
|
722
722
|
}
|
|
723
723
|
}
|
|
724
724
|
})
|
package/package.json
CHANGED
|
@@ -228,7 +228,7 @@ import { callAdminForthApi, getIcon } from '@/utils';
|
|
|
228
228
|
import ValueRenderer from '@/components/ValueRenderer.vue';
|
|
229
229
|
import { getCustomComponent } from '@/utils';
|
|
230
230
|
import { useCoreStore } from '@/stores/core';
|
|
231
|
-
import { showSuccesTost } from '@/composables/useFrontendApi';
|
|
231
|
+
import { showSuccesTost, showErrorTost } from '@/composables/useFrontendApi';
|
|
232
232
|
import SkeleteLoader from '@/components/SkeleteLoader.vue';
|
|
233
233
|
|
|
234
234
|
import {
|
|
@@ -368,22 +368,24 @@ async function deleteRecord(row) {
|
|
|
368
368
|
if (data) {
|
|
369
369
|
try {
|
|
370
370
|
const res = await callAdminForthApi({
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
371
|
+
path: '/delete_record',
|
|
372
|
+
method: 'POST',
|
|
373
|
+
body: {
|
|
374
|
+
resourceId: props.resource.resourceId,
|
|
375
|
+
primaryKey: row._primaryKeyValue,
|
|
376
|
+
}
|
|
377
|
+
});
|
|
377
378
|
if (!res.error){
|
|
378
379
|
emits('update:records', true)
|
|
379
380
|
showSuccesTost('Record deleted successfully')
|
|
380
381
|
} else {
|
|
381
|
-
|
|
382
|
+
showErrorTost(res.error)
|
|
382
383
|
}
|
|
383
384
|
|
|
384
385
|
} catch (e) {
|
|
386
|
+
showErrorTost(`Something went wrong, please try again later`);
|
|
385
387
|
console.error(e);
|
|
386
|
-
|
|
387
|
-
|
|
388
|
+
};
|
|
389
|
+
}
|
|
388
390
|
}
|
|
389
391
|
</script>
|
|
@@ -200,11 +200,6 @@ async function getList() {
|
|
|
200
200
|
totalRows.value = data.total;
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
203
|
async function startBulkAction(actionId) {
|
|
209
204
|
const data = await callAdminForthApi({
|
|
210
205
|
path: '/start_bulk_action',
|
|
@@ -216,10 +211,13 @@ async function startBulkAction(actionId) {
|
|
|
216
211
|
|
|
217
212
|
}
|
|
218
213
|
});
|
|
219
|
-
if (data?.
|
|
214
|
+
if (data?.ok) {
|
|
220
215
|
checkboxes.value = [];
|
|
216
|
+
await getList();
|
|
217
|
+
}
|
|
218
|
+
if (data?.error) {
|
|
219
|
+
showErrorTost(data.error);
|
|
221
220
|
}
|
|
222
|
-
await getList();
|
|
223
221
|
}
|
|
224
222
|
|
|
225
223
|
|