adminizer 4.1.0-build.3 → 4.1.0-build.31
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/Readme.md +11 -1
- package/assets/{VanillaJSONEditor-FUe77pIA.js → VanillaJSONEditor-DTWads1Y.js} +104 -104
- package/assets/add-NjsCZZct.js +1 -0
- package/assets/add-form-DJnEBqvy.js +1 -0
- package/assets/add-group-CU2zD7To.js +1 -0
- package/assets/add-group-form-CQN_syZq.js +1 -0
- package/assets/add-user-BkTa9shp.js +1 -0
- package/assets/add-user-form-C7T14FsG.js +1 -0
- package/assets/{app-DMmad2-f.css → app-DVaaqBB5.css} +1 -1
- package/assets/app-layout-NY6MXzc5.js +1 -0
- package/assets/{app-shell-BWMRMkHM.js → app-shell-BjaxjNs9.js} +1 -1
- package/assets/app-sidebar-CLu13Pcu.js +1 -0
- package/assets/{app-sidebar-header-DLAFi13E.js → app-sidebar-header-5IaQpngt.js} +1 -1
- package/assets/app.js +9 -9
- package/assets/{breadcrumbs-CQNon4Vl.js → breadcrumbs-CDxSbsTe.js} +1 -1
- package/assets/button-BV-GbIpN.js +1 -0
- package/assets/catalog-Cc6Mk9sX.css +1 -0
- package/assets/catalog-CeUUKxG9.js +17 -0
- package/assets/{checkbox-W0nGAXIj.js → checkbox-DrkQu16U.js} +1 -1
- package/assets/{compiler-runtime-tM4jBQ-T.js → compiler-runtime-Cj7rbuyn.js} +2 -2
- package/assets/dashboard-BOltB2Hq.css +1 -0
- package/assets/dashboard-BTmXuc5F.js +3 -0
- package/assets/{date-picker-B__dVVqj.js → date-picker-hoDPF9Am.js} +1 -1
- package/assets/debounce-qdyXyOeG.js +1 -0
- package/assets/del-modal-BUVjhY0k.js +6 -0
- package/assets/dialog-stack-BAuaxCy1.js +1 -0
- package/assets/dropdown-menu-CeMIoM8d.js +1 -0
- package/assets/{field-renderer-CapylJU9.js → field-renderer-zGC76llY.js} +3 -3
- package/assets/form-CN2xVSMK.js +1 -0
- package/assets/form-DOt5Fa6e.js +1 -0
- package/assets/{geo-json-CwteYDGB.js → geo-json-VtXcqPd9.js} +1 -1
- package/assets/group-link-add-CCNISxeF.js +1 -0
- package/assets/{handsontable-BCnjOpBr.js → handsontable-DrEU6lOi.js} +1 -1
- package/assets/home-3FBATYFh.js +2 -0
- package/assets/{icon-Bz9BMaD0.js → icon-CqJOMij7.js} +1 -1
- package/assets/index-BCpOvf4m.js +1 -0
- package/assets/{index-BbXEMx9n.js → index-B__NksD2.js} +1 -1
- package/assets/{index-DTRTjOmh.js → index-C0o7vG6r.js} +3 -3
- package/assets/{index-C0SL3SHw.js → index-CcxvoJO6.js} +1 -1
- package/assets/{index-D5ir9iUV.js → index-Cq31rrfZ.js} +1 -1
- package/assets/{index-K81GbF6O.js → index-DN1K56yz.js} +1 -1
- package/assets/{index-DrWfGwtf.js → index-DU8vYhyh.js} +1 -1
- package/assets/{index-BcE9FUM6.js → index-DoVAC0HX.js} +1 -1
- package/assets/{index-BC0yfOHo.js → index-lqMxC6QB.js} +1 -1
- package/assets/{index-DEk3sC8d.js → index-oMAR28Sy.js} +1 -1
- package/assets/{init-user-D9mW-g14.js → init-user-BBfP40-3.js} +1 -1
- package/assets/{input-DF7Ue23C.js → input-B7wUhbil.js} +1 -1
- package/assets/{input-error-BBygona6.js → input-error-DFk1EyT_.js} +1 -1
- package/assets/item-add-CX7EOX0H.js +1 -0
- package/assets/{label-Z506NKsW.js → label-GEoZpZr4.js} +1 -1
- package/assets/list-DqIUjXSX.js +1 -0
- package/assets/list-table-1aXDvDPl.js +57 -0
- package/assets/{login-DrGaTWhY.js → login-Bv4hqwaM.js} +2 -2
- package/assets/manifest.json +788 -604
- package/assets/{material-icon-CItZiB53.js → material-icon-BAd3Wrgn.js} +1 -1
- package/assets/module-DziT22BH.js +1 -0
- package/assets/{monaco-editor-DqAqwxw4.js → monaco-editor-B5kndNv5.js} +1 -1
- package/assets/{multi-select-oabtVhUP.js → multi-select-CSxVlxon.js} +2 -2
- package/assets/{nav-footer-CM-yHiRs.js → nav-footer-Vm24wf5X.js} +1 -1
- package/assets/{nav-main-Q3xofGRT.js → nav-main-JVt9gzn8.js} +1 -1
- package/assets/{nav-user-Ds8i0Pa2.js → nav-user-DgYX0wO7.js} +1 -1
- package/assets/{pagination-render-B57pOpFy.js → pagination-render-B12W01AJ.js} +1 -1
- package/assets/{popover-I249Gg2O.js → popover-B3ZOyoLQ.js} +1 -1
- package/assets/{register-C9FQIDtS.js → register-D8SyTFBZ.js} +1 -1
- package/assets/{select-D1N8zRPY.js → select-MzwxLt1D.js} +2 -2
- package/assets/{sidebar-4D-sX2l4.js → sidebar-DGp3i7GG.js} +2 -2
- package/assets/skeleton-C3gmNc1Z.js +1 -0
- package/assets/{sonner-Dzckw3U3.js → sonner-MAL0i2dq.js} +1 -1
- package/assets/{toast-editor-FbrFd1ft.js → toast-editor-DRP2u8-X.js} +1 -1
- package/assets/{tooltip-D2ehgLlB.js → tooltip-Du62rBCn.js} +1 -1
- package/assets/{use-appearance-Co6mO0dV.js → use-appearance-DeUiDZ72.js} +1 -1
- package/assets/{use-window-size-B8l6Bpkf.js → use-window-size-ChEjEujj.js} +1 -1
- package/assets/{user-info-DBYoAJYJ.js → user-info-C_11jYGE.js} +1 -1
- package/assets/{user-menu-content-qkvdkUVd.js → user-menu-content-BNRzhEo_.js} +2 -2
- package/assets/welcome-C9BMKsoY.js +1 -0
- package/controllers/add.js +10 -10
- package/controllers/addGroup.js +2 -4
- package/controllers/addUser.js +4 -6
- package/controllers/catalog/Catalog.d.ts +1 -1
- package/controllers/catalog/Catalog.js +42 -36
- package/controllers/catalog/FrontentCatalogAdapter.d.ts +39 -25
- package/controllers/catalog/FrontentCatalogAdapter.js +55 -55
- package/controllers/ckeditorUpload.js +2 -3
- package/controllers/dashboard.js +16 -2
- package/controllers/edit.js +10 -14
- package/controllers/editGroup.js +2 -4
- package/controllers/editUser.js +3 -5
- package/controllers/form.js +2 -3
- package/controllers/getAllWidgets.js +3 -3
- package/controllers/initUser.js +1 -2
- package/controllers/list.js +6 -6
- package/controllers/login.js +31 -15
- package/controllers/media-manager/mediaManagerAdapter.js +1 -2
- package/controllers/media-manager/mediaManagerApi.js +2 -2
- package/controllers/navigation/edit.js +2 -2
- package/controllers/register.js +1 -4
- package/controllers/remove.js +3 -3
- package/controllers/timezones.js +1 -1
- package/controllers/view.js +3 -3
- package/controllers/welcome.js +1 -1
- package/controllers/widgets/Action.js +2 -2
- package/controllers/widgets/Custom.js +2 -2
- package/controllers/widgets/Info.js +2 -2
- package/controllers/widgets/switch.js +2 -2
- package/controllers/widgetsDB.js +5 -5
- package/helpers/JsUtils.d.ts +1 -0
- package/helpers/JsUtils.js +3 -0
- package/helpers/accessRightsHelper.d.ts +6 -2
- package/helpers/accessRightsHelper.js +26 -3
- package/helpers/configHelper.js +2 -1
- package/helpers/controllerHelper.js +39 -18
- package/helpers/fieldsHelper.d.ts +4 -3
- package/helpers/fieldsHelper.js +5 -1
- package/helpers/inertiaActionsHelper.js +1 -1
- package/helpers/inertiaAddHelper.d.ts +3 -4
- package/helpers/inertiaAddHelper.js +27 -7
- package/helpers/inertiaFromHelper.js +2 -0
- package/helpers/inertiaGroupHelper.d.ts +4 -2
- package/helpers/inertiaGroupHelper.js +1 -1
- package/helpers/inertiaListHelper.js +5 -5
- package/helpers/inertiaMenuHelper.d.ts +1 -1
- package/helpers/inertiaMenuHelper.js +2 -2
- package/helpers/inertiaUserHelper.d.ts +7 -1
- package/helpers/inertiaUserHelper.js +5 -1
- package/helpers/menuHelper.d.ts +4 -3
- package/helpers/menuHelper.js +22 -15
- package/index.d.ts +5 -3
- package/index.js +8 -3
- package/interfaces/adminpanelConfig.d.ts +29 -32
- package/interfaces/global.d.ts +10 -28
- package/interfaces/types.d.ts +1 -1
- package/lib/Adminizer.d.ts +4 -2
- package/lib/Adminizer.js +33 -11
- package/lib/media-manager/AbstractMediaManager.d.ts +2 -2
- package/lib/media-manager/AbstractMediaManager.js +1 -1
- package/lib/media-manager/Items.js +0 -3
- package/lib/requestProcessor.js +10 -3
- package/lib/v4/DataAccessor.d.ts +5 -2
- package/lib/v4/DataAccessor.js +44 -19
- package/lib/v4/I18n.js +2 -0
- package/lib/v4/POWCaptcha.js +0 -1
- package/lib/v4/PolicyManager.js +0 -1
- package/lib/{catalog → v4/catalog}/AbstractCatalog.d.ts +79 -41
- package/lib/{catalog → v4/catalog}/AbstractCatalog.js +49 -41
- package/lib/v4/catalog/Navigation.d.ts +43 -0
- package/lib/v4/catalog/Navigation.js +457 -0
- package/lib/{controls → v4/controls}/AbstractControls.d.ts +1 -1
- package/lib/{controls → v4/controls}/codeEditor/MonacoEditor.d.ts +1 -1
- package/lib/{controls → v4/controls}/geojsoneditor/GeoEditor.d.ts +1 -1
- package/lib/{controls → v4/controls}/jsoneditor/JsonEditor.d.ts +1 -1
- package/lib/{controls → v4/controls}/markdown/ToastUiEditor.d.ts +1 -1
- package/lib/{controls → v4/controls}/table/Handsontable.d.ts +1 -1
- package/lib/{controls → v4/controls}/wysiwyg/CKeditor.d.ts +1 -1
- package/lib/{datatable → v4/datatable}/NodeTable.d.ts +3 -3
- package/lib/{datatable → v4/datatable}/NodeTable.js +8 -8
- package/lib/v4/helper/jwt.d.ts +10 -0
- package/lib/v4/helper/jwt.js +18 -0
- package/lib/{inertia → v4/inertia}/inertiaAdapter.js +0 -1
- package/lib/v4/model/AbstractModel.d.ts +5 -1
- package/lib/v4/model/AbstractModel.js +2 -3
- package/lib/v4/model/ModelHandler.js +1 -1
- package/lib/v4/model/adapter/sequelize.d.ts +11 -2
- package/lib/v4/model/adapter/sequelize.js +451 -118
- package/lib/v4/model/adapter/waterline.js +5 -3
- package/lib/{widgets → v4/widgets}/abstractAction.d.ts +1 -1
- package/lib/v4/widgets/abstractCustom.d.ts +28 -0
- package/lib/v4/widgets/abstractCustom.js +9 -0
- package/lib/{widgets → v4/widgets}/abstractInfo.d.ts +1 -1
- package/lib/{widgets → v4/widgets}/abstractInfo.js +1 -1
- package/lib/{widgets → v4/widgets}/abstractLink.d.ts +2 -1
- package/lib/{widgets → v4/widgets}/abstractSwitch.d.ts +1 -1
- package/lib/{widgets → v4/widgets}/abstractWidgetBase.d.ts +2 -2
- package/lib/{widgets → v4/widgets}/widgetHandler.d.ts +29 -5
- package/lib/{widgets → v4/widgets}/widgetHandler.js +25 -25
- package/models/GroupAP.d.ts +8 -0
- package/models/NavigationAP.d.ts +7 -3
- package/models/NavigationAP.js +5 -6
- package/models/UserAP.d.ts +24 -2
- package/models/UserAP.js +2 -2
- package/package.json +27 -11
- package/policies/checkAuth.js +4 -3
- package/policies/setLocale.js +2 -2
- package/system/Router.js +8 -16
- package/system/bindAccessRights.js +0 -4
- package/system/bindAuthorization.js +4 -5
- package/system/bindControls.js +6 -6
- package/system/bindDev.js +1 -0
- package/system/bindInertia.js +12 -11
- package/system/bindMediaManager.js +0 -1
- package/system/bindModels.js +8 -5
- package/system/bindNavigation.d.ts +2 -0
- package/system/bindNavigation.js +42 -42
- package/system/bindReqFunctions.js +15 -0
- package/system/defaults.js +2 -2
- package/translations/ru.json +17 -8
- package/assets/add-ZITr43GJ.js +0 -1
- package/assets/add-form-CYOfr0Ef.js +0 -1
- package/assets/add-group-B332wN8K.js +0 -1
- package/assets/add-group-form-dzadPSfL.js +0 -1
- package/assets/add-user-TC-mYdsB.js +0 -1
- package/assets/add-user-form-y2f_1_lM.js +0 -1
- package/assets/app-layout-D1m9Kvxq.js +0 -1
- package/assets/app-sidebar-BCtaEFGb.js +0 -1
- package/assets/button-CQ9t1kLz.js +0 -1
- package/assets/dashboard-BR602KhL.js +0 -1
- package/assets/dropdown-menu-SEBnEIiL.js +0 -1
- package/assets/form-DOUNk3o2.js +0 -1
- package/assets/form-lOKv4Qbw.js +0 -1
- package/assets/home-Ch6QfTIt.js +0 -2
- package/assets/index-Cdb9ACvz.js +0 -1
- package/assets/list-Qyd7ecQH.js +0 -1
- package/assets/list-table-DB1sEQLF.js +0 -62
- package/assets/module-DBaykv8l.js +0 -1
- package/assets/welcome-D2adQ8EU.js +0 -1
- package/controllers/processInstallFinalize.d.ts +0 -1
- package/controllers/processInstallFinalize.js +0 -16
- package/controllers/processInstallStep.d.ts +0 -1
- package/controllers/processInstallStep.js +0 -132
- package/lib/catalog/Navigation.d.ts +0 -0
- package/lib/catalog/Navigation.js +0 -532
- package/lib/installStepper/InstallStepAbstract.d.ts +0 -52
- package/lib/installStepper/InstallStepAbstract.js +0 -69
- package/lib/installStepper/finalizeStep.d.ts +0 -21
- package/lib/installStepper/finalizeStep.js +0 -48
- package/lib/installStepper/installStepper.d.ts +0 -40
- package/lib/installStepper/installStepper.js +0 -195
- package/lib/widgets/abstractCustom.d.ts +0 -13
- package/lib/widgets/abstractCustom.js +0 -3
- package/models/MediaManagerAP.d.ts +0 -46
- package/models/MediaManagerAP.js +0 -45
- package/models/MediaManagerAssociationsAP.d.ts +0 -28
- package/models/MediaManagerAssociationsAP.js +0 -27
- package/models/MediaManagerMetaAP.d.ts +0 -22
- package/models/MediaManagerMetaAP.js +0 -21
- package/system/bindInstallStepper.d.ts +0 -2
- package/system/bindInstallStepper.js +0 -23
- /package/lib/{catalog → v4/catalog}/CatalogHandler.d.ts +0 -0
- /package/lib/{catalog → v4/catalog}/CatalogHandler.js +0 -0
- /package/lib/{controls → v4/controls}/AbstractControls.js +0 -0
- /package/lib/{controls → v4/controls}/ControlsHandler.d.ts +0 -0
- /package/lib/{controls → v4/controls}/ControlsHandler.js +0 -0
- /package/lib/{controls → v4/controls}/codeEditor/MonacoEditor.js +0 -0
- /package/lib/{controls → v4/controls}/geojsoneditor/GeoEditor.js +0 -0
- /package/lib/{controls → v4/controls}/jsoneditor/JsonEditor.js +0 -0
- /package/lib/{controls → v4/controls}/markdown/ToastUiEditor.js +0 -0
- /package/lib/{controls → v4/controls}/table/Handsontable.js +0 -0
- /package/lib/{controls → v4/controls}/wysiwyg/CKeditor.js +0 -0
- /package/lib/{inertia → v4/inertia}/flash.d.ts +0 -0
- /package/lib/{inertia → v4/inertia}/flash.js +0 -0
- /package/lib/{inertia → v4/inertia}/inertiaAdapter.d.ts +0 -0
- /package/lib/{widgets → v4/widgets}/abstractAction.js +0 -0
- /package/lib/{widgets → v4/widgets}/abstractLink.js +0 -0
- /package/lib/{widgets → v4/widgets}/abstractSwitch.js +0 -0
- /package/lib/{widgets → v4/widgets}/abstractWidgetBase.js +0 -0
|
@@ -28,7 +28,15 @@ export class ControllerHelper {
|
|
|
28
28
|
* @private
|
|
29
29
|
*/
|
|
30
30
|
static _isValidModelConfig(config) {
|
|
31
|
-
|
|
31
|
+
try {
|
|
32
|
+
if (!config)
|
|
33
|
+
throw `Config is not defined ${config}`;
|
|
34
|
+
return (typeof config === "object" && typeof config.model === "string");
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
Adminizer.log.error(error);
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
32
40
|
}
|
|
33
41
|
;
|
|
34
42
|
/**
|
|
@@ -84,7 +92,7 @@ export class ControllerHelper {
|
|
|
84
92
|
const entityType = req.params.entityType;
|
|
85
93
|
if (!entityType) {
|
|
86
94
|
const extractedEntityType = req.originalUrl.split('/')[2];
|
|
87
|
-
if (["form", "model"
|
|
95
|
+
if (["form", "model"].includes(extractedEntityType)) {
|
|
88
96
|
return extractedEntityType;
|
|
89
97
|
}
|
|
90
98
|
else {
|
|
@@ -101,22 +109,28 @@ export class ControllerHelper {
|
|
|
101
109
|
* @returns {?string}
|
|
102
110
|
*/
|
|
103
111
|
static findEntityName(req) {
|
|
104
|
-
if (
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
+
if (req.params.entityName) {
|
|
113
|
+
return req.params.entityName;
|
|
114
|
+
}
|
|
115
|
+
const urlParts = req.originalUrl.split('/');
|
|
116
|
+
const entityType = urlParts[2];
|
|
117
|
+
const entityName = urlParts[3];
|
|
118
|
+
if (entityType === 'form') {
|
|
119
|
+
const forms = req.adminizer.config.forms?.data;
|
|
120
|
+
if (!forms || !Object.keys(forms).some(key => key.toLowerCase() === entityName.toLowerCase())) {
|
|
121
|
+
throw new Error(`Form "${entityName}" not found`);
|
|
112
122
|
}
|
|
113
|
-
|
|
114
|
-
|
|
123
|
+
return Object.keys(forms).find(key => key.toLowerCase() === entityName.toLowerCase());
|
|
124
|
+
}
|
|
125
|
+
if (entityType === 'model') {
|
|
126
|
+
const models = req.adminizer.config.models;
|
|
127
|
+
if (!models || !Object.keys(models).some(key => key.toLowerCase() === entityName.toLowerCase())) {
|
|
128
|
+
throw new Error(`Model "${entityName}" not found`);
|
|
115
129
|
}
|
|
130
|
+
return Object.keys(models).find(key => key.toLowerCase() === entityName.toLowerCase());
|
|
116
131
|
}
|
|
117
|
-
|
|
132
|
+
throw new Error(`Unsupported entity type "${entityType}" in URL`);
|
|
118
133
|
}
|
|
119
|
-
;
|
|
120
134
|
/**
|
|
121
135
|
* Searches for config from admin panel
|
|
122
136
|
*
|
|
@@ -125,11 +139,17 @@ export class ControllerHelper {
|
|
|
125
139
|
* @returns {?Object}
|
|
126
140
|
*/
|
|
127
141
|
static findModelConfig(req, entityName) {
|
|
128
|
-
|
|
129
|
-
|
|
142
|
+
const models = req.adminizer.config.models;
|
|
143
|
+
if (!models) {
|
|
144
|
+
Adminizer.log.error('No models configuration found');
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
const foundKey = Object.keys(models).find(key => key.toLowerCase() === entityName.toLowerCase());
|
|
148
|
+
if (!foundKey) {
|
|
149
|
+
Adminizer.log.error(`No such route exists: ${entityName}`);
|
|
130
150
|
return null;
|
|
131
151
|
}
|
|
132
|
-
return this._normalizeModelConfig(
|
|
152
|
+
return this._normalizeModelConfig(foundKey, models[foundKey]);
|
|
133
153
|
}
|
|
134
154
|
/**
|
|
135
155
|
* Will get action config from configuration file depending to given action
|
|
@@ -200,7 +220,8 @@ export class ControllerHelper {
|
|
|
200
220
|
name: entityName,
|
|
201
221
|
uri: entityUri,
|
|
202
222
|
type: entityType,
|
|
203
|
-
model: null
|
|
223
|
+
model: null,
|
|
224
|
+
config: null
|
|
204
225
|
};
|
|
205
226
|
// If the entity type is "model", add additional properties
|
|
206
227
|
if (entityType === "model") {
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import { ActionType, BaseFieldConfig, FieldsTypes } from "../interfaces/adminpanelConfig";
|
|
1
|
+
import { ActionType, BaseFieldConfig, FieldsTypes, ModelConfig } from "../interfaces/adminpanelConfig";
|
|
2
2
|
import { Attribute } from "../lib/v4/model/AbstractModel";
|
|
3
3
|
export type Field = {
|
|
4
4
|
config: BaseFieldConfig & {
|
|
5
5
|
/** @deprecated record should not be in config anymore */
|
|
6
|
-
records?:
|
|
6
|
+
records?: Record<string, any>[];
|
|
7
7
|
file?: string;
|
|
8
8
|
key?: string;
|
|
9
9
|
required?: boolean;
|
|
10
10
|
type?: FieldsTypes;
|
|
11
11
|
groupsAccessRights?: string[];
|
|
12
12
|
} | string | boolean;
|
|
13
|
-
/**
|
|
13
|
+
/** For render associalitons fields */
|
|
14
14
|
populated: {
|
|
15
15
|
[key: string]: Field;
|
|
16
16
|
} | undefined;
|
|
17
17
|
model: Attribute;
|
|
18
|
+
modelConfig: ModelConfig;
|
|
18
19
|
};
|
|
19
20
|
export type Fields = {
|
|
20
21
|
[key: string]: Field;
|
package/helpers/fieldsHelper.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DataAccessor } from "../lib/v4/DataAccessor";
|
|
2
2
|
import { Adminizer } from "../lib/Adminizer";
|
|
3
|
+
import { isObject } from "./JsUtils";
|
|
3
4
|
export class FieldsHelper {
|
|
4
5
|
/**
|
|
5
6
|
* Load list of records for all associations into `fields`
|
|
@@ -20,6 +21,9 @@ export class FieldsHelper {
|
|
|
20
21
|
*/
|
|
21
22
|
let loadAssoc = async function (key, action) {
|
|
22
23
|
let fieldConfigConfig = fields[key].config;
|
|
24
|
+
if (!isObject(fieldConfigConfig)) {
|
|
25
|
+
throw 'type error: fieldConfigConfig should be normalized';
|
|
26
|
+
}
|
|
23
27
|
if (fieldConfigConfig.type !== 'association' && fieldConfigConfig.type !== 'association-many') {
|
|
24
28
|
return;
|
|
25
29
|
}
|
|
@@ -42,7 +46,7 @@ export class FieldsHelper {
|
|
|
42
46
|
name: modelName, config: req.adminizer.config.models[modelName],
|
|
43
47
|
model: Model, uri: `${req.adminizer.config.routePrefix}/model/${modelName}`, type: "model"
|
|
44
48
|
};
|
|
45
|
-
let dataAccessor = new DataAccessor(req, entity,
|
|
49
|
+
let dataAccessor = new DataAccessor(req.adminizer, req.user, entity, "view");
|
|
46
50
|
list = await Model.find({}, dataAccessor);
|
|
47
51
|
}
|
|
48
52
|
catch (e) {
|
|
@@ -4,7 +4,7 @@ export default function inertiaActionsHelper(actionType, entity, req) {
|
|
|
4
4
|
const actions = req.adminizer.menuHelper.getGlobalActions(entity.config, actionType);
|
|
5
5
|
if (actions && actions.length > 0) {
|
|
6
6
|
actions.forEach(function (action) {
|
|
7
|
-
if (req.adminizer.accessRightsHelper.hasPermission(action.accessRightsToken, req.
|
|
7
|
+
if (req.adminizer.accessRightsHelper.hasPermission(action.accessRightsToken, req.user)) {
|
|
8
8
|
resActions.push({
|
|
9
9
|
link: action.link,
|
|
10
10
|
id: action.id,
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Entity, PropsField } from "../interfaces/types";
|
|
2
2
|
import { Actions } from "./inertiaActionsHelper";
|
|
3
|
-
import { Fields } from "./fieldsHelper";
|
|
4
|
-
import {
|
|
5
|
-
import { AbstractControls, ControlType } from "../lib/controls/AbstractControls";
|
|
3
|
+
import { Fields, Field } from "./fieldsHelper";
|
|
4
|
+
import { AbstractControls, ControlType } from "../lib/v4/controls/AbstractControls";
|
|
6
5
|
export type PropsFieldType = 'text' | 'number' | 'range' | 'week' | 'month' | 'email' | 'color' | 'time' | 'date' | 'datetime-local' | 'password' | 'select' | 'select-many' | 'association-many' | 'association' | 'textarea' | 'checkbox' | ControlType;
|
|
7
6
|
interface FieldProps extends Record<string | number | symbol, unknown> {
|
|
8
7
|
edit: boolean;
|
|
@@ -21,7 +20,7 @@ interface FieldProps extends Record<string | number | symbol, unknown> {
|
|
|
21
20
|
postLink: string;
|
|
22
21
|
}
|
|
23
22
|
export default function inertiaAddHelper(req: ReqType, entity: Entity, fields: Fields, record?: Record<string, string | boolean | number | string[]>, view?: boolean): FieldProps;
|
|
24
|
-
export declare function getControlsOptions(fieldConfig:
|
|
23
|
+
export declare function getControlsOptions(fieldConfig: Field["config"], req: ReqType, type: ControlType, defaultControlName: string): {
|
|
25
24
|
name: string;
|
|
26
25
|
config: {
|
|
27
26
|
el?: HTMLElement;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import inertiaActionsHelper from "./inertiaActionsHelper";
|
|
2
2
|
import chalk from "chalk";
|
|
3
|
+
import { isObject } from "./JsUtils";
|
|
3
4
|
export default function inertiaAddHelper(req, entity, fields, record, view = false) {
|
|
4
5
|
const actionType = 'add';
|
|
5
6
|
let props = {
|
|
@@ -25,6 +26,10 @@ export default function inertiaAddHelper(req, entity, fields, record, view = fal
|
|
|
25
26
|
continue;
|
|
26
27
|
let field = fields[key];
|
|
27
28
|
let fieldConfig = field.config;
|
|
29
|
+
if (!isObject(fieldConfig))
|
|
30
|
+
throw `Type error: fieldConfig is object`;
|
|
31
|
+
if (!!fieldConfig.visible === false)
|
|
32
|
+
continue;
|
|
28
33
|
const type = (fieldConfig.type || fieldConfig.type).toLowerCase();
|
|
29
34
|
//@ts-ignore TODO: fix model validations
|
|
30
35
|
const isIn = typeof fieldConfig.isIn === 'object' ? fieldConfig.isIn : (field.model && typeof { ...field.model.validations }.isIn === 'object' ? { ...field.model.validations }.isIn : []);
|
|
@@ -113,6 +118,8 @@ export default function inertiaAddHelper(req, entity, fields, record, view = fal
|
|
|
113
118
|
return props;
|
|
114
119
|
}
|
|
115
120
|
export function getControlsOptions(fieldConfig, req, type, defaultControlName) {
|
|
121
|
+
if (!isObject(fieldConfig))
|
|
122
|
+
throw `Type error: fieldConfig is object`;
|
|
116
123
|
const fieldOptions = fieldConfig?.options;
|
|
117
124
|
let control = getControl(req, type, fieldOptions?.name, defaultControlName);
|
|
118
125
|
let editorName = control.getName();
|
|
@@ -190,6 +197,8 @@ function setAssociationValues(field, value) {
|
|
|
190
197
|
let options = [];
|
|
191
198
|
let initValue = [];
|
|
192
199
|
const config = field.config;
|
|
200
|
+
if (!isObject(config))
|
|
201
|
+
throw `Type error: config is object`;
|
|
193
202
|
const isOptionSelected = (option, value) => {
|
|
194
203
|
if (Array.isArray(value)) {
|
|
195
204
|
return value.includes(option);
|
|
@@ -198,8 +207,8 @@ function setAssociationValues(field, value) {
|
|
|
198
207
|
return (option == value);
|
|
199
208
|
}
|
|
200
209
|
};
|
|
201
|
-
const getAssociationValue = (value,
|
|
202
|
-
const displayField =
|
|
210
|
+
const getAssociationValue = (value, field) => {
|
|
211
|
+
const displayField = field.modelConfig?.titleField || 'id';
|
|
203
212
|
if (value === null)
|
|
204
213
|
return [];
|
|
205
214
|
if (Array.isArray(value)) {
|
|
@@ -212,13 +221,24 @@ function setAssociationValues(field, value) {
|
|
|
212
221
|
return String(value);
|
|
213
222
|
};
|
|
214
223
|
for (let opt of config.records) {
|
|
224
|
+
const optAny = opt;
|
|
225
|
+
const displayField = typeof field.modelConfig.titleField !== 'undefined'
|
|
226
|
+
? field.modelConfig.titleField
|
|
227
|
+
: typeof optAny.title !== 'undefined'
|
|
228
|
+
? 'title'
|
|
229
|
+
: typeof optAny.name !== 'undefined'
|
|
230
|
+
? 'name'
|
|
231
|
+
: config.identifierField;
|
|
232
|
+
const label = typeof config.displayModifier === 'function'
|
|
233
|
+
? config.displayModifier(opt)
|
|
234
|
+
: optAny[displayField];
|
|
215
235
|
options.push({
|
|
216
|
-
label
|
|
217
|
-
|
|
218
|
-
: (config.displayField ? opt[config.displayField] : opt[config.identifierField]),
|
|
219
|
-
value: opt[config.identifierField],
|
|
236
|
+
label,
|
|
237
|
+
value: optAny[config.identifierField],
|
|
220
238
|
});
|
|
221
|
-
if (
|
|
239
|
+
if (!isObject(config))
|
|
240
|
+
throw `Type error: config is object`;
|
|
241
|
+
if (config.identifierField && isOptionSelected(opt[config.identifierField], getAssociationValue(value, field))) {
|
|
222
242
|
initValue.push(opt[config.identifierField]);
|
|
223
243
|
}
|
|
224
244
|
}
|
|
@@ -9,6 +9,8 @@ export default function inertiaFormHelper(req, postLink, formData) {
|
|
|
9
9
|
};
|
|
10
10
|
for (const key of Object.keys(formData)) {
|
|
11
11
|
let field = formData[key];
|
|
12
|
+
if (!!field.visible === false)
|
|
13
|
+
continue;
|
|
12
14
|
const type = (field.type || field.type).toLowerCase();
|
|
13
15
|
const isIn = field.isIn ?? [];
|
|
14
16
|
let label = field.title ?? '';
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { GroupAP } from "models/GroupAP";
|
|
2
|
+
import { UserAP } from "models/UserAP";
|
|
1
3
|
import { AccessRightsToken, Entity, PropsField } from "../interfaces/types";
|
|
2
4
|
interface groupedTokens {
|
|
3
5
|
header: string;
|
|
@@ -20,7 +22,7 @@ interface listProps extends Record<string | number | symbol, unknown> {
|
|
|
20
22
|
users: PropsField[];
|
|
21
23
|
groupedTokens: groupedTokens[];
|
|
22
24
|
}
|
|
23
|
-
export declare function inertiaGroupHelper(entity: Entity, req: ReqType, users:
|
|
25
|
+
export declare function inertiaGroupHelper(entity: Entity, req: ReqType, users: UserAP[], groupedTokens: {
|
|
24
26
|
[key: string]: AccessRightsToken[];
|
|
25
|
-
}, group?:
|
|
27
|
+
}, group?: GroupAP, view?: boolean): listProps;
|
|
26
28
|
export {};
|
|
@@ -55,7 +55,7 @@ export function inertiaGroupHelper(entity, req, users, groupedTokens, group, vie
|
|
|
55
55
|
label: token.name,
|
|
56
56
|
tooltip: token.description,
|
|
57
57
|
name: `token-checkbox-${token.id}`,
|
|
58
|
-
value: group ? (group.tokens && group.tokens
|
|
58
|
+
value: group ? (group.tokens && group.tokens?.includes(token.id)) : false,
|
|
59
59
|
type: 'checkbox'
|
|
60
60
|
});
|
|
61
61
|
}
|
|
@@ -24,22 +24,22 @@ export function inertiaListHelper(entity, req, fields) {
|
|
|
24
24
|
searchBtn: req.i18n.__('Search'),
|
|
25
25
|
resetBtn: req.i18n.__('Reset'),
|
|
26
26
|
};
|
|
27
|
-
if (entity.config.add && req.adminizer.accessRightsHelper.hasPermission(`create-${entity.name}-model`, req.
|
|
27
|
+
if (entity.config.add && req.adminizer.accessRightsHelper.hasPermission(`create-${entity.name}-model`, req.user)) {
|
|
28
28
|
props.crudActions.createTitle = req.i18n.__('create');
|
|
29
29
|
}
|
|
30
|
-
if (req.adminizer.accessRightsHelper.hasPermission(`update-${entity.name}-model`, req.
|
|
30
|
+
if (req.adminizer.accessRightsHelper.hasPermission(`update-${entity.name}-model`, req.user)) {
|
|
31
31
|
props.crudActions.editTitle = req.i18n.__('Edit');
|
|
32
32
|
}
|
|
33
|
-
if (req.adminizer.accessRightsHelper.hasPermission(`read-${entity.name}-model`, req.
|
|
33
|
+
if (req.adminizer.accessRightsHelper.hasPermission(`read-${entity.name}-model`, req.user)) {
|
|
34
34
|
props.crudActions.viewsTitle = req.i18n.__('View');
|
|
35
35
|
}
|
|
36
|
-
if (req.adminizer.accessRightsHelper.hasPermission(`delete-${entity.name}-model`, req.
|
|
36
|
+
if (req.adminizer.accessRightsHelper.hasPermission(`delete-${entity.name}-model`, req.user)) {
|
|
37
37
|
props.crudActions.deleteTitle = req.i18n.__('Delete');
|
|
38
38
|
}
|
|
39
39
|
props.actions = inertiaActionsHelper(actionType, entity, req);
|
|
40
40
|
if (req.adminizer.menuHelper.hasInlineActions(entity.config, 'list')) {
|
|
41
41
|
for (const inlineAction of req.adminizer.menuHelper.getInlineActions(entity.config, 'list')) {
|
|
42
|
-
if (req.adminizer.accessRightsHelper.hasPermission(inlineAction.accessRightsToken, req.
|
|
42
|
+
if (req.adminizer.accessRightsHelper.hasPermission(inlineAction.accessRightsToken, req.user)) {
|
|
43
43
|
props.inlineActions.push({
|
|
44
44
|
icon: inlineAction.icon,
|
|
45
45
|
id: inlineAction.id,
|
|
@@ -5,7 +5,7 @@ export class InertiaMenuHelper {
|
|
|
5
5
|
}
|
|
6
6
|
getMenuItems(req) {
|
|
7
7
|
let menu = [];
|
|
8
|
-
for (const menuItem of this.adminizer.menuHelper.getMenuItems()) {
|
|
8
|
+
for (const menuItem of this.adminizer.menuHelper.getMenuItems(req.user)) {
|
|
9
9
|
const menuItemTokens = menuItem.actions ? menuItem.actions.map(item => {
|
|
10
10
|
return item.accessRightsToken;
|
|
11
11
|
}).filter(item => {
|
|
@@ -13,7 +13,7 @@ export class InertiaMenuHelper {
|
|
|
13
13
|
}) : [];
|
|
14
14
|
if (menuItem.accessRightsToken)
|
|
15
15
|
menuItemTokens.push(menuItem.accessRightsToken);
|
|
16
|
-
if (this.adminizer.accessRightsHelper.enoughPermissions(menuItemTokens, req.
|
|
16
|
+
if (this.adminizer.accessRightsHelper.enoughPermissions(menuItemTokens, req.user)) {
|
|
17
17
|
menu.push(menuItem);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { GroupAP } from "models/GroupAP";
|
|
2
|
+
import { UserAP } from "models/UserAP";
|
|
1
3
|
import { Entity, PropsField } from "../interfaces/types";
|
|
2
4
|
interface listProps extends Record<string | number | symbol, unknown> {
|
|
3
5
|
edit: boolean;
|
|
@@ -16,6 +18,10 @@ interface listProps extends Record<string | number | symbol, unknown> {
|
|
|
16
18
|
fields: PropsField[];
|
|
17
19
|
groups: PropsField[];
|
|
18
20
|
locales: Record<string, string>[];
|
|
21
|
+
userPretend: {
|
|
22
|
+
label: string;
|
|
23
|
+
postLink: string;
|
|
24
|
+
};
|
|
19
25
|
}
|
|
20
|
-
export declare function inertiaUserHelper(entity: Entity, req: ReqType, groups:
|
|
26
|
+
export declare function inertiaUserHelper(entity: Entity, req: ReqType, groups: GroupAP[], user?: UserAP, view?: boolean): listProps;
|
|
21
27
|
export {};
|
|
@@ -6,6 +6,10 @@ export function inertiaUserHelper(entity, req, groups, user, view = false) {
|
|
|
6
6
|
title: req.i18n.__('Back'),
|
|
7
7
|
link: entity.uri
|
|
8
8
|
},
|
|
9
|
+
userPretend: {
|
|
10
|
+
label: req.i18n.__('Pretend to be a user'),
|
|
11
|
+
postLink: `${req.adminizer.config.routePrefix}/model/userap/login`
|
|
12
|
+
},
|
|
9
13
|
passwordError: req.i18n.__('Values in "password" and "repeatPassword" fields should be the same'),
|
|
10
14
|
btnSave: {
|
|
11
15
|
title: req.i18n.__('Save')
|
|
@@ -58,7 +62,7 @@ export function inertiaUserHelper(entity, req, groups, user, view = false) {
|
|
|
58
62
|
value: user?.locale ?? ''
|
|
59
63
|
});
|
|
60
64
|
}
|
|
61
|
-
if (req.
|
|
65
|
+
if (req.user.isAdministrator) {
|
|
62
66
|
props.fields.push({
|
|
63
67
|
label: req.i18n.__('Profile expires'),
|
|
64
68
|
type: 'date',
|
package/helpers/menuHelper.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @constructor
|
|
5
5
|
*/
|
|
6
|
+
import { UserAP } from "models/UserAP";
|
|
6
7
|
import { ActionType, AdminpanelConfig, HrefConfig, ModelConfig } from "../interfaces/adminpanelConfig";
|
|
7
8
|
export type MenuItem = {
|
|
8
9
|
link: string;
|
|
@@ -15,14 +16,14 @@ export type MenuItem = {
|
|
|
15
16
|
entityName?: string;
|
|
16
17
|
};
|
|
17
18
|
export declare class MenuHelper {
|
|
18
|
-
private
|
|
19
|
+
private config;
|
|
19
20
|
constructor(config: AdminpanelConfig);
|
|
20
21
|
/**
|
|
21
22
|
* Get menu brand title
|
|
22
23
|
*
|
|
23
24
|
* @returns {string}
|
|
24
25
|
*/
|
|
25
|
-
getBrandTitle():
|
|
26
|
+
getBrandTitle(): string;
|
|
26
27
|
/**
|
|
27
28
|
* Check if global actions buttons added to action
|
|
28
29
|
*
|
|
@@ -60,5 +61,5 @@ export declare class MenuHelper {
|
|
|
60
61
|
*
|
|
61
62
|
* @returns {Array}
|
|
62
63
|
*/
|
|
63
|
-
getMenuItems(): MenuItem[];
|
|
64
|
+
getMenuItems(user: UserAP): MenuItem[];
|
|
64
65
|
}
|
package/helpers/menuHelper.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { GroupsAccessRightsHelper } from "./accessRightsHelper";
|
|
1
2
|
export class MenuHelper {
|
|
2
|
-
|
|
3
|
+
config;
|
|
3
4
|
constructor(config) {
|
|
4
|
-
|
|
5
|
+
this.config = config;
|
|
5
6
|
}
|
|
6
7
|
/**
|
|
7
8
|
* Get menu brand title
|
|
@@ -9,14 +10,14 @@ export class MenuHelper {
|
|
|
9
10
|
* @returns {string}
|
|
10
11
|
*/
|
|
11
12
|
getBrandTitle() {
|
|
12
|
-
if (!
|
|
13
|
+
if (!this.config.brand || !this.config.brand.link) {
|
|
13
14
|
return 'Adminizer';
|
|
14
15
|
}
|
|
15
|
-
if (typeof
|
|
16
|
-
return
|
|
16
|
+
if (typeof this.config.brand.link === "string") {
|
|
17
|
+
return this.config.brand.link;
|
|
17
18
|
}
|
|
18
|
-
if (typeof
|
|
19
|
-
return
|
|
19
|
+
if (typeof this.config.brand.link === "object" && typeof this.config.brand.link.title === "string") {
|
|
20
|
+
return this.config.brand.link.title;
|
|
20
21
|
}
|
|
21
22
|
return 'Adminizer';
|
|
22
23
|
}
|
|
@@ -98,10 +99,10 @@ export class MenuHelper {
|
|
|
98
99
|
*
|
|
99
100
|
* @returns {Array}
|
|
100
101
|
*/
|
|
101
|
-
getMenuItems() {
|
|
102
|
+
getMenuItems(user) {
|
|
102
103
|
let menus = [];
|
|
103
|
-
if (
|
|
104
|
-
|
|
104
|
+
if (this.config.navbar.additionalLinks && this.config.navbar.additionalLinks.length > 0) {
|
|
105
|
+
this.config.navbar.additionalLinks.forEach(function (additionalLink) {
|
|
105
106
|
if (!additionalLink.link || !additionalLink.title || additionalLink.disabled) {
|
|
106
107
|
return;
|
|
107
108
|
}
|
|
@@ -116,13 +117,19 @@ export class MenuHelper {
|
|
|
116
117
|
});
|
|
117
118
|
});
|
|
118
119
|
}
|
|
119
|
-
if (
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
if (this.config.models) {
|
|
121
|
+
const _this = this;
|
|
122
|
+
Object.entries(this.config.models).forEach(function ([key, val]) {
|
|
123
|
+
const hide = typeof val.navbar?.visible === 'boolean'
|
|
124
|
+
? !val.navbar.visible
|
|
125
|
+
: val.navbar?.groupsAccessRights
|
|
126
|
+
? !GroupsAccessRightsHelper.hasAccess(user, val.navbar.groupsAccessRights)
|
|
127
|
+
: false;
|
|
128
|
+
if (!hide) {
|
|
122
129
|
if (val.tools && val.tools.length > 0 && val.tools[0].id !== "overview") {
|
|
123
130
|
val.tools.unshift({
|
|
124
131
|
id: "overview",
|
|
125
|
-
link:
|
|
132
|
+
link: _this.config.routePrefix + '/model/' + key,
|
|
126
133
|
title: 'Overview',
|
|
127
134
|
type: 'self',
|
|
128
135
|
icon: "list",
|
|
@@ -130,7 +137,7 @@ export class MenuHelper {
|
|
|
130
137
|
});
|
|
131
138
|
}
|
|
132
139
|
menus.push({
|
|
133
|
-
link:
|
|
140
|
+
link: _this.config.routePrefix + '/model/' + key,
|
|
134
141
|
title: val.title || key,
|
|
135
142
|
icon: val.icon || null,
|
|
136
143
|
actions: val.tools || null,
|
package/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
export * from "./helpers/configHelper";
|
|
2
2
|
export * from "./helpers/accessRightsHelper";
|
|
3
|
-
export * from "./lib/
|
|
4
|
-
export * from "./lib/
|
|
5
|
-
export * from "./lib/catalog/CatalogHandler";
|
|
3
|
+
export * from "./lib/v4/widgets/widgetHandler";
|
|
4
|
+
export * from "./lib/v4/catalog/CatalogHandler";
|
|
6
5
|
export * from "./lib/media-manager/MediaManagerHandler";
|
|
7
6
|
export * from "./interfaces/adminpanelConfig";
|
|
8
7
|
export * from "./lib/v4/model/AbstractModel";
|
|
@@ -10,3 +9,6 @@ export * from "./lib/v4/model/adapter/waterline";
|
|
|
10
9
|
export * from "./lib/v4/model/adapter/typeorm";
|
|
11
10
|
export * from "./lib/v4/model/adapter/sequelize";
|
|
12
11
|
export * from "./lib/Adminizer";
|
|
12
|
+
export * from "./models/GroupAP";
|
|
13
|
+
export * from "./models/UserAP";
|
|
14
|
+
export * from "./models/NavigationAP";
|
package/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
export * from "./helpers/configHelper";
|
|
2
2
|
export * from "./helpers/accessRightsHelper";
|
|
3
|
-
export * from "./lib/
|
|
4
|
-
export * from "./lib/
|
|
5
|
-
export * from "./lib/catalog/CatalogHandler";
|
|
3
|
+
export * from "./lib/v4/widgets/widgetHandler";
|
|
4
|
+
export * from "./lib/v4/catalog/CatalogHandler";
|
|
6
5
|
export * from "./lib/media-manager/MediaManagerHandler";
|
|
7
6
|
export * from "./interfaces/adminpanelConfig";
|
|
8
7
|
export * from "./lib/v4/model/AbstractModel";
|
|
@@ -10,3 +9,9 @@ export * from "./lib/v4/model/adapter/waterline";
|
|
|
10
9
|
export * from "./lib/v4/model/adapter/typeorm";
|
|
11
10
|
export * from "./lib/v4/model/adapter/sequelize";
|
|
12
11
|
export * from "./lib/Adminizer";
|
|
12
|
+
export * from "./models/GroupAP";
|
|
13
|
+
export * from "./models/UserAP";
|
|
14
|
+
// export * from "./models/MediaManagerAP"
|
|
15
|
+
// export * from "./models/MediaManagerAssociationsAP"
|
|
16
|
+
// export * from "./models/MediaManagerMetaAP"
|
|
17
|
+
export * from "./models/NavigationAP";
|