adminizer 4.6.0 → 4.7.0-build.221
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 +12 -0
- package/assets/RelationDialogStack-CnHFOYyR.css +1 -0
- package/assets/RelationDialogStack-DI2bZxQX.js +20 -0
- package/assets/add-4213XScp.js +1 -0
- package/assets/add-group--F1XxfJ1.js +1 -0
- package/assets/add-group-form-DKRXC2n-.js +1 -0
- package/assets/add-user-b9HfMq7z.js +1 -0
- package/assets/add-user-form-UXAToWQd.js +1 -0
- package/assets/app-Clx8f5hd.css +1 -0
- package/assets/app-layout-C02ja4OI.js +1 -0
- package/assets/app-shell-D8wtkECO.js +1 -0
- package/assets/app-sidebar-BR5_zwxj.js +1 -0
- package/assets/app-sidebar-header-BZbIBQjq.js +1 -0
- package/assets/app.js +59 -7990
- package/assets/breadcrumbs-CODaqVkB.js +1 -0
- package/assets/catalog-6ZZjWdFs.js +6 -0
- package/assets/dashboard-CftAdKiH.js +3 -0
- package/assets/date-picker-DSOkNiNo.js +1 -0
- package/assets/del-modal-Cd4M7af8.js +1 -0
- package/assets/dynamic-controls-BsrJhPDY.js +1 -0
- package/assets/geo-json-CzR5JBXL.js +1 -0
- package/assets/handsontable-BI98OF5R.js +336 -0
- package/assets/history-DLHSU7Ak.js +1 -0
- package/assets/home-NcQ7nnU0.js +2 -0
- package/assets/icon-C2JNaLxH.js +1 -0
- package/assets/init-user-D2HSyXup.js +1 -0
- package/assets/input-error-CH2caTtO.js +1 -0
- package/assets/jsoneditor-DVNQmA6G.js +3869 -0
- package/assets/list-CFU0-TgN.js +4 -0
- package/assets/login-DFSLEO17.js +1 -0
- package/assets/manifest.json +246 -273
- package/assets/material-icon-Bx9pGQiQ.js +1 -0
- package/assets/media-manager-WcKe1EvD.js +6 -0
- package/assets/module-CT7PC6pc.js +1 -0
- package/assets/monaco-Bl4zdWCn.js +11 -0
- package/assets/nav-footer-BiSQkPt4.js +1 -0
- package/assets/nav-main-rTH0PfDw.js +1 -0
- package/assets/nav-user-Bj6cWs0a.js +1 -0
- package/assets/notification-Bi-PX87D.js +20 -0
- package/assets/pagination-render-AKJvTIRA.js +1 -0
- package/assets/register-BTP4uxsK.js +1 -0
- package/assets/ru-eW0WKkga.js +1 -0
- package/assets/theme-switcher-Dm8EOGzx.js +1 -0
- package/assets/toast-editor-DOg_gvSp.js +668 -0
- package/assets/user-filters-list-YUfR4XMI.js +1 -0
- package/assets/user-info-BgSbT02v.js +1 -0
- package/assets/user-menu-content-TQTXHIv6.js +1 -0
- package/assets/{vanilla-picker-l5rcX3cq.js → vanilla-picker-B3LgXoKV.js} +1 -7
- package/assets/welcome-vLwTu1R6.js +1 -0
- package/controllers/add.d.ts +1 -1
- package/controllers/add.js +20 -26
- package/controllers/addGroup.d.ts +1 -1
- package/controllers/addGroup.js +7 -15
- package/controllers/addUser.d.ts +1 -1
- package/controllers/addUser.js +10 -16
- package/controllers/catalog/Catalog.d.ts +1 -1
- package/controllers/catalog/Catalog.js +1 -10
- package/controllers/catalog/FrontendCatalogAdapter.d.ts +3 -3
- package/controllers/catalog/FrontendCatalogAdapter.js +0 -6
- package/controllers/catalog/FrontentCatalogAdapter.d.ts +3 -3
- package/controllers/catalog/FrontentCatalogAdapter.js +0 -4
- package/controllers/ckeditorUpload.js +2 -18
- package/controllers/dashboard.d.ts +1 -1
- package/controllers/dashboard.js +2 -5
- package/controllers/edit.js +24 -37
- package/controllers/editGroup.d.ts +1 -1
- package/controllers/editGroup.js +10 -21
- package/controllers/editUser.d.ts +1 -1
- package/controllers/editUser.js +11 -23
- package/controllers/exportData.d.ts +6 -0
- package/controllers/exportData.js +315 -0
- package/controllers/feed.d.ts +6 -0
- package/controllers/feed.js +73 -0
- package/controllers/feedback/feedbackController.d.ts +1 -1
- package/controllers/feedback/feedbackController.js +5 -7
- package/controllers/filter-fields/columns.d.ts +11 -0
- package/controllers/filter-fields/columns.js +106 -0
- package/controllers/filter-fields/filterFields.d.ts +10 -0
- package/controllers/filter-fields/filterFields.js +141 -0
- package/controllers/filter-fields/getAllUserFilters.d.ts +6 -0
- package/controllers/filter-fields/getAllUserFilters.js +115 -0
- package/controllers/filter-fields/groups.d.ts +5 -0
- package/controllers/filter-fields/groups.js +26 -0
- package/controllers/filter-fields/savedFilters.d.ts +25 -0
- package/controllers/filter-fields/savedFilters.js +317 -0
- package/controllers/getAllWidgets.d.ts +1 -1
- package/controllers/getAllWidgets.js +1 -9
- package/controllers/history-actions/HistoryController.js +6 -31
- package/controllers/initUser.js +6 -5
- package/controllers/inlineUpdate.d.ts +7 -0
- package/controllers/inlineUpdate.js +148 -0
- package/controllers/list.d.ts +1 -1
- package/controllers/list.js +383 -70
- package/controllers/listUserFilters.d.ts +5 -0
- package/controllers/listUserFilters.js +26 -0
- package/controllers/login.js +2 -2
- package/controllers/media-manager/mediaManagerApi.js +0 -9
- package/controllers/navigation/edit.js +3 -9
- package/controllers/notifications/NotificationController.d.ts +1 -1
- package/controllers/notifications/NotificationController.js +12 -36
- package/controllers/register.js +10 -9
- package/controllers/remove.js +10 -19
- package/controllers/timezones.d.ts +1 -1
- package/controllers/timezones.js +0 -6
- package/controllers/userApiKey.d.ts +7 -0
- package/controllers/userApiKey.js +36 -0
- package/controllers/view.js +14 -26
- package/controllers/welcome.d.ts +1 -1
- package/controllers/welcome.js +0 -4
- package/controllers/widgets/Action.d.ts +1 -1
- package/controllers/widgets/Action.js +1 -9
- package/controllers/widgets/Custom.d.ts +1 -1
- package/controllers/widgets/Custom.js +1 -9
- package/controllers/widgets/Info.d.ts +1 -1
- package/controllers/widgets/Info.js +1 -9
- package/controllers/widgets/filterInfo.d.ts +1 -0
- package/controllers/widgets/filterInfo.js +44 -0
- package/controllers/widgets/switch.d.ts +1 -1
- package/controllers/widgets/switch.js +1 -9
- package/controllers/widgetsDB.d.ts +1 -1
- package/controllers/widgetsDB.js +2 -8
- package/helpers/accessRightsHelper.d.ts +1 -1
- package/helpers/accessRightsHelper.js +5 -4
- package/helpers/apiKeyHelper.d.ts +5 -0
- package/helpers/apiKeyHelper.js +8 -0
- package/helpers/configHelper.js +12 -15
- package/helpers/controllerHelper.d.ts +14 -21
- package/helpers/controllerHelper.js +50 -83
- package/helpers/fieldsHelper.js +3 -3
- package/helpers/filterDatetimeHelper.d.ts +5 -0
- package/helpers/filterDatetimeHelper.js +84 -0
- package/helpers/inertiaActionsHelper.d.ts +2 -2
- package/helpers/inertiaActionsHelper.js +5 -4
- package/helpers/inertiaAddHelper.d.ts +3 -414
- package/helpers/inertiaAddHelper.js +39 -15
- package/helpers/inertiaGroupHelper.d.ts +2 -2
- package/helpers/inertiaGroupHelper.js +3 -3
- package/helpers/inertiaListHelper.d.ts +7 -3
- package/helpers/inertiaListHelper.js +26 -12
- package/helpers/inertiaMenuHelper.d.ts +1 -0
- package/helpers/inertiaMenuHelper.js +15 -3
- package/helpers/inertiaUserHelper.d.ts +3 -2
- package/helpers/inertiaUserHelper.js +7 -3
- package/helpers/menuHelper.d.ts +5 -2
- package/helpers/menuHelper.js +64 -12
- package/helpers/viteHelper.js +1 -2
- package/index.d.ts +6 -2
- package/index.js +6 -2
- package/interfaces/adminpanelConfig.d.ts +126 -39
- package/interfaces/internalModelAccess.d.ts +37 -0
- package/interfaces/internalModelAccess.js +1 -0
- package/interfaces/listQueryBuilder.d.ts +22 -0
- package/interfaces/listQueryBuilder.js +1 -0
- package/interfaces/queryCriteria.d.ts +54 -0
- package/interfaces/queryCriteria.js +1 -0
- package/interfaces/types.d.ts +1 -13
- package/lib/Adminizer.d.ts +4 -2
- package/lib/Adminizer.js +29 -10
- package/lib/DataAccessor.d.ts +8 -5
- package/lib/DataAccessor.js +89 -42
- package/lib/I18n.d.ts +5 -1
- package/lib/I18n.js +45 -19
- package/lib/MiddlewareManager.d.ts +8 -0
- package/lib/MiddlewareManager.js +53 -0
- package/lib/ai-assistant/OpenAiModelService.d.ts +3 -3
- package/lib/ai-assistant/OpenAiModelService.js +23 -24
- package/lib/catalog/Navigation.d.ts +1 -0
- package/lib/catalog/Navigation.js +12 -11
- package/lib/controls/jsoneditor/JsonEditor.d.ts +1 -2
- package/lib/controls/markdown/ToastUiEditor.d.ts +1 -2
- package/lib/feedback/FeedbackHandler.js +2 -2
- package/lib/filters/ConditionValidator.d.ts +107 -0
- package/lib/filters/ConditionValidator.js +483 -0
- package/lib/filters/CustomFilterHandler.d.ts +122 -0
- package/lib/filters/CustomFilterHandler.js +131 -0
- package/lib/filters/FilterCustomFieldHandler.d.ts +2 -0
- package/lib/filters/FilterCustomFieldHandler.js +2 -0
- package/lib/filters/FilterService.d.ts +82 -0
- package/lib/filters/FilterService.js +323 -0
- package/lib/filters/index.d.ts +6 -0
- package/lib/filters/index.js +4 -0
- package/lib/history-actions/AbstractHistoryAdapter.d.ts +5 -4
- package/lib/history-actions/AbstractHistoryAdapter.js +45 -30
- package/lib/history-actions/DefaultHistoryAdapter.d.ts +2 -0
- package/lib/history-actions/DefaultHistoryAdapter.js +12 -6
- package/lib/history-actions/HistoryHandler.js +1 -1
- package/lib/list-query-builder/ListQueryBuilder.d.ts +117 -0
- package/lib/list-query-builder/ListQueryBuilder.js +707 -0
- package/lib/media-manager/AbstractMediaManager.d.ts +9 -8
- package/lib/media-manager/DefaultMediaManager.d.ts +2 -0
- package/lib/media-manager/DefaultMediaManager.js +27 -15
- package/lib/media-manager/Items.d.ts +4 -1
- package/lib/media-manager/Items.js +62 -59
- package/lib/media-manager/MediaManagerHandler.js +1 -1
- package/lib/media-manager/helpers/MediaManagerHelper.d.ts +5 -1
- package/lib/media-manager/helpers/MediaManagerHelper.js +38 -4
- package/lib/model/AbstractModel.d.ts +33 -25
- package/lib/model/AbstractModel.js +54 -2
- package/lib/model/InternalModelAccessFactory.d.ts +18 -0
- package/lib/model/InternalModelAccessFactory.js +82 -0
- package/lib/model/ModelHandler.d.ts +6 -0
- package/lib/model/ModelHandler.js +14 -0
- package/lib/model/adapter/sequelize.d.ts +32 -10
- package/lib/model/adapter/sequelize.js +409 -62
- package/lib/model/adapter/typeorm.d.ts +62 -0
- package/lib/model/adapter/typeorm.js +777 -0
- package/lib/model/internalModelAccessToken.d.ts +1 -0
- package/lib/model/internalModelAccessToken.js +1 -0
- package/lib/model/internalModelRepository.d.ts +3 -0
- package/lib/model/internalModelRepository.js +4 -0
- package/lib/notifications/AbstractNotificationService.d.ts +3 -0
- package/lib/notifications/AbstractNotificationService.js +42 -36
- package/lib/notifications/GeneralNotificationService.js +37 -40
- package/lib/notifications/SystemNotificationService.js +33 -36
- package/lib/requestProcessor.js +0 -3
- package/lib/ui-i18n/getUiTranslations.d.ts +1 -0
- package/lib/ui-i18n/getUiTranslations.js +3 -0
- package/lib/ui-i18n/uiTranslationKeys.d.ts +6 -0
- package/lib/ui-i18n/uiTranslationKeys.js +268 -0
- package/lib/widgets/widgetHandler.d.ts +7 -2
- package/lib/widgets/widgetHandler.js +98 -18
- package/models/FilterAP.d.ts +116 -0
- package/models/FilterAP.js +68 -0
- package/models/FilterColumnAP.d.ts +32 -0
- package/models/FilterColumnAP.js +21 -0
- package/models/GroupAP.d.ts +1 -1
- package/models/HistoryActionsAP.d.ts +3 -3
- package/models/MediaManagerMetaAP.d.ts +1 -1
- package/models/NavigationAP.d.ts +1 -1
- package/models/UserAP.d.ts +6 -1
- package/models/UserAP.js +4 -0
- package/package.json +39 -32
- package/policies/authPolicies.d.ts +12 -0
- package/policies/authPolicies.js +104 -0
- package/policies/permissionResolvers.d.ts +12 -0
- package/policies/permissionResolvers.js +52 -0
- package/services/FeedService.d.ts +70 -0
- package/services/FeedService.js +334 -0
- package/system/Router.d.ts +1 -0
- package/system/Router.js +136 -59
- package/system/bindAccessRights.js +11 -30
- package/system/bindAuthorization.js +18 -18
- package/system/bindCors.js +16 -1
- package/system/bindCustomFilterHandlers.d.ts +2 -0
- package/system/bindCustomFilterHandlers.js +4 -0
- package/system/bindInertia.js +18 -61
- package/system/bindReqFunctions.js +10 -2
- package/system/bindTranslations.js +7 -3
- package/system/buildInternalModelAccess.d.ts +4 -0
- package/system/buildInternalModelAccess.js +59 -0
- package/system/defaults.js +18 -14
- package/system/routePolicies.d.ts +2 -0
- package/system/routePolicies.js +29 -0
- package/translations/en.json +151 -39
- package/translations/ru.json +211 -64
- package/ui/components/handsontable.js +13 -27
- package/ui/components/ui/dialog-stack.js +1 -3
- package/ui/components/ui/popover.js +1 -1
- package/ui/components/ui/sidebar.js +1 -1
- package/assets/RelationDialogStack-D9UVEF9s.js +0 -407
- package/assets/RelationDialogStack-DV8OITPR.css +0 -4
- package/assets/add-BlvzWQKF.js +0 -1
- package/assets/add-group-1Uoq9NWe.js +0 -1
- package/assets/add-group-form-B01gwDGu.js +0 -1
- package/assets/add-user-BQCAsaRy.js +0 -1
- package/assets/add-user-form-Cgwc9JkI.js +0 -1
- package/assets/app-DaOMy1nl.css +0 -72
- package/assets/app-layout-CAm60qoE.js +0 -1
- package/assets/app-shell-QWCtn9ye.js +0 -1
- package/assets/app-sidebar-CfaYbnSy.js +0 -1
- package/assets/app-sidebar-header-BsPFDhZ8.js +0 -1
- package/assets/breadcrumbs-CZZirDj8.js +0 -1
- package/assets/catalog-k5myk7fk.js +0 -6
- package/assets/dashboard-BkL9ybBw.js +0 -3
- package/assets/date-picker-B5AZ_7Q9.js +0 -1
- package/assets/del-modal-BoyXZloG.js +0 -1
- package/assets/dynamic-controls-k61T9W2P.js +0 -1
- package/assets/form-1WGY0YgG.js +0 -1
- package/assets/form-DJapG3qF.js +0 -1
- package/assets/geo-json-DsMUHo0l.js +0 -4
- package/assets/handsontable-PxYdjN8c.js +0 -298
- package/assets/history-CluyR-yJ.js +0 -1
- package/assets/home-Dug9zBzM.js +0 -2
- package/assets/icon-DfDLMG5f.js +0 -1
- package/assets/init-user-CF80MEnT.js +0 -1
- package/assets/input-error-DuuqFgZa.js +0 -1
- package/assets/jsoneditor-De1FvcYu.js +0 -3882
- package/assets/list-CuexshNt.js +0 -1
- package/assets/list-table-BsEWjTKY.js +0 -22
- package/assets/login-eDemYzN-.js +0 -1
- package/assets/material-icon-DMT8KdmE.js +0 -1
- package/assets/media-manager-DfYa_mT_.js +0 -14
- package/assets/module-Cd4Tm6uq.js +0 -1
- package/assets/monaco-BhBYtg3d.js +0 -11
- package/assets/nav-footer-D3olYxtz.js +0 -1
- package/assets/nav-main-BctqyzeV.js +0 -1
- package/assets/nav-user-Bn1Lt-BZ.js +0 -1
- package/assets/notification-D64qvni-.js +0 -27
- package/assets/pagination-render-DxD78ahJ.js +0 -1
- package/assets/register-349PwYbe.js +0 -1
- package/assets/theme-switcher-DfExsHW2.js +0 -1
- package/assets/toast-editor-ESK5iWPx.js +0 -845
- package/assets/user-info-DtBK5Kh8.js +0 -1
- package/assets/user-menu-content-0XYOCMaA.js +0 -1
- package/assets/welcome-PDp-gUei.js +0 -1
- package/controllers/form.d.ts +0 -1
- package/controllers/form.js +0 -86
- package/helpers/formHelper.d.ts +0 -6
- package/helpers/formHelper.js +0 -38
- package/helpers/inertiaFromHelper.d.ts +0 -11
- package/helpers/inertiaFromHelper.js +0 -98
- package/helpers/runtimeMode.d.ts +0 -1
- package/helpers/runtimeMode.js +0 -3
- package/lib/PolicyManager.d.ts +0 -8
- package/lib/PolicyManager.js +0 -53
- package/lib/datatable/NodeTable.d.ts +0 -49
- package/lib/datatable/NodeTable.js +0 -207
- package/lib/model/adapter/waterline.d.ts +0 -32
- package/lib/model/adapter/waterline.js +0 -180
- package/migrations/index.d.ts +0 -3
- package/migrations/index.js +0 -4
- package/migrations/knex/20250106000001_adminizer_init.d.ts +0 -8
- package/migrations/knex/20250106000001_adminizer_init.js +0 -164
- package/migrations/umzug/0001.d.ts +0 -7
- package/migrations/umzug/0001.js +0 -121
- package/migrations/umzugExports.d.ts +0 -2
- package/migrations/umzugExports.js +0 -9
- package/system/bindForms.d.ts +0 -2
- package/system/bindForms.js +0 -20
- /package/{policies → middlewares}/addMessages.d.ts +0 -0
- /package/{policies → middlewares}/addMessages.js +0 -0
- /package/{policies → middlewares}/checkAuth.d.ts +0 -0
- /package/{policies → middlewares}/checkAuth.js +0 -0
- /package/{policies → middlewares}/setLocale.d.ts +0 -0
- /package/{policies → middlewares}/setLocale.js +0 -0
package/helpers/configHelper.js
CHANGED
|
@@ -36,12 +36,12 @@ export class ConfigHelper {
|
|
|
36
36
|
}
|
|
37
37
|
let config = this.adminizer.config;
|
|
38
38
|
let modelConfig;
|
|
39
|
-
Object.keys(config.models).forEach((
|
|
40
|
-
const model = config.models[
|
|
39
|
+
Object.keys(config.models).forEach((modelResourceName) => {
|
|
40
|
+
const model = config.models[modelResourceName];
|
|
41
41
|
if (typeof model !== "boolean") {
|
|
42
42
|
if (model.model === modelName.toLowerCase()) {
|
|
43
|
-
if (typeof config.models[
|
|
44
|
-
modelConfig = config.models[
|
|
43
|
+
if (typeof config.models[modelResourceName] !== "boolean") {
|
|
44
|
+
modelConfig = config.models[modelResourceName];
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
}
|
|
@@ -119,23 +119,20 @@ export class ConfigHelper {
|
|
|
119
119
|
*/
|
|
120
120
|
static normalizeConfig(config) {
|
|
121
121
|
const defaultConfig = getDefaultConfig();
|
|
122
|
-
const { forms: configForms = {}, ...restConfig } = config;
|
|
123
|
-
const { forms: defaultForms = {}, } = defaultConfig;
|
|
124
122
|
const mergedConfig = {
|
|
125
123
|
...defaultConfig,
|
|
126
|
-
...
|
|
124
|
+
...config,
|
|
127
125
|
models: {
|
|
128
126
|
...defaultConfig.models,
|
|
129
127
|
...config.models
|
|
130
128
|
},
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
...
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
set: configForms.set ?? defaultForms.set
|
|
129
|
+
navbar: {
|
|
130
|
+
...defaultConfig.navbar,
|
|
131
|
+
...config.navbar,
|
|
132
|
+
additionalLinks: [
|
|
133
|
+
...(defaultConfig.navbar?.additionalLinks || []),
|
|
134
|
+
...(config.navbar?.additionalLinks || [])
|
|
135
|
+
]
|
|
139
136
|
}
|
|
140
137
|
};
|
|
141
138
|
// Normalize auth config if it's a boolean
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ModelResource } from "../interfaces/types";
|
|
2
2
|
import { ActionType, CreateUpdateConfig, ModelConfig } from "../interfaces/adminpanelConfig";
|
|
3
3
|
/**
|
|
4
4
|
* @deprecated need refactor actions
|
|
@@ -6,7 +6,7 @@ import { ActionType, CreateUpdateConfig, ModelConfig } from "../interfaces/admin
|
|
|
6
6
|
type ActionConfig = CreateUpdateConfig;
|
|
7
7
|
export declare class ControllerHelper {
|
|
8
8
|
/**
|
|
9
|
-
* Default configuration for
|
|
9
|
+
* Default configuration for ModelResource
|
|
10
10
|
*
|
|
11
11
|
* @see ControllerHelper.findConfig
|
|
12
12
|
*/
|
|
@@ -18,7 +18,7 @@ export declare class ControllerHelper {
|
|
|
18
18
|
*/
|
|
19
19
|
private static _defaultActionConfig;
|
|
20
20
|
/**
|
|
21
|
-
* Check if given
|
|
21
|
+
* Check if given ModelResource config has all required properties
|
|
22
22
|
*
|
|
23
23
|
* @param {Object} config
|
|
24
24
|
* @returns {boolean}
|
|
@@ -26,11 +26,11 @@ export declare class ControllerHelper {
|
|
|
26
26
|
*/
|
|
27
27
|
private static _isValidModelConfig;
|
|
28
28
|
/**
|
|
29
|
-
* Normalizing
|
|
29
|
+
* Normalizing ModelResource config.
|
|
30
30
|
* Will return fulfilled configuration object.
|
|
31
31
|
*
|
|
32
32
|
* @see ControllerHelper._isValidModelConfig
|
|
33
|
-
* @param
|
|
33
|
+
* @param modelResourceName
|
|
34
34
|
* @param {Object} config
|
|
35
35
|
* @returns {Object}
|
|
36
36
|
* @private
|
|
@@ -45,27 +45,20 @@ export declare class ControllerHelper {
|
|
|
45
45
|
*/
|
|
46
46
|
private static _normalizeActionConfig;
|
|
47
47
|
/**
|
|
48
|
-
* Get
|
|
48
|
+
* Get ModelResource name
|
|
49
49
|
*
|
|
50
50
|
* @param {Request} req
|
|
51
51
|
* @returns {?string}
|
|
52
52
|
*/
|
|
53
|
-
static
|
|
54
|
-
/**
|
|
55
|
-
* Get entity name
|
|
56
|
-
*
|
|
57
|
-
* @param {Request} req
|
|
58
|
-
* @returns {?string}
|
|
59
|
-
*/
|
|
60
|
-
static findEntityName(req: ReqType): string;
|
|
53
|
+
static findModelResourceName(req: ReqType): string;
|
|
61
54
|
/**
|
|
62
55
|
* Searches for config from admin panel
|
|
63
56
|
*
|
|
64
57
|
* @param {Request} req
|
|
65
|
-
* @param {String}
|
|
58
|
+
* @param {String} modelResourceName
|
|
66
59
|
* @returns {?Object}
|
|
67
60
|
*/
|
|
68
|
-
static findModelConfig(req: ReqType,
|
|
61
|
+
static findModelConfig(req: ReqType, modelResourceName: string): ModelConfig;
|
|
69
62
|
/**
|
|
70
63
|
* Will get action config from configuration file depending to given action
|
|
71
64
|
*
|
|
@@ -85,15 +78,15 @@ export declare class ControllerHelper {
|
|
|
85
78
|
* }
|
|
86
79
|
*
|
|
87
80
|
* @throws {Error} if req or actionType not passed
|
|
88
|
-
* @param {Object}
|
|
81
|
+
* @param {Object} ModelResource ModelResource object with `name`, `config`, `model` {@link ControllerHelper.findModelResource}
|
|
89
82
|
* @param {string} actionType Type of action that config should be loaded for. Example: list, edit, add, remove, view.
|
|
90
83
|
* @returns {Object} Will return object with configs or default configs.
|
|
91
84
|
*/
|
|
92
|
-
static findActionConfig(
|
|
85
|
+
static findActionConfig(modelResource: ModelResource, actionType: ActionType): ActionConfig;
|
|
93
86
|
/**
|
|
94
|
-
* Will create
|
|
87
|
+
* Will create ModelResource object from request.
|
|
95
88
|
*
|
|
96
|
-
*
|
|
89
|
+
* ModelResource Object will have this format:
|
|
97
90
|
*
|
|
98
91
|
* @example
|
|
99
92
|
* ```javascript
|
|
@@ -108,6 +101,6 @@ export declare class ControllerHelper {
|
|
|
108
101
|
* @param req
|
|
109
102
|
* @returns {Object}
|
|
110
103
|
*/
|
|
111
|
-
static
|
|
104
|
+
static findModelResource(req: ReqType): ModelResource;
|
|
112
105
|
}
|
|
113
106
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Adminizer } from "../lib/Adminizer.js";
|
|
2
2
|
export class ControllerHelper {
|
|
3
3
|
/**
|
|
4
|
-
* Default configuration for
|
|
4
|
+
* Default configuration for ModelResource
|
|
5
5
|
*
|
|
6
6
|
* @see ControllerHelper.findConfig
|
|
7
7
|
*/
|
|
@@ -21,7 +21,7 @@ export class ControllerHelper {
|
|
|
21
21
|
fields: {}
|
|
22
22
|
};
|
|
23
23
|
/**
|
|
24
|
-
* Check if given
|
|
24
|
+
* Check if given ModelResource config has all required properties
|
|
25
25
|
*
|
|
26
26
|
* @param {Object} config
|
|
27
27
|
* @returns {boolean}
|
|
@@ -40,29 +40,29 @@ export class ControllerHelper {
|
|
|
40
40
|
}
|
|
41
41
|
;
|
|
42
42
|
/**
|
|
43
|
-
* Normalizing
|
|
43
|
+
* Normalizing ModelResource config.
|
|
44
44
|
* Will return fulfilled configuration object.
|
|
45
45
|
*
|
|
46
46
|
* @see ControllerHelper._isValidModelConfig
|
|
47
|
-
* @param
|
|
47
|
+
* @param modelResourceName
|
|
48
48
|
* @param {Object} config
|
|
49
49
|
* @returns {Object}
|
|
50
50
|
* @private
|
|
51
51
|
*/
|
|
52
|
-
static _normalizeModelConfig(
|
|
52
|
+
static _normalizeModelConfig(modelResourceName, config) {
|
|
53
53
|
if (typeof config === "boolean") {
|
|
54
54
|
config = {
|
|
55
|
-
model:
|
|
55
|
+
model: modelResourceName,
|
|
56
56
|
icon: 'description',
|
|
57
|
-
title:
|
|
57
|
+
title: modelResourceName
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
60
|
if (!this._isValidModelConfig(config)) {
|
|
61
|
-
Adminizer.log.error('Wrong
|
|
61
|
+
Adminizer.log.error('Wrong ModelResource configuration, using default');
|
|
62
62
|
config = {
|
|
63
|
-
model:
|
|
63
|
+
model: modelResourceName,
|
|
64
64
|
icon: 'description',
|
|
65
|
-
title:
|
|
65
|
+
title: modelResourceName
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
68
|
config = { ...this._defaultModelConfig, ...config };
|
|
@@ -83,70 +83,42 @@ export class ControllerHelper {
|
|
|
83
83
|
}
|
|
84
84
|
;
|
|
85
85
|
/**
|
|
86
|
-
* Get
|
|
86
|
+
* Get ModelResource name
|
|
87
87
|
*
|
|
88
88
|
* @param {Request} req
|
|
89
89
|
* @returns {?string}
|
|
90
90
|
*/
|
|
91
|
-
static
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const extractedEntityType = req.originalUrl.split('/')[2];
|
|
95
|
-
if (["form", "model"].includes(extractedEntityType)) {
|
|
96
|
-
return extractedEntityType;
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
91
|
+
static findModelResourceName(req) {
|
|
92
|
+
if (req.params.modelResourceName) {
|
|
93
|
+
return req.params.modelResourceName;
|
|
101
94
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
;
|
|
105
|
-
/**
|
|
106
|
-
* Get entity name
|
|
107
|
-
*
|
|
108
|
-
* @param {Request} req
|
|
109
|
-
* @returns {?string}
|
|
110
|
-
*/
|
|
111
|
-
static findEntityName(req) {
|
|
112
|
-
if (req.params.entityName) {
|
|
113
|
-
return req.params.entityName;
|
|
95
|
+
if (req.params.model) {
|
|
96
|
+
return req.params.model;
|
|
114
97
|
}
|
|
115
98
|
const urlParts = req.originalUrl.split('/');
|
|
116
|
-
const
|
|
117
|
-
const
|
|
118
|
-
if (
|
|
119
|
-
|
|
120
|
-
if (!forms || !Object.keys(forms).some(key => key.toLowerCase() === entityName.toLowerCase())) {
|
|
121
|
-
throw new Error(`Form "${entityName}" not found`);
|
|
122
|
-
}
|
|
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`);
|
|
129
|
-
}
|
|
130
|
-
return Object.keys(models).find(key => key.toLowerCase() === entityName.toLowerCase());
|
|
99
|
+
const modelResourceName = urlParts[3];
|
|
100
|
+
const models = req.adminizer.config.models;
|
|
101
|
+
if (!models || !Object.keys(models).some(key => key.toLowerCase() === modelResourceName.toLowerCase())) {
|
|
102
|
+
throw new Error(`Model "${modelResourceName}" not found`);
|
|
131
103
|
}
|
|
132
|
-
|
|
104
|
+
return Object.keys(models).find(key => key.toLowerCase() === modelResourceName.toLowerCase());
|
|
133
105
|
}
|
|
134
106
|
/**
|
|
135
107
|
* Searches for config from admin panel
|
|
136
108
|
*
|
|
137
109
|
* @param {Request} req
|
|
138
|
-
* @param {String}
|
|
110
|
+
* @param {String} modelResourceName
|
|
139
111
|
* @returns {?Object}
|
|
140
112
|
*/
|
|
141
|
-
static findModelConfig(req,
|
|
113
|
+
static findModelConfig(req, modelResourceName) {
|
|
142
114
|
const models = req.adminizer.config.models;
|
|
143
115
|
if (!models) {
|
|
144
116
|
Adminizer.log.error('No models configuration found');
|
|
145
117
|
return null;
|
|
146
118
|
}
|
|
147
|
-
const foundKey = Object.keys(models).find(key => key.toLowerCase() ===
|
|
119
|
+
const foundKey = Object.keys(models).find(key => key.toLowerCase() === modelResourceName.toLowerCase());
|
|
148
120
|
if (!foundKey) {
|
|
149
|
-
Adminizer.log.error(`No such route exists: ${
|
|
121
|
+
Adminizer.log.error(`No such route exists: ${modelResourceName}`);
|
|
150
122
|
return null;
|
|
151
123
|
}
|
|
152
124
|
return this._normalizeModelConfig(foundKey, models[foundKey]);
|
|
@@ -170,31 +142,31 @@ export class ControllerHelper {
|
|
|
170
142
|
* }
|
|
171
143
|
*
|
|
172
144
|
* @throws {Error} if req or actionType not passed
|
|
173
|
-
* @param {Object}
|
|
145
|
+
* @param {Object} ModelResource ModelResource object with `name`, `config`, `model` {@link ControllerHelper.findModelResource}
|
|
174
146
|
* @param {string} actionType Type of action that config should be loaded for. Example: list, edit, add, remove, view.
|
|
175
147
|
* @returns {Object} Will return object with configs or default configs.
|
|
176
148
|
*/
|
|
177
|
-
static findActionConfig(
|
|
178
|
-
if (!
|
|
179
|
-
throw new Error('No `
|
|
149
|
+
static findActionConfig(modelResource, actionType) {
|
|
150
|
+
if (!modelResource || !actionType) {
|
|
151
|
+
throw new Error('No `ModelResource` or `actionType` passed !');
|
|
180
152
|
}
|
|
181
153
|
let result = { ...this._defaultActionConfig };
|
|
182
|
-
if (!
|
|
154
|
+
if (!modelResource.config || !modelResource.config[actionType]) {
|
|
183
155
|
return result;
|
|
184
156
|
}
|
|
185
157
|
/**
|
|
186
158
|
* Here we could get true/false so need to update it to Object for later manipulations
|
|
187
159
|
* In this function
|
|
188
160
|
*/
|
|
189
|
-
if (typeof
|
|
161
|
+
if (typeof modelResource.config[actionType] === "boolean") {
|
|
190
162
|
return result;
|
|
191
163
|
}
|
|
192
|
-
return this._normalizeActionConfig(
|
|
164
|
+
return this._normalizeActionConfig(modelResource.config[actionType]);
|
|
193
165
|
}
|
|
194
166
|
/**
|
|
195
|
-
* Will create
|
|
167
|
+
* Will create ModelResource object from request.
|
|
196
168
|
*
|
|
197
|
-
*
|
|
169
|
+
* ModelResource Object will have this format:
|
|
198
170
|
*
|
|
199
171
|
* @example
|
|
200
172
|
* ```javascript
|
|
@@ -209,30 +181,25 @@ export class ControllerHelper {
|
|
|
209
181
|
* @param req
|
|
210
182
|
* @returns {Object}
|
|
211
183
|
*/
|
|
212
|
-
static
|
|
213
|
-
// Retrieve
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
uri: entityUri,
|
|
222
|
-
type: entityType,
|
|
184
|
+
static findModelResource(req) {
|
|
185
|
+
// Retrieve model name based on the request
|
|
186
|
+
const modelResourceName = this.findModelResourceName(req);
|
|
187
|
+
// Construct the ModelResource URI
|
|
188
|
+
const modelResourceUri = `${req.adminizer.config.routePrefix}/model/${modelResourceName}`;
|
|
189
|
+
// Initialize the ModelResource object
|
|
190
|
+
const modelResource = {
|
|
191
|
+
name: modelResourceName,
|
|
192
|
+
uri: modelResourceUri,
|
|
223
193
|
model: null,
|
|
224
194
|
config: null
|
|
225
195
|
};
|
|
226
|
-
//
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
if (this._isValidModelConfig(entity.config)) {
|
|
232
|
-
entity.model = req.adminizer.modelHandler.model.get(entity.config.model);
|
|
233
|
-
}
|
|
196
|
+
// Find and add the model configuration to the ModelResource
|
|
197
|
+
modelResource.config = this.findModelConfig(req, modelResourceName);
|
|
198
|
+
// Find and add the model itself to the ModelResource
|
|
199
|
+
if (this._isValidModelConfig(modelResource.config)) {
|
|
200
|
+
modelResource.model = req.adminizer.modelHandler.model.get(modelResource.config.model);
|
|
234
201
|
}
|
|
235
|
-
// Return the completed
|
|
236
|
-
return
|
|
202
|
+
// Return the completed ModelResource object
|
|
203
|
+
return modelResource;
|
|
237
204
|
}
|
|
238
205
|
}
|
package/helpers/fieldsHelper.js
CHANGED
|
@@ -38,11 +38,11 @@ export class FieldsHelper {
|
|
|
38
38
|
// adding deprecated records array to config for association widget
|
|
39
39
|
Adminizer.log.warn("Warning: executing malicious job trying to add a huge amount of records in field config," +
|
|
40
40
|
" please rewrite this part of code in the nearest future");
|
|
41
|
-
let
|
|
41
|
+
let modelResource = {
|
|
42
42
|
name: modelName, config: req.adminizer.config.models[modelName],
|
|
43
|
-
model: Model, uri: `${req.adminizer.config.routePrefix}/model/${modelName}
|
|
43
|
+
model: Model, uri: `${req.adminizer.config.routePrefix}/model/${modelName}`
|
|
44
44
|
};
|
|
45
|
-
let dataAccessor = new DataAccessor(req.adminizer, req.user,
|
|
45
|
+
let dataAccessor = new DataAccessor(req.adminizer, req.user, modelResource, "view");
|
|
46
46
|
list = await Model.find({}, dataAccessor);
|
|
47
47
|
}
|
|
48
48
|
catch (e) {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FilterCondition } from "../models/FilterAP";
|
|
2
|
+
export interface ConvertDatetimeConditionsOptions {
|
|
3
|
+
dropEmptyValues?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function convertDatetimeConditions(conditions: FilterCondition[] | undefined, options?: ConvertDatetimeConditionsOptions): FilterCondition[];
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
const DATETIME_LOCAL_REGEX = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/;
|
|
2
|
+
const OPERATORS_WITHOUT_VALUE = ['isNull', 'isNotNull', 'today'];
|
|
3
|
+
function isOperatorWithoutValue(operator) {
|
|
4
|
+
return operator !== undefined && OPERATORS_WITHOUT_VALUE.includes(operator);
|
|
5
|
+
}
|
|
6
|
+
function parseDatetimeLocalToUtc(value) {
|
|
7
|
+
if (!DATETIME_LOCAL_REGEX.test(value)) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
const [datePart, timePart] = value.split('T');
|
|
11
|
+
const [year, month, day] = datePart.split('-').map(Number);
|
|
12
|
+
const [hours, minutes] = timePart.split(':').map(Number);
|
|
13
|
+
if ([year, month, day, hours, minutes].some(Number.isNaN)) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
return new Date(Date.UTC(year, month - 1, day, hours, minutes, 0, 0));
|
|
17
|
+
}
|
|
18
|
+
export function convertDatetimeConditions(conditions, options = {}) {
|
|
19
|
+
if (!conditions || !Array.isArray(conditions)) {
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
const { dropEmptyValues = false } = options;
|
|
23
|
+
return conditions
|
|
24
|
+
.filter(cond => {
|
|
25
|
+
if (!dropEmptyValues) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
if (isOperatorWithoutValue(cond.operator)) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
if (cond.value === undefined || cond.value === null || cond.value === '') {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
if (Array.isArray(cond.value) && cond.value.length === 0) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
return true;
|
|
38
|
+
})
|
|
39
|
+
.map(cond => {
|
|
40
|
+
if (cond.children && cond.children.length > 0) {
|
|
41
|
+
return {
|
|
42
|
+
...cond,
|
|
43
|
+
children: convertDatetimeConditions(cond.children, options)
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
if (!cond.field || cond.value === undefined || cond.value === null || cond.value === '') {
|
|
47
|
+
return cond;
|
|
48
|
+
}
|
|
49
|
+
if (isOperatorWithoutValue(cond.operator)) {
|
|
50
|
+
return cond;
|
|
51
|
+
}
|
|
52
|
+
if (typeof cond.value === 'string') {
|
|
53
|
+
const utcDate = parseDatetimeLocalToUtc(cond.value);
|
|
54
|
+
if (utcDate) {
|
|
55
|
+
if (cond.operator === 'eq') {
|
|
56
|
+
const endOfMinute = new Date(utcDate.getTime() + 59_999);
|
|
57
|
+
return {
|
|
58
|
+
...cond,
|
|
59
|
+
operator: 'between',
|
|
60
|
+
value: [utcDate, endOfMinute]
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
...cond,
|
|
65
|
+
value: utcDate
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (Array.isArray(cond.value) && cond.value.length === 2) {
|
|
70
|
+
const [val1, val2] = cond.value;
|
|
71
|
+
if (typeof val1 === 'string' && typeof val2 === 'string') {
|
|
72
|
+
const utcDate1 = parseDatetimeLocalToUtc(val1);
|
|
73
|
+
const utcDate2 = parseDatetimeLocalToUtc(val2);
|
|
74
|
+
if (utcDate1 && utcDate2) {
|
|
75
|
+
return {
|
|
76
|
+
...cond,
|
|
77
|
+
value: [utcDate1, utcDate2]
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return cond;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ModelResource } from "../interfaces/types";
|
|
2
2
|
import { ActionType } from "../interfaces/adminpanelConfig";
|
|
3
3
|
export interface Actions {
|
|
4
4
|
link: string;
|
|
@@ -7,4 +7,4 @@ export interface Actions {
|
|
|
7
7
|
title: string;
|
|
8
8
|
icon: string;
|
|
9
9
|
}
|
|
10
|
-
export default function inertiaActionsHelper(actionType: ActionType,
|
|
10
|
+
export default function inertiaActionsHelper(actionType: ActionType, modelResource: ModelResource, req: ReqType): Actions[];
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
export default function inertiaActionsHelper(actionType,
|
|
1
|
+
export default function inertiaActionsHelper(actionType, modelResource, req) {
|
|
2
2
|
let resActions = [];
|
|
3
|
-
if (req.adminizer.menuHelper.hasGlobalActions(
|
|
4
|
-
const actions = req.adminizer.menuHelper.getGlobalActions(
|
|
3
|
+
if (req.adminizer.menuHelper.hasGlobalActions(modelResource.config, actionType)) {
|
|
4
|
+
const actions = req.adminizer.menuHelper.getGlobalActions(modelResource.config, actionType);
|
|
5
5
|
if (actions && actions.length > 0) {
|
|
6
6
|
actions.forEach(function (action) {
|
|
7
|
-
|
|
7
|
+
const context = `global action "${action.title}" (${action.id}) on model "${modelResource.name}"`;
|
|
8
|
+
if (req.adminizer.accessRightsHelper.hasPermission(action.accessRightsToken, req.user, context)) {
|
|
8
9
|
resActions.push({
|
|
9
10
|
link: action.link,
|
|
10
11
|
id: action.id,
|