adminizer 4.1.0-commit.d8a06d3 → 4.1.1
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 +46 -0
- package/assets/{VanillaJSONEditor-D-Lx670g.js → VanillaJSONEditor-DfRefswH.js} +104 -104
- package/assets/add-CJ1-zeA1.js +1 -0
- package/assets/add-form-CbNl0wdS.js +1 -0
- package/assets/add-group-form-Bt_Dx9wm.js +1 -0
- package/assets/add-group-pIFJV5qL.js +1 -0
- package/assets/add-user-D2US8hL_.js +1 -0
- package/assets/add-user-form-Bt8Jy6S2.js +1 -0
- package/assets/{app-WTooYWC3.css → app-B6cCPfWk.css} +1 -1
- package/assets/app-layout-B86jl9bH.js +1 -0
- package/assets/app-shell-CiGyzQ0C.js +1 -0
- package/assets/app-sidebar-Bz-SRwBg.js +1 -0
- package/assets/app-sidebar-header-7CNCx7Rs.js +11 -0
- package/assets/app.js +45 -37
- package/assets/breadcrumbs-_jhtTcOi.js +1 -0
- package/assets/catalog-CON6moaA.js +16 -0
- package/assets/catalog-Cc6Mk9sX.css +1 -0
- package/assets/checkbox-CQdZw5mb.js +1 -0
- package/assets/dashboard-es9ZT8qk.js +3 -0
- package/assets/{date-picker-DI1cCO7K.js → date-picker-Dz-d-YWX.js} +2 -2
- package/assets/debounce-qdyXyOeG.js +1 -0
- package/assets/del-modal-D0mrZvki.js +11 -0
- package/assets/dialog-stack-BiMbfm58.js +1 -0
- package/assets/dropdown-menu-BSBcRiXx.js +1 -0
- package/assets/{field-renderer-DVHZF6HS.js → field-renderer-B6hFAeiU.js} +3 -3
- package/assets/form-Buslty7y.js +1 -0
- package/assets/form-aqiRmPix.js +1 -0
- package/assets/{geo-json-BjiyTtMu.js → geo-json-BKmYmu3d.js} +2 -2
- package/assets/{handsontable-4mjU_b0n.js → handsontable-B8xVeMAQ.js} +5 -5
- package/assets/home-Dr72Jk-w.js +2 -0
- package/assets/icon-B-a7xg54.js +1 -0
- package/assets/index-B68_akQe.js +1 -0
- package/assets/index-B7-xTDyy.js +1 -0
- package/assets/index-BJFFlCSo.js +1 -0
- package/assets/{index-Cw5o84pO.js → index-BOuMo_nl.js} +3 -3
- package/assets/index-BzOcGsBq.js +1 -0
- package/assets/index-CFbQ2Rv0.js +1 -0
- package/assets/{index-D5ir9iUV.js → index-Cq31rrfZ.js} +1 -1
- package/assets/{index-Cgp8OfuI.js → index-D5UDXTFs.js} +1 -1
- package/assets/index-oxIQWAdI.js +41 -0
- package/assets/init-user-5H689LP0.js +1 -0
- package/assets/input-CSJjrf2i.js +1 -0
- package/assets/input-error-CK92Shhm.js +1 -0
- package/assets/label-Muj0-Efy.js +1 -0
- package/assets/list-Cvh7zbyG.js +1 -0
- package/assets/list-table-Bs_vbQiV.js +52 -0
- package/assets/login-DliJrjMQ.js +6 -0
- package/assets/manifest.json +575 -673
- package/assets/material-icon-BRS58Qpk.js +1 -0
- package/assets/module-CjG21VCT.js +1 -0
- package/assets/{monaco-editor-CJs0_GlD.js → monaco-editor-9fDiyfuW.js} +2 -2
- package/assets/{multi-select-BvRpAW8r.js → multi-select-CMQIJ0JT.js} +2 -2
- package/assets/nav-footer-IGMn9NiE.js +1 -0
- package/assets/nav-main-DBE4rMiZ.js +1 -0
- package/assets/nav-user-CjyLRyq-.js +1 -0
- package/assets/pagination-render-DUAq2klc.js +1 -0
- package/assets/popover-C_cww-4_.js +1 -0
- package/assets/register-UzQn3J0g.js +1 -0
- package/assets/{select-BWepUw-9.js → select-DzBno-dc.js} +2 -2
- package/assets/{sidebar-CAHsHdjM.js → sidebar-Dc4iqfu-.js} +2 -2
- package/assets/skeleton-Dkmj2o2Z.js +1 -0
- package/assets/sonner-De1t71Gj.js +1 -0
- package/assets/{toast-editor-CMK7QtF1.js → toast-editor-1Pul3oMs.js} +2 -2
- package/assets/tooltip-CwPrC-HD.js +1 -0
- package/assets/use-appearance-J8J2w43p.js +1 -0
- package/assets/use-window-size-DLSEoR6e.js +1 -0
- package/assets/{user-info-DFrmpJ4y.js → user-info-8RyDk7qh.js} +2 -2
- package/assets/user-menu-content-CpxTLH56.js +6 -0
- package/assets/welcome-BYKI6yO-.js +1 -0
- package/controllers/add.js +8 -8
- package/controllers/catalog/Catalog.d.ts +1 -1
- package/controllers/catalog/Catalog.js +40 -35
- package/controllers/catalog/FrontentCatalogAdapter.d.ts +36 -26
- package/controllers/catalog/FrontentCatalogAdapter.js +71 -72
- package/controllers/edit.js +8 -11
- package/controllers/list.js +2 -2
- package/controllers/login.js +16 -7
- package/controllers/navigation/edit.js +1 -1
- package/controllers/remove.js +1 -1
- package/controllers/view.js +1 -1
- package/helpers/JsUtils.d.ts +1 -0
- package/helpers/JsUtils.js +3 -0
- package/helpers/accessRightsHelper.d.ts +3 -0
- package/helpers/accessRightsHelper.js +27 -4
- package/helpers/controllerHelper.js +39 -18
- package/helpers/fieldsHelper.d.ts +3 -2
- package/helpers/fieldsHelper.js +5 -1
- package/helpers/inertiaAddHelper.d.ts +4 -5
- package/helpers/inertiaAddHelper.js +25 -7
- package/helpers/inertiaFromHelper.js +1 -1
- package/helpers/inertiaMenuHelper.d.ts +1 -1
- package/helpers/inertiaMenuHelper.js +1 -1
- package/helpers/menuHelper.d.ts +8 -3
- package/helpers/menuHelper.js +26 -17
- package/index.d.ts +2 -6
- package/index.js +5 -6
- package/interfaces/adminpanelConfig.d.ts +35 -30
- package/interfaces/global.d.ts +5 -2
- package/interfaces/types.d.ts +1 -1
- package/lib/Adminizer.d.ts +9 -3
- package/lib/Adminizer.js +32 -16
- package/lib/media-manager/Items.js +0 -3
- package/lib/requestProcessor.js +10 -3
- package/lib/v4/DataAccessor.d.ts +3 -1
- package/lib/v4/DataAccessor.js +43 -18
- package/lib/v4/I18n.js +2 -0
- package/lib/{catalog → v4/catalog}/AbstractCatalog.d.ts +89 -60
- package/lib/{catalog → v4/catalog}/AbstractCatalog.js +59 -54
- 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 -5
- package/lib/v4/model/AbstractModel.d.ts +5 -1
- package/lib/v4/model/AbstractModel.js +2 -1
- package/lib/v4/model/ModelHandler.js +1 -3
- package/lib/v4/model/adapter/sequelize.d.ts +8 -0
- package/lib/v4/model/adapter/sequelize.js +274 -133
- package/lib/v4/model/adapter/waterline.js +5 -2
- package/lib/{widgets → v4/widgets}/abstractLink.d.ts +1 -1
- package/lib/{widgets → v4/widgets}/abstractWidgetBase.d.ts +1 -1
- package/lib/{widgets → v4/widgets}/widgetHandler.d.ts +11 -4
- package/lib/{widgets → v4/widgets}/widgetHandler.js +1 -1
- package/models/NavigationAP.d.ts +2 -3
- package/models/NavigationAP.js +5 -6
- package/models/UserAP.d.ts +2 -3
- package/package.json +17 -6
- package/system/Router.js +8 -11
- package/system/bindAccessRights.js +0 -4
- package/system/bindControls.js +6 -6
- package/system/bindDev.js +1 -0
- package/system/bindInertia.js +9 -4
- package/system/bindMediaManager.js +0 -1
- package/system/bindModels.js +9 -6
- package/system/bindNavigation.d.ts +2 -0
- package/system/bindNavigation.js +42 -42
- package/system/bindReqFunctions.js +0 -1
- package/system/defaults.js +13 -6
- package/translations/ar.json +70 -1
- package/translations/cn.json +70 -1
- package/translations/de.json +71 -3
- package/translations/en.json +70 -102
- package/translations/es.json +70 -1
- package/translations/fr.json +70 -1
- package/translations/hi.json +70 -1
- package/translations/jp.json +70 -1
- package/translations/ko.json +70 -1
- package/translations/pt.json +70 -1
- package/translations/ru.json +71 -103
- package/translations/ua.json +70 -1
- package/translations/uz.json +72 -0
- package/translations/vi.json +70 -1
- package/assets/add-BP_u3Tjl.js +0 -1
- package/assets/add-form-nffmiYTh.js +0 -1
- package/assets/add-group-D4vcHlm-.js +0 -1
- package/assets/add-group-form-gNJW11-q.js +0 -1
- package/assets/add-user-DWh3Nas0.js +0 -1
- package/assets/add-user-form-BJ0FsZYJ.js +0 -1
- package/assets/app-layout-DYsRFUuP.js +0 -1
- package/assets/app-shell-Dd9Eknik.js +0 -1
- package/assets/app-sidebar-BOmu6-Sl.js +0 -1
- package/assets/app-sidebar-header-CoXSzWxk.js +0 -11
- package/assets/breadcrumbs-BmAq4fHT.js +0 -1
- package/assets/button-C9B_5Jf_.js +0 -1
- package/assets/checkbox-Fg27sL_1.js +0 -1
- package/assets/compiler-runtime-hB6dAw2d.js +0 -9
- package/assets/dashboard-BACj996r.js +0 -3
- package/assets/dropdown-menu-Bhj17ENm.js +0 -1
- package/assets/form-BgWdwvz1.js +0 -1
- package/assets/form-DgtErfln.js +0 -1
- package/assets/home-CHntBHJa.js +0 -2
- package/assets/icon-Dt0vBgDO.js +0 -1
- package/assets/index-B8BS9wMC.js +0 -1
- package/assets/index-BC0yfOHo.js +0 -1
- package/assets/index-BKCgnGj_.js +0 -1
- package/assets/index-BbXEMx9n.js +0 -1
- package/assets/index-BykbU6Ee.js +0 -41
- package/assets/index-CaJgc5EZ.js +0 -1
- package/assets/index-DrWfGwtf.js +0 -1
- package/assets/init-user-JfCKJ5Ce.js +0 -1
- package/assets/input-CvRbIbk4.js +0 -1
- package/assets/input-error-DMK7cAt7.js +0 -1
- package/assets/label-CSLFe9Bz.js +0 -1
- package/assets/list-B2Oa5O_Q.js +0 -1
- package/assets/list-table-DA9MhywL.js +0 -62
- package/assets/login-DQwGtdis.js +0 -6
- package/assets/material-icon-BJg8o_fs.js +0 -1
- package/assets/module-DWXp59Vg.js +0 -1
- package/assets/nav-footer-Bs4dmN1d.js +0 -1
- package/assets/nav-main-Bq3IMk4C.js +0 -1
- package/assets/nav-user-CbB22J5O.js +0 -1
- package/assets/pagination-render-DuXDDbC_.js +0 -1
- package/assets/popover-DtoGI2b1.js +0 -1
- package/assets/register-BSogVF0h.js +0 -1
- package/assets/skeleton-COOcAA8f.js +0 -1
- package/assets/sonner-BI0IFOQN.js +0 -1
- package/assets/tooltip-DHwpLKOI.js +0 -1
- package/assets/use-appearance-DRfIqTgw.js +0 -1
- package/assets/use-window-size-h0Sh_NvX.js +0 -1
- package/assets/user-menu-content-DPXQdERj.js +0 -6
- package/assets/utils-DjqsqOe8.js +0 -1
- package/assets/welcome-B4WCIXKf.js +0 -1
- package/controllers/processInstallFinalize.d.ts +0 -1
- package/controllers/processInstallFinalize.js +0 -16
- package/controllers/processInstallStep.d.ts +0 -0
- package/controllers/processInstallStep.js +0 -122
- 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/models/MediaManagerAP.d.ts +0 -62
- package/models/MediaManagerAP.js +0 -45
- package/models/MediaManagerAssociationsAP.d.ts +0 -38
- package/models/MediaManagerAssociationsAP.js +0 -27
- package/models/MediaManagerMetaAP.d.ts +0 -30
- 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/{inertia → v4/inertia}/inertiaAdapter.js +0 -0
- /package/lib/{widgets → v4/widgets}/abstractAction.d.ts +0 -0
- /package/lib/{widgets → v4/widgets}/abstractAction.js +0 -0
- /package/lib/{widgets → v4/widgets}/abstractCustom.d.ts +0 -0
- /package/lib/{widgets → v4/widgets}/abstractCustom.js +0 -0
- /package/lib/{widgets → v4/widgets}/abstractInfo.d.ts +0 -0
- /package/lib/{widgets → v4/widgets}/abstractInfo.js +0 -0
- /package/lib/{widgets → v4/widgets}/abstractLink.js +0 -0
- /package/lib/{widgets → v4/widgets}/abstractSwitch.d.ts +0 -0
- /package/lib/{widgets → v4/widgets}/abstractSwitch.js +0 -0
- /package/lib/{widgets → v4/widgets}/abstractWidgetBase.js +0 -0
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) {
|
|
@@ -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;
|
|
@@ -436,7 +435,7 @@ export declare function getControlsOptions(fieldConfig: BaseFieldConfig, req: Re
|
|
|
436
435
|
};
|
|
437
436
|
path: {};
|
|
438
437
|
};
|
|
439
|
-
export declare function inputText(type: string, isIn: string[]): "email" | "password" | "
|
|
438
|
+
export declare function inputText(type: string, isIn: string[]): "email" | "password" | "number" | "date" | "time" | "color" | "month" | "week" | "range" | "text" | "select" | "datetime-local";
|
|
440
439
|
export declare function getControl(req: ReqType, type: ControlType, name: string | undefined, defaultControlName: string): AbstractControls;
|
|
441
440
|
export declare function setSelectMany(isIn: string[], value: string[] | undefined): {
|
|
442
441
|
initOptions: {
|
|
@@ -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,8 @@ 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`;
|
|
28
31
|
if (!!fieldConfig.visible === false)
|
|
29
32
|
continue;
|
|
30
33
|
const type = (fieldConfig.type || fieldConfig.type).toLowerCase();
|
|
@@ -115,6 +118,8 @@ export default function inertiaAddHelper(req, entity, fields, record, view = fal
|
|
|
115
118
|
return props;
|
|
116
119
|
}
|
|
117
120
|
export function getControlsOptions(fieldConfig, req, type, defaultControlName) {
|
|
121
|
+
if (!isObject(fieldConfig))
|
|
122
|
+
throw `Type error: fieldConfig is object`;
|
|
118
123
|
const fieldOptions = fieldConfig?.options;
|
|
119
124
|
let control = getControl(req, type, fieldOptions?.name, defaultControlName);
|
|
120
125
|
let editorName = control.getName();
|
|
@@ -192,6 +197,8 @@ function setAssociationValues(field, value) {
|
|
|
192
197
|
let options = [];
|
|
193
198
|
let initValue = [];
|
|
194
199
|
const config = field.config;
|
|
200
|
+
if (!isObject(config))
|
|
201
|
+
throw `Type error: config is object`;
|
|
195
202
|
const isOptionSelected = (option, value) => {
|
|
196
203
|
if (Array.isArray(value)) {
|
|
197
204
|
return value.includes(option);
|
|
@@ -200,8 +207,8 @@ function setAssociationValues(field, value) {
|
|
|
200
207
|
return (option == value);
|
|
201
208
|
}
|
|
202
209
|
};
|
|
203
|
-
const getAssociationValue = (value,
|
|
204
|
-
const displayField =
|
|
210
|
+
const getAssociationValue = (value, field) => {
|
|
211
|
+
const displayField = field.modelConfig?.titleField || 'id';
|
|
205
212
|
if (value === null)
|
|
206
213
|
return [];
|
|
207
214
|
if (Array.isArray(value)) {
|
|
@@ -214,13 +221,24 @@ function setAssociationValues(field, value) {
|
|
|
214
221
|
return String(value);
|
|
215
222
|
};
|
|
216
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];
|
|
217
235
|
options.push({
|
|
218
|
-
label
|
|
219
|
-
|
|
220
|
-
: (config.displayField ? opt[config.displayField] : opt[config.identifierField]),
|
|
221
|
-
value: opt[config.identifierField],
|
|
236
|
+
label,
|
|
237
|
+
value: optAny[config.identifierField],
|
|
222
238
|
});
|
|
223
|
-
if (
|
|
239
|
+
if (!isObject(config))
|
|
240
|
+
throw `Type error: config is object`;
|
|
241
|
+
if (config.identifierField && isOptionSelected(opt[config.identifierField], getAssociationValue(value, field))) {
|
|
224
242
|
initValue.push(opt[config.identifierField]);
|
|
225
243
|
}
|
|
226
244
|
}
|
|
@@ -9,7 +9,7 @@ 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)
|
|
12
|
+
if (!!field.visible === false)
|
|
13
13
|
continue;
|
|
14
14
|
const type = (field.type || field.type).toLowerCase();
|
|
15
15
|
const isIn = field.isIn ?? [];
|
|
@@ -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 => {
|
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;
|
|
@@ -13,16 +14,20 @@ export type MenuItem = {
|
|
|
13
14
|
icon: string;
|
|
14
15
|
accessRightsToken: string;
|
|
15
16
|
entityName?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Section grouping for navbar items (side navigation)
|
|
19
|
+
*/
|
|
20
|
+
section?: string;
|
|
16
21
|
};
|
|
17
22
|
export declare class MenuHelper {
|
|
18
|
-
private
|
|
23
|
+
private config;
|
|
19
24
|
constructor(config: AdminpanelConfig);
|
|
20
25
|
/**
|
|
21
26
|
* Get menu brand title
|
|
22
27
|
*
|
|
23
28
|
* @returns {string}
|
|
24
29
|
*/
|
|
25
|
-
getBrandTitle():
|
|
30
|
+
getBrandTitle(): string;
|
|
26
31
|
/**
|
|
27
32
|
* Check if global actions buttons added to action
|
|
28
33
|
*
|
|
@@ -60,5 +65,5 @@ export declare class MenuHelper {
|
|
|
60
65
|
*
|
|
61
66
|
* @returns {Array}
|
|
62
67
|
*/
|
|
63
|
-
getMenuItems(): MenuItem[];
|
|
68
|
+
getMenuItems(user: UserAP): MenuItem[];
|
|
64
69
|
}
|
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
|
}
|
|
@@ -112,17 +113,24 @@ export class MenuHelper {
|
|
|
112
113
|
id: additionalLink.id || additionalLink.title.replace(" ", "_"),
|
|
113
114
|
actions: additionalLink.subItems || null,
|
|
114
115
|
icon: additionalLink.icon || null,
|
|
115
|
-
accessRightsToken: additionalLink.accessRightsToken || null
|
|
116
|
+
accessRightsToken: additionalLink.accessRightsToken || null,
|
|
117
|
+
section: additionalLink.section || 'Platform',
|
|
116
118
|
});
|
|
117
119
|
});
|
|
118
120
|
}
|
|
119
|
-
if (
|
|
120
|
-
|
|
121
|
-
|
|
121
|
+
if (this.config.models) {
|
|
122
|
+
const _this = this;
|
|
123
|
+
Object.entries(this.config.models).forEach(function ([key, val]) {
|
|
124
|
+
const hide = typeof val.navbar?.visible === 'boolean'
|
|
125
|
+
? !val.navbar.visible
|
|
126
|
+
: val.navbar?.groupsAccessRights
|
|
127
|
+
? !GroupsAccessRightsHelper.hasAccess(user, val.navbar.groupsAccessRights)
|
|
128
|
+
: false;
|
|
129
|
+
if (!hide) {
|
|
122
130
|
if (val.tools && val.tools.length > 0 && val.tools[0].id !== "overview") {
|
|
123
131
|
val.tools.unshift({
|
|
124
132
|
id: "overview",
|
|
125
|
-
link:
|
|
133
|
+
link: _this.config.routePrefix + '/model/' + key,
|
|
126
134
|
title: 'Overview',
|
|
127
135
|
type: 'self',
|
|
128
136
|
icon: "list",
|
|
@@ -130,13 +138,14 @@ export class MenuHelper {
|
|
|
130
138
|
});
|
|
131
139
|
}
|
|
132
140
|
menus.push({
|
|
133
|
-
link:
|
|
141
|
+
link: _this.config.routePrefix + '/model/' + key,
|
|
134
142
|
title: val.title || key,
|
|
135
143
|
icon: val.icon || null,
|
|
136
144
|
actions: val.tools || null,
|
|
137
145
|
id: val.title ? val.title.replace(" ", "_") : key,
|
|
138
146
|
entityName: key,
|
|
139
|
-
accessRightsToken: `read-${key}-model
|
|
147
|
+
accessRightsToken: `read-${key}-model`,
|
|
148
|
+
section: val.navbar?.section || 'Platform',
|
|
140
149
|
});
|
|
141
150
|
}
|
|
142
151
|
});
|
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";
|
|
@@ -12,7 +11,4 @@ export * from "./lib/v4/model/adapter/sequelize";
|
|
|
12
11
|
export * from "./lib/Adminizer";
|
|
13
12
|
export * from "./models/GroupAP";
|
|
14
13
|
export * from "./models/UserAP";
|
|
15
|
-
export * from "./models/MediaManagerAP";
|
|
16
|
-
export * from "./models/MediaManagerAssociationsAP";
|
|
17
|
-
export * from "./models/MediaManagerMetaAP";
|
|
18
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";
|
|
@@ -12,7 +11,7 @@ export * from "./lib/v4/model/adapter/sequelize";
|
|
|
12
11
|
export * from "./lib/Adminizer";
|
|
13
12
|
export * from "./models/GroupAP";
|
|
14
13
|
export * from "./models/UserAP";
|
|
15
|
-
export * from "./models/MediaManagerAP"
|
|
16
|
-
export * from "./models/MediaManagerAssociationsAP"
|
|
17
|
-
export * from "./models/MediaManagerMetaAP"
|
|
14
|
+
// export * from "./models/MediaManagerAP"
|
|
15
|
+
// export * from "./models/MediaManagerAssociationsAP"
|
|
16
|
+
// export * from "./models/MediaManagerMetaAP"
|
|
18
17
|
export * from "./models/NavigationAP";
|
|
@@ -30,7 +30,11 @@ export interface AdminpanelConfig {
|
|
|
30
30
|
* by default is false
|
|
31
31
|
*/
|
|
32
32
|
auth?: {
|
|
33
|
+
/** Enable or disable authentication for admin panel */
|
|
33
34
|
enable: boolean;
|
|
35
|
+
/** Enable crypto-puzzle CAPTCHA (default: true) */
|
|
36
|
+
captcha?: boolean;
|
|
37
|
+
/** Description displayed on login page */
|
|
34
38
|
description?: string;
|
|
35
39
|
};
|
|
36
40
|
/**
|
|
@@ -39,7 +43,7 @@ export interface AdminpanelConfig {
|
|
|
39
43
|
* reference upload contoroller ~50 line
|
|
40
44
|
* */
|
|
41
45
|
models: {
|
|
42
|
-
[key: string]: ModelConfig
|
|
46
|
+
[key: string]: ModelConfig;
|
|
43
47
|
};
|
|
44
48
|
/**
|
|
45
49
|
* For custom adminpanel sections, displays inside header
|
|
@@ -123,23 +127,6 @@ export interface AdminpanelConfig {
|
|
|
123
127
|
* */
|
|
124
128
|
set?: SetFunction;
|
|
125
129
|
};
|
|
126
|
-
/**
|
|
127
|
-
* Wizards
|
|
128
|
-
* */
|
|
129
|
-
installStepper?: {
|
|
130
|
-
path: string;
|
|
131
|
-
data: {
|
|
132
|
-
[key: string]: FieldsModels;
|
|
133
|
-
};
|
|
134
|
-
/**
|
|
135
|
-
* Custom getter
|
|
136
|
-
* */
|
|
137
|
-
get?: GetFunction;
|
|
138
|
-
/**
|
|
139
|
-
* Custom setter
|
|
140
|
-
* */
|
|
141
|
-
set?: SetFunction;
|
|
142
|
-
};
|
|
143
130
|
/**
|
|
144
131
|
* Prime administrator login credentials
|
|
145
132
|
* */
|
|
@@ -180,12 +167,6 @@ export interface AdminpanelConfig {
|
|
|
180
167
|
* Navigation
|
|
181
168
|
*/
|
|
182
169
|
navigation?: NavigationConfig;
|
|
183
|
-
/**
|
|
184
|
-
* Path to modules views
|
|
185
|
-
*/
|
|
186
|
-
modulesViewsPath?: string;
|
|
187
|
-
/** @deprecated (module manager can be used it somehow) */
|
|
188
|
-
templateRootPath?: string;
|
|
189
170
|
mediamanager?: MediaManagerConfig;
|
|
190
171
|
/** System settings */
|
|
191
172
|
system?: {
|
|
@@ -201,9 +182,23 @@ export interface ModelConfig {
|
|
|
201
182
|
* */
|
|
202
183
|
model: string;
|
|
203
184
|
/**
|
|
204
|
-
*
|
|
185
|
+
* If the field is not definitely, then it will appear in Navbar
|
|
205
186
|
* */
|
|
206
|
-
|
|
187
|
+
navbar?: {
|
|
188
|
+
/**
|
|
189
|
+
* @default true
|
|
190
|
+
*/
|
|
191
|
+
visible?: boolean;
|
|
192
|
+
/**
|
|
193
|
+
* User groups who will see the menu item
|
|
194
|
+
* For which it will be shown if not established will be shown to all groups who have the rights to read
|
|
195
|
+
*/
|
|
196
|
+
groupsAccessRights?: string[];
|
|
197
|
+
/**
|
|
198
|
+
* Optional section grouping for navbar items (side navigation)
|
|
199
|
+
*/
|
|
200
|
+
section?: string;
|
|
201
|
+
};
|
|
207
202
|
/**
|
|
208
203
|
* Entity fields configuration
|
|
209
204
|
* */
|
|
@@ -230,7 +225,7 @@ export interface ModelConfig {
|
|
|
230
225
|
filter?: {
|
|
231
226
|
[key: string]: {
|
|
232
227
|
name: string;
|
|
233
|
-
criteria: any
|
|
228
|
+
criteria: Record<string, any>;
|
|
234
229
|
};
|
|
235
230
|
};
|
|
236
231
|
} | boolean;
|
|
@@ -258,6 +253,11 @@ export interface ModelConfig {
|
|
|
258
253
|
* Entity icon
|
|
259
254
|
* */
|
|
260
255
|
icon?: MaterialIcon;
|
|
256
|
+
/**
|
|
257
|
+
* The field that will be shown for communication
|
|
258
|
+
* @default `title` or `name`
|
|
259
|
+
*/
|
|
260
|
+
titleField?: string;
|
|
261
261
|
/**
|
|
262
262
|
* Force set primary key
|
|
263
263
|
* */
|
|
@@ -266,7 +266,7 @@ export interface ModelConfig {
|
|
|
266
266
|
* May be association or association-many to UserAP or GroupAP */
|
|
267
267
|
userAccessRelation?: {
|
|
268
268
|
field: string;
|
|
269
|
-
via
|
|
269
|
+
via?: string;
|
|
270
270
|
} | string;
|
|
271
271
|
userAccessRelationCallback?: (userWithGroups: UserWithGroups, record: any) => boolean;
|
|
272
272
|
}
|
|
@@ -308,6 +308,7 @@ export interface BaseFieldConfig {
|
|
|
308
308
|
identifierField?: string;
|
|
309
309
|
/**
|
|
310
310
|
* Label for associations
|
|
311
|
+
* @deprecated use model labelField prop
|
|
311
312
|
* */
|
|
312
313
|
displayField?: string;
|
|
313
314
|
/**
|
|
@@ -407,11 +408,15 @@ export interface HrefConfig {
|
|
|
407
408
|
/**
|
|
408
409
|
* Only for view, controller still uses his own access rights token
|
|
409
410
|
* */
|
|
410
|
-
accessRightsToken?: string;
|
|
411
|
+
accessRightsToken?: string | undefined;
|
|
411
412
|
/**
|
|
412
413
|
* For menu items only
|
|
413
414
|
* */
|
|
414
415
|
subItems?: HrefConfig[];
|
|
416
|
+
/**
|
|
417
|
+
* Optional section grouping for navbar items (side navigation)
|
|
418
|
+
*/
|
|
419
|
+
section?: string;
|
|
415
420
|
}
|
|
416
421
|
export interface NavigationItemTypeConfig {
|
|
417
422
|
model: string;
|
|
@@ -430,7 +435,7 @@ export interface NavigationConfig {
|
|
|
430
435
|
}[];
|
|
431
436
|
allowContentInGroup?: boolean;
|
|
432
437
|
items: NavigationItemTypeConfig[];
|
|
433
|
-
movingGroupsRootOnly
|
|
438
|
+
movingGroupsRootOnly?: boolean;
|
|
434
439
|
}
|
|
435
440
|
export interface MediaManagerConfig {
|
|
436
441
|
allowMIME?: string[];
|
package/interfaces/global.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { Adminizer } from "../lib/Adminizer";
|
|
|
2
2
|
import { NextFunction, Request, Response } from "express";
|
|
3
3
|
import multer from "multer";
|
|
4
4
|
import { I18n } from "../lib/v4/I18n";
|
|
5
|
-
import { Inertia } from "../lib/inertia/inertiaAdapter";
|
|
6
|
-
import { Flash } from "../lib/inertia/flash";
|
|
5
|
+
import { Inertia } from "../lib/v4/inertia/inertiaAdapter";
|
|
6
|
+
import { Flash } from "../lib/v4/inertia/flash";
|
|
7
7
|
import { UserAP } from "models/UserAP";
|
|
8
8
|
declare global {
|
|
9
9
|
/** @deprecated use import from TS model decalration */
|
|
@@ -75,6 +75,9 @@ declare global {
|
|
|
75
75
|
i18n: I18n;
|
|
76
76
|
};
|
|
77
77
|
type ResType = Response & {
|
|
78
|
+
/**
|
|
79
|
+
* @deprecated // TODO delete after finish catalog
|
|
80
|
+
*/
|
|
78
81
|
viewAdmin(specifiedPath: string, locals?: any, cb_view?: Function): void;
|
|
79
82
|
};
|
|
80
83
|
type MiddlewareType = (req: ReqType, res: ResType, next: NextFunction) => void;
|
package/interfaces/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbstractModel } from "../lib/v4/model/AbstractModel";
|
|
2
2
|
import { ModelConfig } from "./adminpanelConfig";
|
|
3
|
-
export type EntityType = "form" | "model"
|
|
3
|
+
export type EntityType = "form" | "model";
|
|
4
4
|
export interface Entity {
|
|
5
5
|
name: string;
|
|
6
6
|
config?: ModelConfig;
|
package/lib/Adminizer.d.ts
CHANGED
|
@@ -4,14 +4,19 @@ import EventEmitter from 'events';
|
|
|
4
4
|
import { AdminpanelConfig } from "../interfaces/adminpanelConfig";
|
|
5
5
|
import PolicyManager from "./v4/PolicyManager";
|
|
6
6
|
import { ModelHandler } from "./v4/model/ModelHandler";
|
|
7
|
-
import { WidgetHandler } from "./widgets/widgetHandler";
|
|
7
|
+
import { WidgetHandler } from "./v4/widgets/widgetHandler";
|
|
8
8
|
import { AccessRightsHelper } from "../helpers/accessRightsHelper";
|
|
9
9
|
import { ConfigHelper } from "../helpers/configHelper";
|
|
10
10
|
import { AbstractAdapter } from "./v4/model/AbstractModel";
|
|
11
|
-
import { ViteDevServer } from 'vite';
|
|
11
|
+
import type { ViteDevServer } from 'vite';
|
|
12
12
|
import { MenuHelper } from "../helpers/menuHelper";
|
|
13
|
-
import { ControlsHandler } from "./controls/ControlsHandler";
|
|
13
|
+
import { ControlsHandler } from "./v4/controls/ControlsHandler";
|
|
14
14
|
export declare class Adminizer {
|
|
15
|
+
/**
|
|
16
|
+
* If you convey this default Middleware, it will add it to the very top of the router,
|
|
17
|
+
* and will contact each request
|
|
18
|
+
*/
|
|
19
|
+
defaultMiddleware: MiddlewareType;
|
|
15
20
|
app: Express;
|
|
16
21
|
config: AdminpanelConfig;
|
|
17
22
|
private readonly _emitter;
|
|
@@ -44,4 +49,5 @@ export declare class Adminizer {
|
|
|
44
49
|
verbose: (...args: any[]) => winston.Logger;
|
|
45
50
|
silly: (...args: any[]) => winston.Logger;
|
|
46
51
|
};
|
|
52
|
+
get defaultConfig(): AdminpanelConfig;
|
|
47
53
|
}
|