adminforth 2.27.0-next.30 → 2.27.0-next.32
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.
|
@@ -2,12 +2,22 @@ import { Express, Request, Response } from "express";
|
|
|
2
2
|
import { IAdminForth } from "adminforth";
|
|
3
3
|
export function initApi(app: Express, admin: IAdminForth) {
|
|
4
4
|
app.get(`${admin.config.baseUrl}/api/hello/`,
|
|
5
|
+
|
|
6
|
+
// you can use data API to work with your database https://adminforth.dev/docs/tutorial/Customization/dataApi/
|
|
5
7
|
async (req: Request, res: Response) => {
|
|
8
|
+
// req.adminUser to get info about the admin users
|
|
6
9
|
const allUsers = await admin.resource("adminuser").list([]);
|
|
7
10
|
res.json({
|
|
8
|
-
message: "
|
|
11
|
+
message: "List of admin users from AdminForth API",
|
|
9
12
|
users: allUsers,
|
|
10
13
|
});
|
|
11
14
|
}
|
|
15
|
+
|
|
16
|
+
// you can use admin.express.authorize to get info about the current user
|
|
17
|
+
admin.express.authorize(
|
|
18
|
+
async (req: Request, res: Response) => {
|
|
19
|
+
res.json({ message: "Current adminuser from AdminForth API", adminUser: req.adminUser });
|
|
20
|
+
}
|
|
21
|
+
)
|
|
12
22
|
);
|
|
13
23
|
}
|
|
@@ -162,7 +162,7 @@ const columnError = (column: AdminForthResourceColumnCommon) => {
|
|
|
162
162
|
return currentValues.value[column.name] && currentValues.value[column.name].reduce((error: any, item: any) => {
|
|
163
163
|
if (column.isArray) {
|
|
164
164
|
return error || validateValue(column.isArray.itemType, item, column) ||
|
|
165
|
-
(item === null || !item.toString() ? t('Array cannot contain empty items') : null);
|
|
165
|
+
(item === null || (!item || item.toString() === '') ? t('Array cannot contain empty items') : null);
|
|
166
166
|
} else {
|
|
167
167
|
return error;
|
|
168
168
|
}
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
class="rounded-md m-0.5 bg-lightAnnouncementBG dark:bg-darkAnnouncementBG text-lightAnnouncementText dark:text-darkAnnouncementText py-0.5 px-2.5 text-sm"
|
|
12
12
|
>
|
|
13
13
|
<RouterLink
|
|
14
|
+
v-if="foreignResource && foreignResource?.pk"
|
|
14
15
|
class="font-medium text-lightSidebarText dark:text-darkSidebarText hover:brightness-110 whitespace-nowrap"
|
|
15
16
|
:to="{
|
|
16
17
|
name: 'resource-show',
|
|
@@ -147,7 +147,7 @@ const editableRecord = computed(() => {
|
|
|
147
147
|
coreStore.resource.columns.forEach(column => {
|
|
148
148
|
if (column.foreignResource) {
|
|
149
149
|
if (column.isArray?.enabled) {
|
|
150
|
-
newRecord[column.name] = newRecord[column.name]?.map((fr: { pk: any }) => fr
|
|
150
|
+
newRecord[column.name] = newRecord[column.name]?.map((fr: { pk: any }) => fr?.pk);
|
|
151
151
|
} else {
|
|
152
152
|
newRecord[column.name] = newRecord[column.name]?.pk;
|
|
153
153
|
}
|