adminforth 1.13.0-next.25 → 1.13.0-next.27
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import AdminForth, { AdminForthDataTypes, AdminForthResourceInput } from 'adminforth';
|
|
1
|
+
import AdminForth, { AdminForthDataTypes, AdminForthResourceInput, AdminForthResource, AdminUser } from 'adminforth';
|
|
2
|
+
|
|
2
3
|
import type { AdminUser } from 'adminforth';
|
|
3
4
|
|
|
4
5
|
async function canModifyUsers({ adminUser }: { adminUser: AdminUser }): Promise<boolean> {
|
|
@@ -86,18 +87,19 @@ export default {
|
|
|
86
87
|
],
|
|
87
88
|
hooks: {
|
|
88
89
|
create: {
|
|
89
|
-
beforeSave: async ({ record, adminUser, resource }) => {
|
|
90
|
-
record.
|
|
90
|
+
beforeSave: async ({ record, adminUser, resource }: { record: any, adminUser: AdminUser, resource: AdminForthResource }) => {
|
|
91
|
+
record.passwordHash = await AdminForth.Utils.generatePasswordHash(record.password);
|
|
91
92
|
return { ok: true };
|
|
92
93
|
}
|
|
93
94
|
},
|
|
94
95
|
edit: {
|
|
95
|
-
beforeSave: async ({
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
beforeSave: async ({ updates, adminUser, resource }: { updates: any, adminUser: AdminUser, resource: AdminForthResource }) => {
|
|
97
|
+
console.log('Updating user', updates);
|
|
98
|
+
if (updates.password) {
|
|
99
|
+
updates.passwordHash = await AdminForth.Utils.generatePasswordHash(updates.password);
|
|
98
100
|
}
|
|
99
101
|
return { ok: true }
|
|
100
102
|
},
|
|
101
103
|
},
|
|
102
|
-
}
|
|
104
|
+
},
|
|
103
105
|
} as AdminForthResourceInput;
|
|
@@ -107,7 +107,11 @@ const editableRecord = computed(() => {
|
|
|
107
107
|
}
|
|
108
108
|
coreStore.resource.columns.forEach(column => {
|
|
109
109
|
if (column.foreignResource) {
|
|
110
|
-
|
|
110
|
+
if (column.isArray?.enabled) {
|
|
111
|
+
newRecord[column.name] = newRecord[column.name]?.map(fr => fr.pk);
|
|
112
|
+
} else {
|
|
113
|
+
newRecord[column.name] = newRecord[column.name]?.pk;
|
|
114
|
+
}
|
|
111
115
|
}
|
|
112
116
|
});
|
|
113
117
|
return newRecord;
|