adminforth 1.3.33 → 1.3.36
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/restApi.js +10 -6
- package/modules/restApi.ts +12 -8
- package/package.json +1 -1
- package/types/AdminForthConfig.ts +1 -1
package/dist/modules/restApi.js
CHANGED
|
@@ -373,10 +373,12 @@ export default class AdminForthRestAPI {
|
|
|
373
373
|
}
|
|
374
374
|
});
|
|
375
375
|
item._label = resource.recordLabel(item);
|
|
376
|
-
if (resource.options.listTableClickUrl) {
|
|
377
|
-
item._clickUrl = resource.options.listTableClickUrl(item, adminUser);
|
|
378
|
-
}
|
|
379
376
|
});
|
|
377
|
+
if (resource.options.listTableClickUrl) {
|
|
378
|
+
yield Promise.all(data.data.map((item) => __awaiter(this, void 0, void 0, function* () {
|
|
379
|
+
item._clickUrl = yield resource.options.listTableClickUrl(item, adminUser);
|
|
380
|
+
})));
|
|
381
|
+
}
|
|
380
382
|
// only after adminforth made all post processing, give user ability to edit it
|
|
381
383
|
for (const hook of listify((_v = (_u = resource.hooks) === null || _u === void 0 ? void 0 : _u[source]) === null || _v === void 0 ? void 0 : _v.afterDatasourceResponse)) {
|
|
382
384
|
const resp = yield hook({ resource, response: data.data, adminUser });
|
|
@@ -592,9 +594,11 @@ export default class AdminForthRestAPI {
|
|
|
592
594
|
if (!action) {
|
|
593
595
|
return { error: `Action '${actionId}' not found` };
|
|
594
596
|
}
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
597
|
+
if (action.allowed) {
|
|
598
|
+
const execAllowed = yield action.allowed({ adminUser, resource, selectedIds: recordIds, allowedActions });
|
|
599
|
+
if (!execAllowed) {
|
|
600
|
+
return { error: `Action '${actionId}' is not allowed` };
|
|
601
|
+
}
|
|
598
602
|
}
|
|
599
603
|
const response = yield action.action({ selectedIds: recordIds, adminUser, resource });
|
|
600
604
|
return Object.assign({ actionId,
|
package/modules/restApi.ts
CHANGED
|
@@ -437,13 +437,15 @@ export default class AdminForthRestAPI {
|
|
|
437
437
|
delete item[key];
|
|
438
438
|
}
|
|
439
439
|
})
|
|
440
|
-
|
|
441
440
|
item._label = resource.recordLabel(item);
|
|
442
|
-
|
|
443
|
-
if (resource.options.listTableClickUrl) {
|
|
444
|
-
item._clickUrl = resource.options.listTableClickUrl(item, adminUser);
|
|
445
|
-
}
|
|
446
441
|
});
|
|
442
|
+
if (resource.options.listTableClickUrl) {
|
|
443
|
+
await Promise.all(
|
|
444
|
+
data.data.map(async (item) => {
|
|
445
|
+
item._clickUrl = await resource.options.listTableClickUrl(item, adminUser);
|
|
446
|
+
})
|
|
447
|
+
);
|
|
448
|
+
}
|
|
447
449
|
|
|
448
450
|
// only after adminforth made all post processing, give user ability to edit it
|
|
449
451
|
for (const hook of listify(resource.hooks?.[source]?.afterDatasourceResponse)) {
|
|
@@ -685,9 +687,11 @@ export default class AdminForthRestAPI {
|
|
|
685
687
|
return { error: `Action '${actionId}' not found` };
|
|
686
688
|
}
|
|
687
689
|
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
690
|
+
if (action.allowed) {
|
|
691
|
+
const execAllowed = await action.allowed({ adminUser, resource, selectedIds: recordIds, allowedActions });
|
|
692
|
+
if (!execAllowed) {
|
|
693
|
+
return { error: `Action '${actionId}' is not allowed` };
|
|
694
|
+
}
|
|
691
695
|
}
|
|
692
696
|
const response = await action.action({selectedIds: recordIds, adminUser, resource});
|
|
693
697
|
|
package/package.json
CHANGED
|
@@ -1027,7 +1027,7 @@ export type AdminForthResource = {
|
|
|
1027
1027
|
*/
|
|
1028
1028
|
listPageSize?: number,
|
|
1029
1029
|
|
|
1030
|
-
listTableClickUrl?: (record: any, adminUser: AdminUser) => string
|
|
1030
|
+
listTableClickUrl?: (record: any, adminUser: AdminUser) => Promise<string>,
|
|
1031
1031
|
|
|
1032
1032
|
/**
|
|
1033
1033
|
* Custom components which can be injected into AdminForth CRUD pages.
|