adminizer 4.1.0-commit.ad1476a → 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-FUe77pIA.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-DMmad2-f.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-BOltB2Hq.css +1 -0
- package/assets/dashboard-es9ZT8qk.js +3 -0
- package/assets/{date-picker-B__dVVqj.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-CapylJU9.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-CwteYDGB.js → geo-json-BKmYmu3d.js} +2 -2
- package/assets/{handsontable-BCnjOpBr.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-DTRTjOmh.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-BcE9FUM6.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 +589 -666
- package/assets/material-icon-BRS58Qpk.js +1 -0
- package/assets/module-CjG21VCT.js +1 -0
- package/assets/{monaco-editor-DqAqwxw4.js → monaco-editor-9fDiyfuW.js} +2 -2
- package/assets/{multi-select-oabtVhUP.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-D1N8zRPY.js → select-DzBno-dc.js} +2 -2
- package/assets/{sidebar-4D-sX2l4.js → sidebar-Dc4iqfu-.js} +2 -2
- package/assets/skeleton-Dkmj2o2Z.js +1 -0
- package/assets/sonner-De1t71Gj.js +1 -0
- package/assets/{toast-editor-FbrFd1ft.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-DBYoAJYJ.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 +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 -37
- package/controllers/catalog/FrontentCatalogAdapter.d.ts +36 -26
- package/controllers/catalog/FrontentCatalogAdapter.js +71 -73
- 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 +43 -18
- 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 +28 -5
- 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 +8 -3
- package/helpers/menuHelper.js +26 -17
- package/index.d.ts +6 -3
- package/index.js +9 -3
- package/interfaces/adminpanelConfig.d.ts +41 -32
- package/interfaces/global.d.ts +10 -28
- package/interfaces/types.d.ts +1 -1
- package/lib/Adminizer.d.ts +11 -3
- package/lib/Adminizer.js +49 -17
- 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 +89 -60
- package/lib/{catalog → v4/catalog}/AbstractCatalog.js +59 -55
- 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 -4
- 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 +29 -11
- package/policies/checkAuth.js +4 -3
- package/policies/setLocale.js +2 -2
- package/system/Router.js +14 -17
- 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 +17 -12
- 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 +15 -0
- 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 -94
- package/translations/ua.json +70 -1
- package/translations/uz.json +72 -0
- package/translations/vi.json +70 -1
- 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-shell-BWMRMkHM.js +0 -1
- package/assets/app-sidebar-BCtaEFGb.js +0 -1
- package/assets/app-sidebar-header-DLAFi13E.js +0 -11
- package/assets/breadcrumbs-CQNon4Vl.js +0 -1
- package/assets/button-CQ9t1kLz.js +0 -1
- package/assets/checkbox-W0nGAXIj.js +0 -1
- package/assets/compiler-runtime-tM4jBQ-T.js +0 -9
- 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/icon-Bz9BMaD0.js +0 -1
- package/assets/index-BC0yfOHo.js +0 -1
- package/assets/index-BbXEMx9n.js +0 -1
- package/assets/index-C0SL3SHw.js +0 -41
- package/assets/index-Cdb9ACvz.js +0 -1
- package/assets/index-DEk3sC8d.js +0 -1
- package/assets/index-DrWfGwtf.js +0 -1
- package/assets/index-K81GbF6O.js +0 -1
- package/assets/init-user-D9mW-g14.js +0 -1
- package/assets/input-DF7Ue23C.js +0 -1
- package/assets/input-error-BBygona6.js +0 -1
- package/assets/label-Z506NKsW.js +0 -1
- package/assets/list-Qyd7ecQH.js +0 -1
- package/assets/list-table-DB1sEQLF.js +0 -62
- package/assets/login-DrGaTWhY.js +0 -6
- package/assets/material-icon-CItZiB53.js +0 -1
- package/assets/module-DBaykv8l.js +0 -1
- package/assets/nav-footer-CM-yHiRs.js +0 -1
- package/assets/nav-main-Q3xofGRT.js +0 -1
- package/assets/nav-user-Ds8i0Pa2.js +0 -1
- package/assets/pagination-render-B57pOpFy.js +0 -1
- package/assets/popover-I249Gg2O.js +0 -1
- package/assets/register-C9FQIDtS.js +0 -1
- package/assets/sonner-Dzckw3U3.js +0 -1
- package/assets/tooltip-D2ehgLlB.js +0 -1
- package/assets/use-appearance-Co6mO0dV.js +0 -1
- package/assets/use-window-size-B8l6Bpkf.js +0 -1
- package/assets/user-menu-content-qkvdkUVd.js +0 -6
- package/assets/utils-DjqsqOe8.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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CatalogHandler } from "../../lib/catalog/CatalogHandler";
|
|
1
|
+
import { CatalogHandler } from "../../lib/v4/catalog/CatalogHandler";
|
|
2
2
|
import { VueCatalog } from "./FrontentCatalogAdapter";
|
|
3
3
|
import { Adminizer } from "../../lib/Adminizer";
|
|
4
4
|
export async function catalogController(req, res) {
|
|
@@ -6,10 +6,10 @@ export async function catalogController(req, res) {
|
|
|
6
6
|
let id = req.params.id ? req.params.id : '';
|
|
7
7
|
const postfix = id ? `${slug}-${id}` : `${slug}`;
|
|
8
8
|
if (req.adminizer.config.auth.enable) {
|
|
9
|
-
if (!req.
|
|
9
|
+
if (!req.user) {
|
|
10
10
|
return res.redirect(`${req.adminizer.config.routePrefix}/model/userap/login`);
|
|
11
11
|
}
|
|
12
|
-
else if (!req.adminizer.accessRightsHelper.hasPermission(`catalog-${postfix}`, req.
|
|
12
|
+
else if (!req.adminizer.accessRightsHelper.hasPermission(`catalog-${postfix}`, req.user)) {
|
|
13
13
|
return res.sendStatus(403);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -28,64 +28,69 @@ export async function catalogController(req, res) {
|
|
|
28
28
|
}
|
|
29
29
|
const method = req.method.toUpperCase();
|
|
30
30
|
if (method === 'GET') {
|
|
31
|
-
return
|
|
31
|
+
return req.Inertia.render({
|
|
32
|
+
component: 'catalog',
|
|
33
|
+
props: null
|
|
34
|
+
});
|
|
32
35
|
}
|
|
33
36
|
if (method === 'POST' || method === 'PUT' || method === 'DELETE') {
|
|
34
37
|
const data = req.body;
|
|
35
|
-
const
|
|
36
|
-
if (!
|
|
38
|
+
const frontendCatalog = new VueCatalog(_catalog);
|
|
39
|
+
if (!frontendCatalog)
|
|
37
40
|
return res.status(404);
|
|
38
|
-
|
|
39
|
-
const item =
|
|
41
|
+
frontendCatalog.setId(id);
|
|
42
|
+
const item = frontendCatalog.getItemType(data.type);
|
|
40
43
|
switch (method) {
|
|
41
44
|
case 'POST':
|
|
42
45
|
switch (data._method) {
|
|
43
|
-
case '
|
|
44
|
-
return res.json(await
|
|
45
|
-
case '
|
|
46
|
-
return res.json(await
|
|
46
|
+
case 'getAddTemplate':
|
|
47
|
+
return res.json(await frontendCatalog.getAddTemplate(item, req));
|
|
48
|
+
case 'getEditTemplate':
|
|
49
|
+
return res.json(await frontendCatalog.getEditTemplate(item, data.id, req, data.modelId));
|
|
47
50
|
case 'getCatalog':
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
51
|
+
{
|
|
52
|
+
const __catalog = await frontendCatalog.getCatalog();
|
|
53
|
+
return res.json({
|
|
54
|
+
items: frontendCatalog.getitemTypes(),
|
|
55
|
+
catalog: {
|
|
56
|
+
nodes: __catalog,
|
|
57
|
+
movingGroupsRootOnly: _catalog.movingGroupsRootOnly ?? false,
|
|
58
|
+
catalogName: _catalog.name,
|
|
59
|
+
catalogId: _catalog.id,
|
|
60
|
+
catalogSlug: _catalog.slug,
|
|
61
|
+
idList: idList
|
|
62
|
+
},
|
|
63
|
+
toolsActions: await frontendCatalog.getActions([], 'tools')
|
|
64
|
+
});
|
|
65
|
+
}
|
|
61
66
|
case 'createItem':
|
|
62
|
-
return res.json({ 'data': await
|
|
67
|
+
return res.json({ 'data': await frontendCatalog.createItem(data.data, req) });
|
|
63
68
|
case 'getChilds':
|
|
64
|
-
return res.json({ data: await
|
|
69
|
+
return res.json({ data: await frontendCatalog.getChilds(data.data, req) });
|
|
65
70
|
case 'getActions':
|
|
66
|
-
return res.json({ data: await
|
|
71
|
+
return res.json({ data: await frontendCatalog.getActions(data.items, data.type) });
|
|
67
72
|
case 'search':
|
|
68
|
-
return res.json({ data: await
|
|
73
|
+
return res.json({ data: await frontendCatalog.search(data.s, req) });
|
|
69
74
|
case "getLocales":
|
|
70
|
-
return res.json({ data:
|
|
75
|
+
return res.json({ data: frontendCatalog.getLocales(req) });
|
|
71
76
|
}
|
|
72
77
|
break;
|
|
73
78
|
case 'PUT':
|
|
74
79
|
switch (data._method) {
|
|
75
80
|
case 'updateTree':
|
|
76
|
-
return res.json({ data: await
|
|
81
|
+
return res.json({ data: await frontendCatalog.updateTree(data.data, req) });
|
|
77
82
|
case 'getLink':
|
|
78
|
-
return res.json({ data: await
|
|
83
|
+
return res.json({ data: await frontendCatalog.getLink(data.actionId) });
|
|
79
84
|
case 'handleAction':
|
|
80
|
-
return res.json({ data: await
|
|
81
|
-
case '
|
|
82
|
-
return res.json({ data: await
|
|
85
|
+
return res.json({ data: await frontendCatalog.handleAction(data.data.actionID, data.data.items, data.data.data, req) });
|
|
86
|
+
case 'getPopUpTemplate':
|
|
87
|
+
return res.json({ data: await frontendCatalog.getPopUpTemplate(data.actionId, req) });
|
|
83
88
|
case 'updateItem':
|
|
84
|
-
return res.json({ data: await
|
|
89
|
+
return res.json({ data: await frontendCatalog.updateItem(item, data.modelId, data.data, req) });
|
|
85
90
|
}
|
|
86
91
|
break;
|
|
87
92
|
case 'DELETE':
|
|
88
|
-
return res.json({ data: await
|
|
93
|
+
return res.json({ data: await frontendCatalog.deleteItem(data.data, req) });
|
|
89
94
|
}
|
|
90
95
|
}
|
|
91
96
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { AbstractCatalog, Item } from "../../lib/catalog/AbstractCatalog";
|
|
1
|
+
import { AbstractCatalog, Item } from "../../lib/v4/catalog/AbstractCatalog";
|
|
2
2
|
interface NodeModel<TDataType> {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
text: string;
|
|
4
|
+
droppable: boolean;
|
|
5
|
+
id: string;
|
|
6
|
+
parent: string;
|
|
7
7
|
data?: TDataType;
|
|
8
8
|
children?: NodeModel<TDataType>[];
|
|
9
9
|
isSelected?: boolean;
|
|
@@ -18,40 +18,50 @@ interface NodeModel<TDataType> {
|
|
|
18
18
|
}
|
|
19
19
|
interface NodeData extends Item {
|
|
20
20
|
}
|
|
21
|
-
interface obj {
|
|
22
|
-
[key: string]: string;
|
|
23
|
-
}
|
|
24
21
|
interface RequestData {
|
|
25
22
|
reqNode: NodeModel<NodeData>[];
|
|
26
23
|
reqParent: NodeModel<NodeData>;
|
|
27
24
|
_method: string;
|
|
28
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated Now is React
|
|
28
|
+
* // TODO: refactor for react name
|
|
29
|
+
*/
|
|
29
30
|
export declare class VueCatalog {
|
|
30
31
|
catalog: AbstractCatalog;
|
|
31
32
|
constructor(_catalog: AbstractCatalog);
|
|
32
33
|
setId(id: string): void;
|
|
33
|
-
getItemType(type: string): import("../../lib/catalog/AbstractCatalog").BaseItem<Item>;
|
|
34
|
-
|
|
35
|
-
type: "
|
|
36
|
-
data:
|
|
34
|
+
getItemType(type: string): import("../../lib/v4/catalog/AbstractCatalog").BaseItem<Item>;
|
|
35
|
+
getAddTemplate(item: any, req: ReqType): Promise<{
|
|
36
|
+
type: "component" | "navigation.group" | "navigation.link" | "model";
|
|
37
|
+
data: any;
|
|
37
38
|
}>;
|
|
38
|
-
|
|
39
|
-
type: "
|
|
40
|
-
data:
|
|
39
|
+
getEditTemplate(item: any, id: string | number, req: ReqType, modelId: string | number): Promise<{
|
|
40
|
+
type: "component" | "navigation.group" | "navigation.link" | "model";
|
|
41
|
+
data: any;
|
|
41
42
|
}>;
|
|
42
|
-
getitemTypes():
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
getitemTypes(): {
|
|
44
|
+
type: string;
|
|
45
|
+
name: string;
|
|
46
|
+
isGroup: boolean;
|
|
47
|
+
allowedRoot: boolean;
|
|
48
|
+
icon: string;
|
|
49
|
+
actionHandlers: import("../../lib/v4/catalog/AbstractCatalog").ActionHandler[];
|
|
50
|
+
}[];
|
|
51
|
+
getLocales(req: ReqType): {
|
|
52
|
+
[key: string]: string;
|
|
53
|
+
};
|
|
54
|
+
getActions(items: NodeModel<any>[], type: string): Promise<import("../../lib/v4/catalog/AbstractCatalog").ActionHandler[]>;
|
|
55
|
+
handleAction(actionId: string, items: any[], data: any, req: ReqType): Promise<string | void>;
|
|
56
|
+
getPopUpTemplate(actionId: string, req: ReqType): Promise<string>;
|
|
47
57
|
getLink(actionId: string): Promise<string>;
|
|
48
58
|
getCatalog(): Promise<NodeModel<Item>[]>;
|
|
49
|
-
createItem(data: any): Promise<any>;
|
|
50
|
-
getChilds(data: any): Promise<NodeModel<Item>[]>;
|
|
51
|
-
search(s: string): Promise<NodeModel<Item>[]>;
|
|
52
|
-
updateTree(data: RequestData): Promise<any>;
|
|
53
|
-
updateItem(item: any, modelId: string, data: any): Promise<any>;
|
|
54
|
-
deleteItem(
|
|
59
|
+
createItem(data: any, req: ReqType): Promise<any>;
|
|
60
|
+
getChilds(data: any, req: ReqType): Promise<NodeModel<Item>[]>;
|
|
61
|
+
search(s: string, req: ReqType): Promise<NodeModel<Item>[]>;
|
|
62
|
+
updateTree(data: RequestData, req: ReqType): Promise<any>;
|
|
63
|
+
updateItem(item: any, modelId: string, data: any, req: ReqType): Promise<any>;
|
|
64
|
+
deleteItem(item: Item, req: ReqType): Promise<{
|
|
55
65
|
ok: boolean;
|
|
56
66
|
}>;
|
|
57
67
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated Now is React
|
|
3
|
+
* // TODO: refactor for react name
|
|
4
|
+
*/
|
|
2
5
|
export class VueCatalog {
|
|
3
6
|
catalog;
|
|
4
7
|
constructor(_catalog) {
|
|
@@ -10,11 +13,11 @@ export class VueCatalog {
|
|
|
10
13
|
getItemType(type) {
|
|
11
14
|
return this.catalog.getItemType(type);
|
|
12
15
|
}
|
|
13
|
-
|
|
14
|
-
return this.catalog.
|
|
16
|
+
getAddTemplate(item, req) {
|
|
17
|
+
return this.catalog.getAddTemplate(item, req);
|
|
15
18
|
}
|
|
16
|
-
|
|
17
|
-
return this.catalog.
|
|
19
|
+
getEditTemplate(item, id, req, modelId) {
|
|
20
|
+
return this.catalog.getEditTemplate(item, id, req, modelId);
|
|
18
21
|
}
|
|
19
22
|
getitemTypes() {
|
|
20
23
|
return this.catalog.getitemTypes();
|
|
@@ -28,28 +31,35 @@ export class VueCatalog {
|
|
|
28
31
|
"Select Item type": "",
|
|
29
32
|
"Select Items": "",
|
|
30
33
|
"Save": "",
|
|
31
|
-
"No
|
|
34
|
+
"No": "",
|
|
32
35
|
"Are you sure?": "",
|
|
33
|
-
"Yes
|
|
34
|
-
"Select Ids": ""
|
|
36
|
+
"Yes": "",
|
|
37
|
+
"Select Ids": "",
|
|
38
|
+
"OR": "",
|
|
39
|
+
"Open in a new window": "",
|
|
40
|
+
"Clean": "",
|
|
41
|
+
"Performing an action...": "",
|
|
42
|
+
"Action completed": "",
|
|
35
43
|
};
|
|
36
44
|
obj[this.catalog.name] = "";
|
|
37
45
|
for (const actionHandler of this.catalog.actionHandlers) {
|
|
38
46
|
obj[actionHandler.name] = "";
|
|
39
47
|
}
|
|
40
48
|
let messages = obj;
|
|
41
|
-
req.i18n.setLocale(req.session.UserAP.locale);
|
|
42
49
|
let outMessages = {};
|
|
43
50
|
for (const mess of Object.keys(messages)) {
|
|
44
51
|
outMessages[mess] = req.i18n.__(mess);
|
|
45
52
|
}
|
|
46
|
-
return
|
|
53
|
+
return {
|
|
54
|
+
...outMessages,
|
|
55
|
+
};
|
|
47
56
|
}
|
|
48
57
|
async getActions(items, type) {
|
|
49
58
|
let arrItems = [];
|
|
50
59
|
for (const item of items) {
|
|
51
60
|
arrItems.push(await this.catalog.find(item.data));
|
|
52
61
|
}
|
|
62
|
+
console.log(arrItems);
|
|
53
63
|
if (type === 'tools') {
|
|
54
64
|
return (await this.catalog.getActions(arrItems))?.filter(e => e.displayTool);
|
|
55
65
|
}
|
|
@@ -57,95 +67,83 @@ export class VueCatalog {
|
|
|
57
67
|
return (await this.catalog.getActions(arrItems))?.filter(e => e.displayContext);
|
|
58
68
|
}
|
|
59
69
|
}
|
|
60
|
-
async handleAction(actionId, items,
|
|
70
|
+
async handleAction(actionId, items, data, req) {
|
|
61
71
|
let arrItems = [];
|
|
62
72
|
for (const item of items) {
|
|
63
73
|
arrItems.push(await this.catalog.find(item.data));
|
|
64
74
|
}
|
|
65
|
-
|
|
75
|
+
console.log(arrItems);
|
|
76
|
+
return this.catalog.handleAction(actionId, arrItems, data, req);
|
|
66
77
|
}
|
|
67
|
-
async
|
|
68
|
-
return this.catalog.
|
|
78
|
+
async getPopUpTemplate(actionId, req) {
|
|
79
|
+
return this.catalog.getPopUpTemplate(actionId, req);
|
|
69
80
|
}
|
|
70
81
|
async getLink(actionId) {
|
|
71
82
|
return this.catalog.getLink(actionId);
|
|
72
83
|
}
|
|
73
84
|
//Below are the methods that require action
|
|
74
85
|
async getCatalog() {
|
|
75
|
-
let rootItems = await this.catalog.getChilds(
|
|
86
|
+
let rootItems = await this.catalog.getChilds(0);
|
|
76
87
|
return VueCatalogUtils.arrayToNode(rootItems, this.catalog.getGroupType().type);
|
|
77
88
|
}
|
|
78
|
-
createItem(data) {
|
|
89
|
+
async createItem(data, req) {
|
|
90
|
+
// TODO It's not clear why it's here.
|
|
79
91
|
//data = VueCatalogUtils.refinement(data);
|
|
80
|
-
if (this.catalog.slug !== "navigation") {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
async getChilds(data) {
|
|
92
|
+
// if (this.catalog.slug !== "navigation") {
|
|
93
|
+
// let item = data.record;
|
|
94
|
+
// item.parenId = data.parenId;
|
|
95
|
+
// return await this.catalog.createItem(item, req);
|
|
96
|
+
// } else {
|
|
97
|
+
return await this.catalog.createItem(data, req);
|
|
98
|
+
// }
|
|
99
|
+
}
|
|
100
|
+
async getChilds(data, req) {
|
|
90
101
|
data = VueCatalogUtils.refinement(data);
|
|
91
|
-
return VueCatalogUtils.arrayToNode(await this.catalog.getChilds(data.id), this.catalog.getGroupType().type);
|
|
102
|
+
return VueCatalogUtils.arrayToNode(await this.catalog.getChilds(data.id, undefined, req), this.catalog.getGroupType().type);
|
|
92
103
|
}
|
|
93
104
|
// Moved into actions
|
|
94
105
|
// getCreatedItems(data: any) {
|
|
95
106
|
// data = VueCatalogUtils.refinement(data);
|
|
96
107
|
// return this.catalog.getChilds(data.id);
|
|
97
108
|
// }
|
|
98
|
-
async search(s) {
|
|
99
|
-
let searchResult = await this.catalog.search(s);
|
|
100
|
-
let itemsTree = AbstractCatalog.buildTree(searchResult);
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
109
|
+
async search(s, req) {
|
|
110
|
+
let searchResult = await this.catalog.search(s, undefined, req);
|
|
111
|
+
// let itemsTree = AbstractCatalog.buildTree(searchResult);
|
|
112
|
+
// console.log(itemsTree)
|
|
113
|
+
return VueCatalogUtils.treeToNode(searchResult, this.catalog.getGroupType().type);
|
|
114
|
+
}
|
|
115
|
+
async updateTree(data, req) {
|
|
116
|
+
// console.dir(data, {depth: null})
|
|
117
|
+
// return
|
|
108
118
|
let reqParent = data.reqParent;
|
|
109
|
-
if (reqParent.data.id === 0) {
|
|
110
|
-
reqParent.data.id = null;
|
|
111
|
-
}
|
|
112
|
-
if (reqParent.data.id === undefined) {
|
|
113
|
-
throw `reqParent.data.id not defined`;
|
|
114
|
-
}
|
|
115
|
-
// It’s unclear why he’s coming reqNodes
|
|
116
|
-
for (const reqNode of reqNodes) {
|
|
117
|
-
// console.log(">>>>>>>>>", "this.catalog.find", reqNode)
|
|
118
|
-
const item = await this.catalog.find(reqNode.data);
|
|
119
|
-
if (!item) {
|
|
120
|
-
throw `reqNode Item not found`;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
119
|
// Update all items into parent (for two reason: update parent, updare sorting order)
|
|
124
120
|
let sortCount = 0;
|
|
125
121
|
for (const childNode of reqParent.children) {
|
|
126
122
|
childNode.data.sortOrder = sortCount;
|
|
127
123
|
childNode.data.parentId = reqParent.data.id;
|
|
128
|
-
await this.catalog.updateItem(childNode.data.id, childNode.data.type, childNode.data);
|
|
124
|
+
await this.catalog.updateItem(childNode.data.id, childNode.data.type, childNode.data, req);
|
|
129
125
|
sortCount++;
|
|
130
126
|
}
|
|
131
127
|
return Promise.resolve('ok');
|
|
132
128
|
}
|
|
133
|
-
async updateItem(item, modelId, data) {
|
|
129
|
+
async updateItem(item, modelId, data, req) {
|
|
130
|
+
//TODO It's not clear why it's here.
|
|
134
131
|
//data = VueCatalogUtils.refinement(data);
|
|
135
|
-
if (this.catalog.slug !== "navigation") {
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
132
|
+
// if (this.catalog.slug !== "navigation") {
|
|
133
|
+
// return await this.catalog.updateModelItems(data.modelId, data.type, data.record, req);
|
|
134
|
+
// } else {
|
|
135
|
+
return await this.catalog.updateModelItems(modelId, item.type, data, req);
|
|
136
|
+
// }
|
|
137
|
+
}
|
|
138
|
+
async deleteItem(item, req) {
|
|
139
|
+
// Получаем всех непосредственных потомков текущего элемента
|
|
140
|
+
const children = await this.catalog.getChilds(item.id, undefined, req);
|
|
141
|
+
// Рекурсивно удаляем всех потомков
|
|
142
|
+
for (const child of children) {
|
|
143
|
+
await this.deleteItem(child, req);
|
|
144
|
+
}
|
|
145
|
+
// После удаления всех потомков удаляем сам элемент
|
|
146
|
+
await this.catalog.deleteItem(item.type, item.id, req);
|
|
149
147
|
return { ok: true };
|
|
150
148
|
}
|
|
151
149
|
}
|
|
@@ -162,16 +160,16 @@ export class VueCatalogUtils {
|
|
|
162
160
|
static toNode(data, groupTypeName) {
|
|
163
161
|
return {
|
|
164
162
|
data: data,
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
163
|
+
droppable: data.type === groupTypeName,
|
|
164
|
+
id: data.id,
|
|
165
|
+
text: data.name,
|
|
166
|
+
parent: data.parentId,
|
|
169
167
|
};
|
|
170
168
|
}
|
|
171
169
|
static expandTo(vueCatalogData, theseItemIdsNeedToBeOpened) {
|
|
172
170
|
function expand(node) {
|
|
173
171
|
if (theseItemIdsNeedToBeOpened.includes(node.data.id)) {
|
|
174
|
-
node.isExpanded = true;
|
|
172
|
+
// node.isExpanded = true;
|
|
175
173
|
}
|
|
176
174
|
if (node.children) {
|
|
177
175
|
for (const child of node.children) {
|
|
@@ -192,7 +190,7 @@ export class VueCatalogUtils {
|
|
|
192
190
|
// Sort the children before building their nodes
|
|
193
191
|
item.childs.sort((a, b) => (a.sortOrder || 0) - (b.sortOrder || 0));
|
|
194
192
|
node.children = buildNodes(item.childs);
|
|
195
|
-
node.isExpanded = !node.
|
|
193
|
+
// node.isExpanded = !node.droppable;
|
|
196
194
|
}
|
|
197
195
|
return node;
|
|
198
196
|
});
|
|
@@ -2,10 +2,9 @@ import { ControllerHelper } from "../helpers/controllerHelper";
|
|
|
2
2
|
import * as fs from "fs";
|
|
3
3
|
import { Adminizer } from "../lib/Adminizer";
|
|
4
4
|
export default function upload(req, res) {
|
|
5
|
-
//console.log('admin > CK-upload');
|
|
6
5
|
let entity = ControllerHelper.findEntityObject(req);
|
|
7
6
|
if (req.adminizer.config.auth.enable) {
|
|
8
|
-
if (!req.
|
|
7
|
+
if (!req.user) {
|
|
9
8
|
res.redirect(`${req.adminizer.config.routePrefix}/model/userap/login`);
|
|
10
9
|
return;
|
|
11
10
|
}
|
|
@@ -14,7 +13,7 @@ export default function upload(req, res) {
|
|
|
14
13
|
`create-${entity.name}-model`,
|
|
15
14
|
`update-${entity.name}-form`,
|
|
16
15
|
`create-${entity.name}-form`
|
|
17
|
-
], req.
|
|
16
|
+
], req.user)) {
|
|
18
17
|
res.sendStatus(403);
|
|
19
18
|
return;
|
|
20
19
|
}
|
package/controllers/dashboard.js
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
export default function (req, res) {
|
|
2
|
-
if (req.adminizer.config.auth.enable && !req.
|
|
2
|
+
if (req.adminizer.config.auth.enable && !req.user) {
|
|
3
3
|
return res.redirect(`${req.adminizer.config.routePrefix}/model/userap/login`);
|
|
4
4
|
}
|
|
5
5
|
return req.Inertia.render({
|
|
6
6
|
component: 'dashboard',
|
|
7
|
-
props:
|
|
7
|
+
props: {
|
|
8
|
+
title: req.i18n.__('Quick actions'),
|
|
9
|
+
tooltip: req.i18n.__('Toggle to change the grid. To save the grid, turn it off.'),
|
|
10
|
+
notWidgets: req.i18n.__('You don\'t have any widgets selected yet. You can add them by clicking on the plus sign at the top right.'),
|
|
11
|
+
notFound: req.i18n.__('No widgets found'),
|
|
12
|
+
actionsTitles: {
|
|
13
|
+
"All": req.i18n.__('All'),
|
|
14
|
+
'Custom': req.i18n.__('Custom'),
|
|
15
|
+
'Fast links': req.i18n.__('Fast links'),
|
|
16
|
+
'Actions': req.i18n.__('Actions'),
|
|
17
|
+
'Info': req.i18n.__('Info'),
|
|
18
|
+
'Switcher': req.i18n.__('Switcher')
|
|
19
|
+
},
|
|
20
|
+
searchPlaceholder: req.i18n.__('Search'),
|
|
21
|
+
}
|
|
8
22
|
});
|
|
9
23
|
}
|
|
10
24
|
;
|
package/controllers/edit.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ControllerHelper } from "../helpers/controllerHelper";
|
|
2
2
|
import { RequestProcessor } from "../lib/requestProcessor";
|
|
3
3
|
import { FieldsHelper } from "../helpers/fieldsHelper";
|
|
4
|
-
import { CatalogHandler } from "../lib/catalog/CatalogHandler";
|
|
4
|
+
import { CatalogHandler } from "../lib/v4/catalog/CatalogHandler";
|
|
5
5
|
import { getRelationsMediaManager, saveRelationsMediaManager } from "../lib/media-manager/helpers/MediaManagerHelper";
|
|
6
6
|
import { DataAccessor } from "../lib/v4/DataAccessor";
|
|
7
7
|
import { Adminizer } from "../lib/Adminizer";
|
|
@@ -19,10 +19,10 @@ export default async function edit(req, res) {
|
|
|
19
19
|
return res.redirect(`${req.adminizer.config.routePrefix}/${entity.uri}`);
|
|
20
20
|
}
|
|
21
21
|
if (req.adminizer.config.auth.enable) {
|
|
22
|
-
if (!req.
|
|
22
|
+
if (!req.user) {
|
|
23
23
|
return res.redirect(`${req.adminizer.config.routePrefix}/model/userap/login`);
|
|
24
24
|
}
|
|
25
|
-
else if (!req.adminizer.accessRightsHelper.hasPermission(`update-${entity.name}-model`, req.
|
|
25
|
+
else if (!req.adminizer.accessRightsHelper.hasPermission(`update-${entity.name}-model`, req.user)) {
|
|
26
26
|
return res.sendStatus(403);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -30,7 +30,7 @@ export default async function edit(req, res) {
|
|
|
30
30
|
let dataAccessor;
|
|
31
31
|
try {
|
|
32
32
|
const id = req.params.id;
|
|
33
|
-
dataAccessor = new DataAccessor(req, entity, "edit");
|
|
33
|
+
dataAccessor = new DataAccessor(req.adminizer, req.user, entity, "edit");
|
|
34
34
|
record = await entity.model.findOne({ id: id }, dataAccessor);
|
|
35
35
|
if (!record)
|
|
36
36
|
return res.status(404).send("Adminpanel > Record not found");
|
|
@@ -125,7 +125,7 @@ export default async function edit(req, res) {
|
|
|
125
125
|
for (const section of req.adminizer.config.navigation.sections) {
|
|
126
126
|
let navigation = CatalogHandler.getCatalog('navigation');
|
|
127
127
|
navigation.setId(section);
|
|
128
|
-
let navItem = navigation.itemTypes.find(item => item.type === entity.name);
|
|
128
|
+
let navItem = navigation.itemTypes.find(item => item.type === entity.name.toLowerCase());
|
|
129
129
|
if (navItem) {
|
|
130
130
|
await navItem.updateModelItems(newRecord[0].id, { record: newRecord[0] }, section);
|
|
131
131
|
}
|
|
@@ -145,7 +145,6 @@ export default async function edit(req, res) {
|
|
|
145
145
|
let fieldConfigConfig = fields[field].config;
|
|
146
146
|
if (fieldConfigConfig.type === 'mediamanager') {
|
|
147
147
|
if (fields[field].model.type === 'association-many') {
|
|
148
|
-
console.log(fieldConfigConfig.options);
|
|
149
148
|
record[field] = await getRelationsMediaManager({
|
|
150
149
|
list: record[field],
|
|
151
150
|
mediaManagerId: fieldConfigConfig.options.id ?? "default"
|
|
@@ -156,16 +155,13 @@ export default async function edit(req, res) {
|
|
|
156
155
|
}
|
|
157
156
|
}
|
|
158
157
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
// });
|
|
165
|
-
return null;
|
|
158
|
+
const props = inertiaAddHelper(req, entity, fields, record);
|
|
159
|
+
if (req.query?.without_layout) {
|
|
160
|
+
return res.json({
|
|
161
|
+
props: props
|
|
162
|
+
});
|
|
166
163
|
}
|
|
167
164
|
else {
|
|
168
|
-
const props = inertiaAddHelper(req, entity, fields, record);
|
|
169
165
|
return req.Inertia.render({
|
|
170
166
|
component: 'add',
|
|
171
167
|
props: props
|
package/controllers/editGroup.js
CHANGED
|
@@ -4,10 +4,10 @@ import { inertiaGroupHelper } from "../helpers/inertiaGroupHelper";
|
|
|
4
4
|
export default async function editGroup(req, res) {
|
|
5
5
|
let entity = ControllerHelper.findEntityObject(req);
|
|
6
6
|
if (req.adminizer.config.auth.enable) {
|
|
7
|
-
if (!req.
|
|
7
|
+
if (!req.user) {
|
|
8
8
|
return res.redirect(`${req.adminizer.config.routePrefix}/model/userap/login`);
|
|
9
9
|
}
|
|
10
|
-
else if (!req.adminizer.accessRightsHelper.hasPermission(`update-${entity.name}-model`, req.
|
|
10
|
+
else if (!req.adminizer.accessRightsHelper.hasPermission(`update-${entity.name}-model`, req.user)) {
|
|
11
11
|
return res.sendStatus(403);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
@@ -40,7 +40,6 @@ export default async function editGroup(req, res) {
|
|
|
40
40
|
}
|
|
41
41
|
let reloadNeeded = false;
|
|
42
42
|
if (req.method.toUpperCase() === 'POST') {
|
|
43
|
-
// console.log(req.body);
|
|
44
43
|
let allTokens = req.adminizer.accessRightsHelper.getTokens();
|
|
45
44
|
let usersInThisGroup = [];
|
|
46
45
|
let tokensOfThisGroup = [];
|
|
@@ -95,7 +94,6 @@ export default async function editGroup(req, res) {
|
|
|
95
94
|
Adminizer.log.error(e);
|
|
96
95
|
}
|
|
97
96
|
}
|
|
98
|
-
// console.log("GROUP", group)
|
|
99
97
|
const props = inertiaGroupHelper(entity, req, users, groupedTokens, group);
|
|
100
98
|
return req.Inertia.render({
|
|
101
99
|
component: 'add-group',
|
package/controllers/editUser.js
CHANGED
|
@@ -5,10 +5,10 @@ import { inertiaUserHelper } from "../helpers/inertiaUserHelper";
|
|
|
5
5
|
export default async function (req, res) {
|
|
6
6
|
let entity = ControllerHelper.findEntityObject(req);
|
|
7
7
|
if (req.adminizer.config.auth.enable) {
|
|
8
|
-
if (!req.
|
|
8
|
+
if (!req.user) {
|
|
9
9
|
return res.redirect(`${req.adminizer.config.routePrefix}/model/userap/login`);
|
|
10
10
|
}
|
|
11
|
-
else if (!req.adminizer.accessRightsHelper.hasPermission(`update-${entity.name}-model`, req.
|
|
11
|
+
else if (!req.adminizer.accessRightsHelper.hasPermission(`update-${entity.name}-model`, req.user)) {
|
|
12
12
|
return res.sendStatus(403);
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -36,7 +36,6 @@ export default async function (req, res) {
|
|
|
36
36
|
}
|
|
37
37
|
let reloadNeeded = false;
|
|
38
38
|
if (req.method.toUpperCase() === 'POST') {
|
|
39
|
-
// console.log(req.body);
|
|
40
39
|
let userGroups = [];
|
|
41
40
|
for (let key in req.body) {
|
|
42
41
|
if (key.startsWith("group-checkbox-") && req.body[key] === true) {
|
|
@@ -62,12 +61,11 @@ export default async function (req, res) {
|
|
|
62
61
|
locale: locale, isAdministrator: isAdministrator, isConfirmed: isConfirmed, groups: userGroups
|
|
63
62
|
});
|
|
64
63
|
if (req.body.userPassword) {
|
|
65
|
-
let passwordHashed = generate(req.body.login + req.body.userPassword);
|
|
64
|
+
let passwordHashed = generate(req.body.login + req.body.userPassword + process.env.AP_PASSWORD_SALT);
|
|
66
65
|
let password = 'masked';
|
|
67
66
|
// TODO refactor CRUD functions for DataAccessor usage
|
|
68
67
|
updatedUser = await req.adminizer.modelHandler.model.get("UserAP")["_updateOne"]({ id: user.id }, {
|
|
69
68
|
login: req.body.login,
|
|
70
|
-
password: password,
|
|
71
69
|
passwordHashed: passwordHashed
|
|
72
70
|
});
|
|
73
71
|
}
|
package/controllers/form.js
CHANGED
|
@@ -8,10 +8,10 @@ export default async function form(req, res) {
|
|
|
8
8
|
return res.status(404).send({ error: 'Not Found' });
|
|
9
9
|
}
|
|
10
10
|
if (req.adminizer.config.auth.enable) {
|
|
11
|
-
if (!req.
|
|
11
|
+
if (!req.user) {
|
|
12
12
|
return res.redirect(`${req.adminizer.config.routePrefix}/model/userap/login`);
|
|
13
13
|
}
|
|
14
|
-
else if (!req.adminizer.accessRightsHelper.hasPermission(`update-${slug}-form`, req.
|
|
14
|
+
else if (!req.adminizer.accessRightsHelper.hasPermission(`update-${slug}-form`, req.user)) {
|
|
15
15
|
return res.sendStatus(403);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -61,7 +61,6 @@ export default async function form(req, res) {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
const props = inertiaFormHelper(req, `${req.adminizer.config.routePrefix}/form/${slug}`, form);
|
|
64
|
-
// console.log(props)
|
|
65
64
|
return req.Inertia.render({
|
|
66
65
|
component: 'form',
|
|
67
66
|
props: props
|