adminizer 4.4.0-build.148 → 4.4.0-build.150
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/interfaces/adminpanelConfig.d.ts +6 -1
- package/package.json +1 -1
- package/system/Router.js +18 -4
- package/system/defaults.js +8 -4
|
@@ -3,6 +3,10 @@ import { EditorOptions } from "@toast-ui/editor/types/editor";
|
|
|
3
3
|
import { GridSettings as HandsontableSettings } from "handsontable/settings";
|
|
4
4
|
import { GroupAP } from "models/GroupAP";
|
|
5
5
|
import { UserAP } from "models/UserAP";
|
|
6
|
+
/**
|
|
7
|
+
* Controller function type - async function that handles requests and returns a response
|
|
8
|
+
*/
|
|
9
|
+
export type ControllerFunction = (req: ReqType, res: ResType) => Promise<any>;
|
|
6
10
|
export type AdminpanelIcon = MaterialIcon;
|
|
7
11
|
export type FieldsTypes = "string" | "password" | "date" | "datetime" | "time" | "integer" | "number" | "float" | "color" | "email" | "month" | "week" | "range" | "boolean" | "binary" | "text" | "longtext" | "mediumtext" | "ckeditor" | "wysiwyg" | "texteditor" | "word" | 'tui' | 'tuieditor' | 'toast-ui' | "jsoneditor" | "json" | "array" | "object" | "ace" | "code" | "html" | "xml" | "aceeditor" | "menu" | "schedule" | "worktime" | "association" | "association-many" | "select" | "select-many" | "table" | "geojson" | "mediamanager" |
|
|
8
12
|
/**
|
|
@@ -425,8 +429,9 @@ export interface CreateUpdateConfig {
|
|
|
425
429
|
entityModifier?: <T>(fieldData: T) => T;
|
|
426
430
|
/**
|
|
427
431
|
* You can change standard controller for any entity by this property
|
|
432
|
+
* Can be either a string path (for dynamic import) or a controller function
|
|
428
433
|
* */
|
|
429
|
-
controller?: string;
|
|
434
|
+
controller?: string | ControllerFunction;
|
|
430
435
|
}
|
|
431
436
|
export interface HrefConfig {
|
|
432
437
|
id: string;
|
package/package.json
CHANGED
package/system/Router.js
CHANGED
|
@@ -126,8 +126,15 @@ export default class Router {
|
|
|
126
126
|
if (modelConfig.add) {
|
|
127
127
|
let addHandler = modelConfig.add;
|
|
128
128
|
if (addHandler.controller) {
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
if (typeof addHandler.controller === 'string') {
|
|
130
|
+
// Dynamic import for string paths
|
|
131
|
+
let controller = await import(addHandler.controller);
|
|
132
|
+
adminizer.app.all(`${adminizer.config.routePrefix}/model/${model}/add`, adminizer.policyManager.bindPolicies(policies, controller.default));
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
// Direct function reference (controller function matches middleware signature)
|
|
136
|
+
adminizer.app.all(`${adminizer.config.routePrefix}/model/${model}/add`, adminizer.policyManager.bindPolicies(policies, addHandler.controller));
|
|
137
|
+
}
|
|
131
138
|
}
|
|
132
139
|
else {
|
|
133
140
|
adminizer.app.all(`${adminizer.config.routePrefix}/model/${model}/add`, adminizer.policyManager.bindPolicies(policies, _add));
|
|
@@ -142,8 +149,15 @@ export default class Router {
|
|
|
142
149
|
if (modelConfig.edit) {
|
|
143
150
|
let editHandler = modelConfig.edit;
|
|
144
151
|
if (editHandler.controller) {
|
|
145
|
-
|
|
146
|
-
|
|
152
|
+
if (typeof editHandler.controller === 'string') {
|
|
153
|
+
// Dynamic import for string paths
|
|
154
|
+
let controller = await import(editHandler.controller);
|
|
155
|
+
adminizer.app.all(`${adminizer.config.routePrefix}/model/${model}/edit/:id`, adminizer.policyManager.bindPolicies(policies, controller.default));
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
// Direct function reference (controller function matches middleware signature)
|
|
159
|
+
adminizer.app.all(`${adminizer.config.routePrefix}/model/${model}/edit/:id`, adminizer.policyManager.bindPolicies(policies, editHandler.controller));
|
|
160
|
+
}
|
|
147
161
|
}
|
|
148
162
|
else {
|
|
149
163
|
adminizer.app.all(`${adminizer.config.routePrefix}/model/${model}/edit/:id`, adminizer.policyManager.bindPolicies(policies, _edit));
|
package/system/defaults.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
import { FileStorageHelper } from "../helpers/fileStorageHelper.js";
|
|
3
3
|
import timezones from "../lib/timezones.js";
|
|
4
|
+
import addUser from "../controllers/addUser.js";
|
|
5
|
+
import editUser from "../controllers/editUser.js";
|
|
6
|
+
import addGroup from "../controllers/addGroup.js";
|
|
7
|
+
import editGroup from "../controllers/editGroup.js";
|
|
4
8
|
/**
|
|
5
9
|
* Default admin config
|
|
6
10
|
*/
|
|
@@ -37,10 +41,10 @@ let adminpanelConfig = {
|
|
|
37
41
|
section: "System"
|
|
38
42
|
},
|
|
39
43
|
add: {
|
|
40
|
-
controller:
|
|
44
|
+
controller: addUser
|
|
41
45
|
},
|
|
42
46
|
edit: {
|
|
43
|
-
controller:
|
|
47
|
+
controller: editUser
|
|
44
48
|
},
|
|
45
49
|
fields: {
|
|
46
50
|
login: {
|
|
@@ -82,10 +86,10 @@ let adminpanelConfig = {
|
|
|
82
86
|
section: "System"
|
|
83
87
|
},
|
|
84
88
|
add: {
|
|
85
|
-
controller:
|
|
89
|
+
controller: addGroup
|
|
86
90
|
},
|
|
87
91
|
edit: {
|
|
88
|
-
controller:
|
|
92
|
+
controller: editGroup
|
|
89
93
|
},
|
|
90
94
|
list: {
|
|
91
95
|
fields: {
|