adminizer 4.1.0-commit.d8a06d3 → 4.2.0-build.44
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-DujD3Z0j.js +1 -0
- package/assets/add-form-Ch5HOaI3.js +1 -0
- package/assets/add-group-form-CzjFRYQe.js +1 -0
- package/assets/add-group-xKUhiREd.js +1 -0
- package/assets/add-user-DpTQyN0Z.js +1 -0
- package/assets/add-user-form-DmgL9A2G.js +1 -0
- package/assets/{app-WTooYWC3.css → app-B6cCPfWk.css} +1 -1
- package/assets/app-layout-Dn8y3paC.js +1 -0
- package/assets/app-shell-C1wDrRCe.js +1 -0
- package/assets/app-sidebar-BisOEG_p.js +1 -0
- package/assets/app-sidebar-header-CL1OSuV8.js +11 -0
- package/assets/app.js +169 -39
- package/assets/breadcrumbs-BVZtAG3J.js +1 -0
- package/assets/catalog-Cc6Mk9sX.css +1 -0
- package/assets/catalog-CvJMAtEd.js +16 -0
- package/assets/{chevrons-up-down-kALltqHV.js → chevrons-up-down-D3t3UGV7.js} +2 -2
- package/assets/dashboard-Zsh-5yN2.js +3 -0
- package/assets/date-picker-DKdT6XTZ.js +6 -0
- package/assets/debounce-qdyXyOeG.js +1 -0
- package/assets/del-modal-DZ5wZWad.js +11 -0
- package/assets/{field-renderer-DVHZF6HS.js → field-renderer-Dgj1S2Vi.js} +137 -137
- package/assets/form-Bgv171J2.js +1 -0
- package/assets/form-DcfEHbPb.js +1 -0
- package/assets/{geo-json-BjiyTtMu.js → geo-json-vodY1YtH.js} +5 -5
- package/assets/{handsontable-4mjU_b0n.js → handsontable-C-ThjbaJ.js} +5 -5
- package/assets/home-DOm3EaLO.js +2 -0
- package/assets/icon-B-D8X0jg.js +1 -0
- package/assets/init-user-iMMcIQIW.js +1 -0
- package/assets/input-error-F1DL-Fx6.js +1 -0
- package/assets/list-B-vY1rhM.js +1 -0
- package/assets/list-table-8sDi0ZKa.js +52 -0
- package/assets/{check-LAUWAnlX.js → loader-circle-Btx4NYNU.js} +2 -2
- package/assets/login-C2J62v4_.js +6 -0
- package/assets/manifest.json +197 -965
- package/assets/material-icon-DeSoGIhT.js +1 -0
- package/assets/module-I4hW5UqT.js +1 -0
- package/assets/{monaco-editor-CJs0_GlD.js → monaco-editor-9fDiyfuW.js} +2 -2
- package/assets/{move-left-BhKZRPb4.js → move-left-DWHsVHUF.js} +1 -1
- package/assets/multi-select-Bu3n-kcV.js +11 -0
- package/assets/nav-footer-DQwIyd7c.js +1 -0
- package/assets/nav-main-DDQ-_Oed.js +1 -0
- package/assets/nav-user-BwBu-VwZ.js +1 -0
- package/assets/pagination-render-BoDDo2E1.js +1 -0
- package/assets/register-aPC0gjjS.js +1 -0
- package/assets/{toast-editor-CMK7QtF1.js → toast-editor-1Pul3oMs.js} +2 -2
- package/assets/{trash-2-BoK5Xp2F.js → trash-2-CsxWwHNc.js} +2 -2
- package/assets/use-appearance-J8J2w43p.js +1 -0
- package/assets/use-window-size-DLSEoR6e.js +1 -0
- package/assets/user-info-CnB2lvpg.js +1 -0
- package/assets/user-menu-content-BFbaJw6v.js +6 -0
- package/assets/welcome-DB_D6KJV.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 +24 -7
- 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/ui/components/ui/avatar.d.ts +6 -0
- package/ui/components/ui/avatar.js +13 -0
- package/ui/components/ui/badge.d.ts +9 -0
- package/ui/components/ui/badge.js +22 -0
- package/ui/components/ui/breadcrumb.d.ts +11 -0
- package/ui/components/ui/breadcrumb.js +27 -0
- package/ui/components/ui/button.d.ts +10 -0
- package/ui/components/ui/button.js +33 -0
- package/ui/components/ui/calendar.d.ts +4 -0
- package/ui/components/ui/calendar.js +38 -0
- package/ui/components/ui/card.d.ts +9 -0
- package/ui/components/ui/card.js +24 -0
- package/ui/components/ui/checkbox.d.ts +4 -0
- package/ui/components/ui/checkbox.js +8 -0
- package/ui/components/ui/collapsible.d.ts +5 -0
- package/ui/components/ui/collapsible.js +12 -0
- package/ui/components/ui/command.d.ts +16 -0
- package/ui/components/ui/command.js +33 -0
- package/ui/components/ui/context-menu.d.ts +25 -0
- package/ui/components/ui/context-menu.js +50 -0
- package/ui/components/ui/dialog-stack.d.ts +43 -0
- package/ui/components/ui/dialog-stack.js +238 -0
- package/ui/components/ui/dialog.d.ts +13 -0
- package/ui/components/ui/dialog.js +35 -0
- package/ui/components/ui/dropdown-menu.d.ts +25 -0
- package/ui/components/ui/dropdown-menu.js +50 -0
- package/ui/components/ui/input.d.ts +3 -0
- package/ui/components/ui/input.js +6 -0
- package/ui/components/ui/label.d.ts +4 -0
- package/ui/components/ui/label.js +7 -0
- package/ui/components/ui/menubar.d.ts +26 -0
- package/ui/components/ui/menubar.js +53 -0
- package/ui/components/ui/pagination.d.ts +13 -0
- package/ui/components/ui/pagination.js +29 -0
- package/ui/components/ui/popover.d.ts +7 -0
- package/ui/components/ui/popover.js +16 -0
- package/ui/components/ui/select.d.ts +15 -0
- package/ui/components/ui/select.js +37 -0
- package/ui/components/ui/separator.d.ts +4 -0
- package/ui/components/ui/separator.js +8 -0
- package/ui/components/ui/sheet.d.ts +13 -0
- package/ui/components/ui/sheet.js +39 -0
- package/ui/components/ui/sidebar.d.ts +69 -0
- package/ui/components/ui/sidebar.js +211 -0
- package/ui/components/ui/skeleton.d.ts +2 -0
- package/ui/components/ui/skeleton.js +6 -0
- package/ui/components/ui/slider.d.ts +4 -0
- package/ui/components/ui/slider.js +13 -0
- package/ui/components/ui/sonner.d.ts +3 -0
- package/ui/components/ui/sonner.js +12 -0
- package/ui/components/ui/switch.d.ts +4 -0
- package/ui/components/ui/switch.js +7 -0
- package/ui/components/ui/table.d.ts +10 -0
- package/ui/components/ui/table.js +27 -0
- package/ui/components/ui/textarea.d.ts +3 -0
- package/ui/components/ui/textarea.js +6 -0
- package/ui/components/ui/tooltip.d.ts +7 -0
- package/ui/components/ui/tooltip.js +17 -0
- package/ui/hooks/use-mobile.d.ts +1 -0
- package/ui/hooks/use-mobile.js +15 -0
- package/ui/lib/utils.d.ts +2 -0
- package/ui/lib/utils.js +5 -0
- 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/chevron-down-B5XuAFRu.js +0 -6
- package/assets/chevron-left-CoMhTMUD.js +0 -6
- package/assets/chevron-right-D5q8rF7h.js +0 -6
- package/assets/compiler-runtime-hB6dAw2d.js +0 -9
- package/assets/createLucideIcon-BFG25zNo.js +0 -21
- package/assets/dashboard-BACj996r.js +0 -3
- package/assets/date-picker-DI1cCO7K.js +0 -6
- 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-Cgp8OfuI.js +0 -1
- package/assets/index-Cw5o84pO.js +0 -10
- package/assets/index-D5ir9iUV.js +0 -1
- package/assets/index-DrWfGwtf.js +0 -1
- package/assets/index-DwctwfU0.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/loader-circle-Utah5tGx.js +0 -6
- 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/multi-select-BvRpAW8r.js +0 -11
- 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/search-BspystAk.js +0 -6
- package/assets/select-BWepUw-9.js +0 -6
- package/assets/sidebar-CAHsHdjM.js +0 -6
- 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-info-DFrmpJ4y.js +0 -9
- 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
|
@@ -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) {
|
|
@@ -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.user.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,94 +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
|
-
const item = await this.catalog.find(reqNode.data);
|
|
118
|
-
if (!item) {
|
|
119
|
-
throw `reqNode Item not found`;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
119
|
// Update all items into parent (for two reason: update parent, updare sorting order)
|
|
123
120
|
let sortCount = 0;
|
|
124
121
|
for (const childNode of reqParent.children) {
|
|
125
122
|
childNode.data.sortOrder = sortCount;
|
|
126
123
|
childNode.data.parentId = reqParent.data.id;
|
|
127
|
-
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);
|
|
128
125
|
sortCount++;
|
|
129
126
|
}
|
|
130
127
|
return Promise.resolve('ok');
|
|
131
128
|
}
|
|
132
|
-
async updateItem(item, modelId, data) {
|
|
129
|
+
async updateItem(item, modelId, data, req) {
|
|
130
|
+
//TODO It's not clear why it's here.
|
|
133
131
|
//data = VueCatalogUtils.refinement(data);
|
|
134
|
-
if (this.catalog.slug !== "navigation") {
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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);
|
|
148
147
|
return { ok: true };
|
|
149
148
|
}
|
|
150
149
|
}
|
|
@@ -161,16 +160,16 @@ export class VueCatalogUtils {
|
|
|
161
160
|
static toNode(data, groupTypeName) {
|
|
162
161
|
return {
|
|
163
162
|
data: data,
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
163
|
+
droppable: data.type === groupTypeName,
|
|
164
|
+
id: data.id,
|
|
165
|
+
text: data.name,
|
|
166
|
+
parent: data.parentId,
|
|
168
167
|
};
|
|
169
168
|
}
|
|
170
169
|
static expandTo(vueCatalogData, theseItemIdsNeedToBeOpened) {
|
|
171
170
|
function expand(node) {
|
|
172
171
|
if (theseItemIdsNeedToBeOpened.includes(node.data.id)) {
|
|
173
|
-
node.isExpanded = true;
|
|
172
|
+
// node.isExpanded = true;
|
|
174
173
|
}
|
|
175
174
|
if (node.children) {
|
|
176
175
|
for (const child of node.children) {
|
|
@@ -191,7 +190,7 @@ export class VueCatalogUtils {
|
|
|
191
190
|
// Sort the children before building their nodes
|
|
192
191
|
item.childs.sort((a, b) => (a.sortOrder || 0) - (b.sortOrder || 0));
|
|
193
192
|
node.children = buildNodes(item.childs);
|
|
194
|
-
node.isExpanded = !node.
|
|
193
|
+
// node.isExpanded = !node.droppable;
|
|
195
194
|
}
|
|
196
195
|
return node;
|
|
197
196
|
});
|
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";
|
|
@@ -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
|
}
|
|
@@ -155,16 +155,13 @@ export default async function edit(req, res) {
|
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
// });
|
|
164
|
-
return null;
|
|
158
|
+
const props = inertiaAddHelper(req, entity, fields, record);
|
|
159
|
+
if (req.query?.without_layout) {
|
|
160
|
+
return res.json({
|
|
161
|
+
props: props
|
|
162
|
+
});
|
|
165
163
|
}
|
|
166
164
|
else {
|
|
167
|
-
const props = inertiaAddHelper(req, entity, fields, record);
|
|
168
165
|
return req.Inertia.render({
|
|
169
166
|
component: 'add',
|
|
170
167
|
props: props
|
package/controllers/list.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ControllerHelper } from "../helpers/controllerHelper";
|
|
2
2
|
import { DataAccessor } from "../lib/v4/DataAccessor";
|
|
3
|
-
import { NodeTable } from "../lib/datatable/NodeTable";
|
|
3
|
+
import { NodeTable } from "../lib/v4/datatable/NodeTable";
|
|
4
4
|
import { Adminizer } from "../lib/Adminizer";
|
|
5
5
|
import { inertiaListHelper } from "../helpers/inertiaListHelper";
|
|
6
6
|
export default async function list(req, res) {
|
|
@@ -16,7 +16,7 @@ export default async function list(req, res) {
|
|
|
16
16
|
return res.sendStatus(403);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
let dataAccessor = new DataAccessor(req, entity, "list");
|
|
19
|
+
let dataAccessor = new DataAccessor(req.adminizer, req.user, entity, "list");
|
|
20
20
|
let fields = dataAccessor.getFieldsConfig();
|
|
21
21
|
const header = inertiaListHelper(entity, req, fields);
|
|
22
22
|
let start = "0";
|
package/controllers/login.js
CHANGED
|
@@ -33,10 +33,12 @@ export default async function login(req, res) {
|
|
|
33
33
|
}
|
|
34
34
|
return req.Inertia.redirect(`${req.adminizer.config.routePrefix}/`);
|
|
35
35
|
}
|
|
36
|
-
// Verify CAPTCHA solution
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
// Verify CAPTCHA solution if enabled
|
|
37
|
+
if (req.adminizer.config.auth.captcha !== false) {
|
|
38
|
+
const isCaptchaValid = powCaptcha.check(captchaSolution, `login:${req.ip}`);
|
|
39
|
+
if (!isCaptchaValid) {
|
|
40
|
+
return inertiaAdminMessage(req, "Invalid CAPTCHA solution", 'captchaSolution');
|
|
41
|
+
}
|
|
40
42
|
}
|
|
41
43
|
if (!user) {
|
|
42
44
|
return inertiaAdminMessage(req, "Wrong username", 'login');
|
|
@@ -66,8 +68,11 @@ export default async function login(req, res) {
|
|
|
66
68
|
}
|
|
67
69
|
}
|
|
68
70
|
if (req.method.toUpperCase() === "GET") {
|
|
69
|
-
// Generate new CAPTCHA
|
|
70
|
-
|
|
71
|
+
// Generate new CAPTCHA task if enabled
|
|
72
|
+
let captchaTask = [];
|
|
73
|
+
if (req.adminizer.config.auth.captcha !== false) {
|
|
74
|
+
captchaTask = await powCaptcha.getJob(`login:${req.ip}`);
|
|
75
|
+
}
|
|
71
76
|
return req.Inertia.render({
|
|
72
77
|
component: 'login',
|
|
73
78
|
props: {
|
|
@@ -97,7 +102,11 @@ export default async function login(req, res) {
|
|
|
97
102
|
async function inertiaAdminMessage(req, message, messageType) {
|
|
98
103
|
Adminizer.log.warn(message);
|
|
99
104
|
const powCaptcha = new POWCaptcha();
|
|
100
|
-
|
|
105
|
+
// Generate new CAPTCHA task if enabled
|
|
106
|
+
let captchaTask = [];
|
|
107
|
+
if (req.adminizer.config.auth.captcha !== false) {
|
|
108
|
+
captchaTask = await powCaptcha.getJob(`login:${req.ip}`);
|
|
109
|
+
}
|
|
101
110
|
let errors = {};
|
|
102
111
|
errors[messageType] = message;
|
|
103
112
|
return req.Inertia.render({
|
|
@@ -7,7 +7,7 @@ export default async function edit(req, res) {
|
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
let entity = ControllerHelper.findEntityObject(req);
|
|
10
|
-
let dataAccessor = new DataAccessor(req, entity, "edit");
|
|
10
|
+
let dataAccessor = new DataAccessor(req.adminizer, req.user, entity, "edit");
|
|
11
11
|
let record = await entity.model.findOne({ id: req.params.id }, dataAccessor);
|
|
12
12
|
return res.redirect(`${req.adminizer.config.routePrefix}/catalog/navigation/${record.label}`);
|
|
13
13
|
}
|
package/controllers/remove.js
CHANGED
|
@@ -31,7 +31,7 @@ export default async function remove(req, res) {
|
|
|
31
31
|
let record;
|
|
32
32
|
let dataAccessor;
|
|
33
33
|
try {
|
|
34
|
-
dataAccessor = new DataAccessor(req, entity, "remove");
|
|
34
|
+
dataAccessor = new DataAccessor(req.adminizer, req.user, entity, "remove");
|
|
35
35
|
record = await entity.model.findOne({ id: req.params.id }, dataAccessor);
|
|
36
36
|
}
|
|
37
37
|
catch (e) {
|
package/controllers/view.js
CHANGED
|
@@ -25,7 +25,7 @@ export default async function view(req, res) {
|
|
|
25
25
|
return res.sendStatus(403);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
let dataAccessor = new DataAccessor(req, entity, "view");
|
|
28
|
+
let dataAccessor = new DataAccessor(req.adminizer, req.user, entity, "view");
|
|
29
29
|
let fields = dataAccessor.getFieldsConfig();
|
|
30
30
|
let record;
|
|
31
31
|
try {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isObject(obj: unknown): obj is object;
|
|
@@ -13,3 +13,6 @@ export declare class AccessRightsHelper {
|
|
|
13
13
|
enoughPermissions(tokens: string[], user: UserAP): boolean;
|
|
14
14
|
hasPermission(tokenId: string, user: UserAP): boolean;
|
|
15
15
|
}
|
|
16
|
+
export declare class GroupsAccessRightsHelper {
|
|
17
|
+
static hasAccess(user: UserAP, groupsAccessRights?: string[]): boolean;
|
|
18
|
+
}
|
|
@@ -6,12 +6,14 @@ export class AccessRightsHelper {
|
|
|
6
6
|
this.adminizer = adminizer;
|
|
7
7
|
}
|
|
8
8
|
registerToken(accessRightsToken) {
|
|
9
|
+
accessRightsToken.id = accessRightsToken.id.toLowerCase();
|
|
9
10
|
if (!accessRightsToken.id || !accessRightsToken.name || !accessRightsToken.description || !accessRightsToken.department) {
|
|
10
11
|
throw new Error("Adminpanel > Can not register token: Missed one or more required parameters");
|
|
11
12
|
}
|
|
12
|
-
for (let
|
|
13
|
-
if (
|
|
14
|
-
|
|
13
|
+
for (let i = 0; i < this._tokens.length; i++) {
|
|
14
|
+
if (this._tokens[i].id === accessRightsToken.id) {
|
|
15
|
+
this._tokens.splice(i, 1);
|
|
16
|
+
break;
|
|
15
17
|
}
|
|
16
18
|
}
|
|
17
19
|
this._tokens.push(accessRightsToken);
|
|
@@ -42,6 +44,11 @@ export class AccessRightsHelper {
|
|
|
42
44
|
return tokens.some((token) => this.hasPermission(token, user));
|
|
43
45
|
}
|
|
44
46
|
hasPermission(tokenId, user) {
|
|
47
|
+
if (!tokenId) {
|
|
48
|
+
Adminizer.log.error(`AccessRightsHelper > hasPermission no tokenId: ${tokenId}`);
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
tokenId = tokenId.toLowerCase();
|
|
45
52
|
if (!this.adminizer.config.auth.enable) {
|
|
46
53
|
return true;
|
|
47
54
|
}
|
|
@@ -50,9 +57,25 @@ export class AccessRightsHelper {
|
|
|
50
57
|
}
|
|
51
58
|
const tokenIsValid = this._tokens.some((token) => token.id === tokenId);
|
|
52
59
|
if (!tokenIsValid) {
|
|
53
|
-
Adminizer.log.error("Adminpanel > Token is not valid");
|
|
60
|
+
Adminizer.log.error("Adminpanel > Token is not valid", tokenId, user.login);
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
if (!user.groups) {
|
|
64
|
+
Adminizer.log.error('User has no groups');
|
|
54
65
|
return false;
|
|
55
66
|
}
|
|
56
67
|
return user.groups.some((group) => group.tokens?.includes(tokenId));
|
|
57
68
|
}
|
|
58
69
|
}
|
|
70
|
+
export class GroupsAccessRightsHelper {
|
|
71
|
+
static hasAccess(user, groupsAccessRights) {
|
|
72
|
+
const userGroups = user.groups?.map(group => group.name.toLowerCase());
|
|
73
|
+
if (groupsAccessRights) {
|
|
74
|
+
const allowedGroups = groupsAccessRights.map(item => item.toLowerCase());
|
|
75
|
+
return userGroups?.some(group => allowedGroups.includes(group)) ?? false;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|