adminizer 4.1.0-build.3 → 4.1.0-build.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Readme.md +11 -1
- package/assets/{VanillaJSONEditor-FUe77pIA.js → VanillaJSONEditor-DTWads1Y.js} +104 -104
- package/assets/add-NjsCZZct.js +1 -0
- package/assets/add-form-DJnEBqvy.js +1 -0
- package/assets/add-group-CU2zD7To.js +1 -0
- package/assets/add-group-form-CQN_syZq.js +1 -0
- package/assets/add-user-BkTa9shp.js +1 -0
- package/assets/add-user-form-C7T14FsG.js +1 -0
- package/assets/{app-DMmad2-f.css → app-DVaaqBB5.css} +1 -1
- package/assets/app-layout-NY6MXzc5.js +1 -0
- package/assets/{app-shell-BWMRMkHM.js → app-shell-BjaxjNs9.js} +1 -1
- package/assets/app-sidebar-CLu13Pcu.js +1 -0
- package/assets/{app-sidebar-header-DLAFi13E.js → app-sidebar-header-5IaQpngt.js} +1 -1
- package/assets/app.js +9 -9
- package/assets/{breadcrumbs-CQNon4Vl.js → breadcrumbs-CDxSbsTe.js} +1 -1
- package/assets/button-BV-GbIpN.js +1 -0
- package/assets/catalog-Cc6Mk9sX.css +1 -0
- package/assets/catalog-CeUUKxG9.js +17 -0
- package/assets/{checkbox-W0nGAXIj.js → checkbox-DrkQu16U.js} +1 -1
- package/assets/{compiler-runtime-tM4jBQ-T.js → compiler-runtime-Cj7rbuyn.js} +2 -2
- package/assets/dashboard-BOltB2Hq.css +1 -0
- package/assets/dashboard-BTmXuc5F.js +3 -0
- package/assets/{date-picker-B__dVVqj.js → date-picker-hoDPF9Am.js} +1 -1
- package/assets/debounce-qdyXyOeG.js +1 -0
- package/assets/del-modal-BUVjhY0k.js +6 -0
- package/assets/dialog-stack-BAuaxCy1.js +1 -0
- package/assets/dropdown-menu-CeMIoM8d.js +1 -0
- package/assets/{field-renderer-CapylJU9.js → field-renderer-zGC76llY.js} +3 -3
- package/assets/form-CN2xVSMK.js +1 -0
- package/assets/form-DOt5Fa6e.js +1 -0
- package/assets/{geo-json-CwteYDGB.js → geo-json-VtXcqPd9.js} +1 -1
- package/assets/group-link-add-CCNISxeF.js +1 -0
- package/assets/{handsontable-BCnjOpBr.js → handsontable-DrEU6lOi.js} +1 -1
- package/assets/home-3FBATYFh.js +2 -0
- package/assets/{icon-Bz9BMaD0.js → icon-CqJOMij7.js} +1 -1
- package/assets/index-BCpOvf4m.js +1 -0
- package/assets/{index-BbXEMx9n.js → index-B__NksD2.js} +1 -1
- package/assets/{index-DTRTjOmh.js → index-C0o7vG6r.js} +3 -3
- package/assets/{index-C0SL3SHw.js → index-CcxvoJO6.js} +1 -1
- package/assets/{index-D5ir9iUV.js → index-Cq31rrfZ.js} +1 -1
- package/assets/{index-K81GbF6O.js → index-DN1K56yz.js} +1 -1
- package/assets/{index-DrWfGwtf.js → index-DU8vYhyh.js} +1 -1
- package/assets/{index-BcE9FUM6.js → index-DoVAC0HX.js} +1 -1
- package/assets/{index-BC0yfOHo.js → index-lqMxC6QB.js} +1 -1
- package/assets/{index-DEk3sC8d.js → index-oMAR28Sy.js} +1 -1
- package/assets/{init-user-D9mW-g14.js → init-user-BBfP40-3.js} +1 -1
- package/assets/{input-DF7Ue23C.js → input-B7wUhbil.js} +1 -1
- package/assets/{input-error-BBygona6.js → input-error-DFk1EyT_.js} +1 -1
- package/assets/item-add-CX7EOX0H.js +1 -0
- package/assets/{label-Z506NKsW.js → label-GEoZpZr4.js} +1 -1
- package/assets/list-DqIUjXSX.js +1 -0
- package/assets/list-table-1aXDvDPl.js +57 -0
- package/assets/{login-DrGaTWhY.js → login-Bv4hqwaM.js} +2 -2
- package/assets/manifest.json +788 -604
- package/assets/{material-icon-CItZiB53.js → material-icon-BAd3Wrgn.js} +1 -1
- package/assets/module-DziT22BH.js +1 -0
- package/assets/{monaco-editor-DqAqwxw4.js → monaco-editor-B5kndNv5.js} +1 -1
- package/assets/{multi-select-oabtVhUP.js → multi-select-CSxVlxon.js} +2 -2
- package/assets/{nav-footer-CM-yHiRs.js → nav-footer-Vm24wf5X.js} +1 -1
- package/assets/{nav-main-Q3xofGRT.js → nav-main-JVt9gzn8.js} +1 -1
- package/assets/{nav-user-Ds8i0Pa2.js → nav-user-DgYX0wO7.js} +1 -1
- package/assets/{pagination-render-B57pOpFy.js → pagination-render-B12W01AJ.js} +1 -1
- package/assets/{popover-I249Gg2O.js → popover-B3ZOyoLQ.js} +1 -1
- package/assets/{register-C9FQIDtS.js → register-D8SyTFBZ.js} +1 -1
- package/assets/{select-D1N8zRPY.js → select-MzwxLt1D.js} +2 -2
- package/assets/{sidebar-4D-sX2l4.js → sidebar-DGp3i7GG.js} +2 -2
- package/assets/skeleton-C3gmNc1Z.js +1 -0
- package/assets/{sonner-Dzckw3U3.js → sonner-MAL0i2dq.js} +1 -1
- package/assets/{toast-editor-FbrFd1ft.js → toast-editor-DRP2u8-X.js} +1 -1
- package/assets/{tooltip-D2ehgLlB.js → tooltip-Du62rBCn.js} +1 -1
- package/assets/{use-appearance-Co6mO0dV.js → use-appearance-DeUiDZ72.js} +1 -1
- package/assets/{use-window-size-B8l6Bpkf.js → use-window-size-ChEjEujj.js} +1 -1
- package/assets/{user-info-DBYoAJYJ.js → user-info-C_11jYGE.js} +1 -1
- package/assets/{user-menu-content-qkvdkUVd.js → user-menu-content-BNRzhEo_.js} +2 -2
- package/assets/welcome-C9BMKsoY.js +1 -0
- package/controllers/add.js +10 -10
- package/controllers/addGroup.js +2 -4
- package/controllers/addUser.js +4 -6
- package/controllers/catalog/Catalog.d.ts +1 -1
- package/controllers/catalog/Catalog.js +42 -36
- package/controllers/catalog/FrontentCatalogAdapter.d.ts +39 -25
- package/controllers/catalog/FrontentCatalogAdapter.js +55 -55
- package/controllers/ckeditorUpload.js +2 -3
- package/controllers/dashboard.js +16 -2
- package/controllers/edit.js +10 -14
- package/controllers/editGroup.js +2 -4
- package/controllers/editUser.js +3 -5
- package/controllers/form.js +2 -3
- package/controllers/getAllWidgets.js +3 -3
- package/controllers/initUser.js +1 -2
- package/controllers/list.js +6 -6
- package/controllers/login.js +31 -15
- package/controllers/media-manager/mediaManagerAdapter.js +1 -2
- package/controllers/media-manager/mediaManagerApi.js +2 -2
- package/controllers/navigation/edit.js +2 -2
- package/controllers/register.js +1 -4
- package/controllers/remove.js +3 -3
- package/controllers/timezones.js +1 -1
- package/controllers/view.js +3 -3
- package/controllers/welcome.js +1 -1
- package/controllers/widgets/Action.js +2 -2
- package/controllers/widgets/Custom.js +2 -2
- package/controllers/widgets/Info.js +2 -2
- package/controllers/widgets/switch.js +2 -2
- package/controllers/widgetsDB.js +5 -5
- package/helpers/JsUtils.d.ts +1 -0
- package/helpers/JsUtils.js +3 -0
- package/helpers/accessRightsHelper.d.ts +6 -2
- package/helpers/accessRightsHelper.js +26 -3
- package/helpers/configHelper.js +2 -1
- package/helpers/controllerHelper.js +39 -18
- package/helpers/fieldsHelper.d.ts +4 -3
- package/helpers/fieldsHelper.js +5 -1
- package/helpers/inertiaActionsHelper.js +1 -1
- package/helpers/inertiaAddHelper.d.ts +3 -4
- package/helpers/inertiaAddHelper.js +27 -7
- package/helpers/inertiaFromHelper.js +2 -0
- package/helpers/inertiaGroupHelper.d.ts +4 -2
- package/helpers/inertiaGroupHelper.js +1 -1
- package/helpers/inertiaListHelper.js +5 -5
- package/helpers/inertiaMenuHelper.d.ts +1 -1
- package/helpers/inertiaMenuHelper.js +2 -2
- package/helpers/inertiaUserHelper.d.ts +7 -1
- package/helpers/inertiaUserHelper.js +5 -1
- package/helpers/menuHelper.d.ts +4 -3
- package/helpers/menuHelper.js +22 -15
- package/index.d.ts +5 -3
- package/index.js +8 -3
- package/interfaces/adminpanelConfig.d.ts +29 -32
- package/interfaces/global.d.ts +10 -28
- package/interfaces/types.d.ts +1 -1
- package/lib/Adminizer.d.ts +4 -2
- package/lib/Adminizer.js +33 -11
- package/lib/media-manager/AbstractMediaManager.d.ts +2 -2
- package/lib/media-manager/AbstractMediaManager.js +1 -1
- package/lib/media-manager/Items.js +0 -3
- package/lib/requestProcessor.js +10 -3
- package/lib/v4/DataAccessor.d.ts +5 -2
- package/lib/v4/DataAccessor.js +44 -19
- package/lib/v4/I18n.js +2 -0
- package/lib/v4/POWCaptcha.js +0 -1
- package/lib/v4/PolicyManager.js +0 -1
- package/lib/{catalog → v4/catalog}/AbstractCatalog.d.ts +79 -41
- package/lib/{catalog → v4/catalog}/AbstractCatalog.js +49 -41
- package/lib/v4/catalog/Navigation.d.ts +43 -0
- package/lib/v4/catalog/Navigation.js +457 -0
- package/lib/{controls → v4/controls}/AbstractControls.d.ts +1 -1
- package/lib/{controls → v4/controls}/codeEditor/MonacoEditor.d.ts +1 -1
- package/lib/{controls → v4/controls}/geojsoneditor/GeoEditor.d.ts +1 -1
- package/lib/{controls → v4/controls}/jsoneditor/JsonEditor.d.ts +1 -1
- package/lib/{controls → v4/controls}/markdown/ToastUiEditor.d.ts +1 -1
- package/lib/{controls → v4/controls}/table/Handsontable.d.ts +1 -1
- package/lib/{controls → v4/controls}/wysiwyg/CKeditor.d.ts +1 -1
- package/lib/{datatable → v4/datatable}/NodeTable.d.ts +3 -3
- package/lib/{datatable → v4/datatable}/NodeTable.js +8 -8
- package/lib/v4/helper/jwt.d.ts +10 -0
- package/lib/v4/helper/jwt.js +18 -0
- package/lib/{inertia → v4/inertia}/inertiaAdapter.js +0 -1
- package/lib/v4/model/AbstractModel.d.ts +5 -1
- package/lib/v4/model/AbstractModel.js +2 -3
- package/lib/v4/model/ModelHandler.js +1 -1
- package/lib/v4/model/adapter/sequelize.d.ts +11 -2
- package/lib/v4/model/adapter/sequelize.js +451 -118
- package/lib/v4/model/adapter/waterline.js +5 -3
- package/lib/{widgets → v4/widgets}/abstractAction.d.ts +1 -1
- package/lib/v4/widgets/abstractCustom.d.ts +28 -0
- package/lib/v4/widgets/abstractCustom.js +9 -0
- package/lib/{widgets → v4/widgets}/abstractInfo.d.ts +1 -1
- package/lib/{widgets → v4/widgets}/abstractInfo.js +1 -1
- package/lib/{widgets → v4/widgets}/abstractLink.d.ts +2 -1
- package/lib/{widgets → v4/widgets}/abstractSwitch.d.ts +1 -1
- package/lib/{widgets → v4/widgets}/abstractWidgetBase.d.ts +2 -2
- package/lib/{widgets → v4/widgets}/widgetHandler.d.ts +29 -5
- package/lib/{widgets → v4/widgets}/widgetHandler.js +25 -25
- package/models/GroupAP.d.ts +8 -0
- package/models/NavigationAP.d.ts +7 -3
- package/models/NavigationAP.js +5 -6
- package/models/UserAP.d.ts +24 -2
- package/models/UserAP.js +2 -2
- package/package.json +27 -11
- package/policies/checkAuth.js +4 -3
- package/policies/setLocale.js +2 -2
- package/system/Router.js +8 -16
- package/system/bindAccessRights.js +0 -4
- package/system/bindAuthorization.js +4 -5
- package/system/bindControls.js +6 -6
- package/system/bindDev.js +1 -0
- package/system/bindInertia.js +12 -11
- package/system/bindMediaManager.js +0 -1
- package/system/bindModels.js +8 -5
- package/system/bindNavigation.d.ts +2 -0
- package/system/bindNavigation.js +42 -42
- package/system/bindReqFunctions.js +15 -0
- package/system/defaults.js +2 -2
- package/translations/ru.json +17 -8
- package/assets/add-ZITr43GJ.js +0 -1
- package/assets/add-form-CYOfr0Ef.js +0 -1
- package/assets/add-group-B332wN8K.js +0 -1
- package/assets/add-group-form-dzadPSfL.js +0 -1
- package/assets/add-user-TC-mYdsB.js +0 -1
- package/assets/add-user-form-y2f_1_lM.js +0 -1
- package/assets/app-layout-D1m9Kvxq.js +0 -1
- package/assets/app-sidebar-BCtaEFGb.js +0 -1
- package/assets/button-CQ9t1kLz.js +0 -1
- package/assets/dashboard-BR602KhL.js +0 -1
- package/assets/dropdown-menu-SEBnEIiL.js +0 -1
- package/assets/form-DOUNk3o2.js +0 -1
- package/assets/form-lOKv4Qbw.js +0 -1
- package/assets/home-Ch6QfTIt.js +0 -2
- package/assets/index-Cdb9ACvz.js +0 -1
- package/assets/list-Qyd7ecQH.js +0 -1
- package/assets/list-table-DB1sEQLF.js +0 -62
- package/assets/module-DBaykv8l.js +0 -1
- package/assets/welcome-D2adQ8EU.js +0 -1
- package/controllers/processInstallFinalize.d.ts +0 -1
- package/controllers/processInstallFinalize.js +0 -16
- package/controllers/processInstallStep.d.ts +0 -1
- package/controllers/processInstallStep.js +0 -132
- package/lib/catalog/Navigation.d.ts +0 -0
- package/lib/catalog/Navigation.js +0 -532
- package/lib/installStepper/InstallStepAbstract.d.ts +0 -52
- package/lib/installStepper/InstallStepAbstract.js +0 -69
- package/lib/installStepper/finalizeStep.d.ts +0 -21
- package/lib/installStepper/finalizeStep.js +0 -48
- package/lib/installStepper/installStepper.d.ts +0 -40
- package/lib/installStepper/installStepper.js +0 -195
- package/lib/widgets/abstractCustom.d.ts +0 -13
- package/lib/widgets/abstractCustom.js +0 -3
- package/models/MediaManagerAP.d.ts +0 -46
- package/models/MediaManagerAP.js +0 -45
- package/models/MediaManagerAssociationsAP.d.ts +0 -28
- package/models/MediaManagerAssociationsAP.js +0 -27
- package/models/MediaManagerMetaAP.d.ts +0 -22
- package/models/MediaManagerMetaAP.js +0 -21
- package/system/bindInstallStepper.d.ts +0 -2
- package/system/bindInstallStepper.js +0 -23
- /package/lib/{catalog → v4/catalog}/CatalogHandler.d.ts +0 -0
- /package/lib/{catalog → v4/catalog}/CatalogHandler.js +0 -0
- /package/lib/{controls → v4/controls}/AbstractControls.js +0 -0
- /package/lib/{controls → v4/controls}/ControlsHandler.d.ts +0 -0
- /package/lib/{controls → v4/controls}/ControlsHandler.js +0 -0
- /package/lib/{controls → v4/controls}/codeEditor/MonacoEditor.js +0 -0
- /package/lib/{controls → v4/controls}/geojsoneditor/GeoEditor.js +0 -0
- /package/lib/{controls → v4/controls}/jsoneditor/JsonEditor.js +0 -0
- /package/lib/{controls → v4/controls}/markdown/ToastUiEditor.js +0 -0
- /package/lib/{controls → v4/controls}/table/Handsontable.js +0 -0
- /package/lib/{controls → v4/controls}/wysiwyg/CKeditor.js +0 -0
- /package/lib/{inertia → v4/inertia}/flash.d.ts +0 -0
- /package/lib/{inertia → v4/inertia}/flash.js +0 -0
- /package/lib/{inertia → v4/inertia}/inertiaAdapter.d.ts +0 -0
- /package/lib/{widgets → v4/widgets}/abstractAction.js +0 -0
- /package/lib/{widgets → v4/widgets}/abstractLink.js +0 -0
- /package/lib/{widgets → v4/widgets}/abstractSwitch.js +0 -0
- /package/lib/{widgets → v4/widgets}/abstractWidgetBase.js +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{j as t,J as u}from"./app.js";import{c as f}from"./compiler-runtime-
|
|
1
|
+
import{j as t,J as u}from"./app.js";import{c as f}from"./compiler-runtime-Cj7rbuyn.js";import{c as d,d as x,e as h}from"./dropdown-menu-CeMIoM8d.js";import{UserInfo as y}from"./user-info-C_11jYGE.js";import{c as j}from"./createLucideIcon-BFG25zNo.js";import"./index-BCpOvf4m.js";import"./index-Cq31rrfZ.js";import"./index-DN1K56yz.js";import"./index-DU8vYhyh.js";import"./index-oMAR28Sy.js";import"./index-B__NksD2.js";import"./index-CcxvoJO6.js";import"./index-lqMxC6QB.js";import"./utils-DjqsqOe8.js";/**
|
|
2
2
|
* @license lucide-react v0.485.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const
|
|
6
|
+
*/const g=[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]],b=j("log-out",g);function _(){return M}function M(){document.body.style.removeProperty("pointer-events")}function B(p){const e=f.c(11),{user:l,logout:m,logoutBtn:c}=p,a=_();let o;e[0]!==l?(o=t.jsx(d,{className:"p-0 font-normal",children:t.jsx("div",{className:"flex items-center gap-2 px-1 py-1.5 text-left text-sm",children:t.jsx(y,{user:l,showEmail:!0})})}),e[0]=l,e[1]=o):o=e[1];let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsx(x,{}),e[2]=s):s=e[2];let n;e[3]===Symbol.for("react.memo_cache_sentinel")?(n=t.jsx(b,{className:"mr-2"}),e[3]=n):n=e[3];let r;e[4]!==a||e[5]!==m||e[6]!==c?(r=t.jsx(h,{asChild:!0,children:t.jsxs(u,{className:"block w-full cursor-pointer",method:"get",href:m,as:"button",onClick:a,children:[n,c]})}),e[4]=a,e[5]=m,e[6]=c,e[7]=r):r=e[7];let i;return e[8]!==o||e[9]!==r?(i=t.jsxs(t.Fragment,{children:[o,s,r]}),e[8]=o,e[9]=r,e[10]=i):i=e[10],i}export{B as UserMenuContent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{q as s,j as i}from"./app.js";import{c as l}from"./compiler-runtime-Cj7rbuyn.js";import{A as x}from"./app-layout-NY6MXzc5.js";import"./sidebar-DGp3i7GG.js";import"./index-DU8vYhyh.js";import"./button-BV-GbIpN.js";import"./utils-DjqsqOe8.js";import"./index-C0o7vG6r.js";import"./createLucideIcon-BFG25zNo.js";import"./index-BCpOvf4m.js";import"./index-Cq31rrfZ.js";import"./index-DN1K56yz.js";import"./index-CcxvoJO6.js";import"./index-lqMxC6QB.js";import"./tooltip-Du62rBCn.js";import"./index-DoVAC0HX.js";import"./app-shell-BjaxjNs9.js";import"./app-sidebar-CLu13Pcu.js";import"./nav-main-JVt9gzn8.js";import"./material-icon-BAd3Wrgn.js";import"./chevron-right-D5q8rF7h.js";import"./index-B__NksD2.js";import"./index-oMAR28Sy.js";import"./chevrons-up-down-kALltqHV.js";import"./app-sidebar-header-5IaQpngt.js";import"./breadcrumbs-CDxSbsTe.js";import"./nav-user-DgYX0wO7.js";import"./dropdown-menu-CeMIoM8d.js";import"./user-info-C_11jYGE.js";import"./user-menu-content-BNRzhEo_.js";import"./icon-CqJOMij7.js";import"./use-appearance-DeUiDZ72.js";const a=[];function J(){const t=l.c(8),r=s();let o;t[0]!==r.props.title?(o=r.props.title&&i.jsx("div",{className:"text-3xl mb-8",children:r.props.title}),t[0]=r.props.title,t[1]=o):o=t[1];let e;t[2]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx("div",{className:"text-3xl mb-8",children:"Adminizer"}),t[2]=e):e=t[2];let p;t[3]!==r.props.text?(p=r.props.text&&i.jsx("div",{dangerouslySetInnerHTML:{__html:r.props.text}}),t[3]=r.props.text,t[4]=p):p=t[4];let m;return t[5]!==o||t[6]!==p?(m=i.jsx(x,{breadcrumbs:a,children:i.jsxs("div",{className:"flex h-full flex-1 flex-col gap-4 rounded-xl p-4",children:[o,e,p]})}),t[5]=o,t[6]=p,t[7]=m):m=t[7],m}export{J as default};
|
package/controllers/add.js
CHANGED
|
@@ -14,14 +14,14 @@ export default async function add(req, res) {
|
|
|
14
14
|
return req.Inertia.redirect(`${req.adminizer.config.routePrefix}/${entity.uri}`);
|
|
15
15
|
}
|
|
16
16
|
if (req.adminizer.config.auth.enable) {
|
|
17
|
-
if (!req.
|
|
17
|
+
if (!req.user) {
|
|
18
18
|
return req.Inertia.redirect(`${req.adminizer.config.routePrefix}/model/userap/login`);
|
|
19
19
|
}
|
|
20
|
-
else if (!req.adminizer.accessRightsHelper.hasPermission(`create-${entity.name}-model`, req.
|
|
20
|
+
else if (!req.adminizer.accessRightsHelper.hasPermission(`create-${entity.name}-model`, req.user)) {
|
|
21
21
|
return res.sendStatus(403);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
let dataAccessor = new DataAccessor(req, entity, "add");
|
|
24
|
+
let dataAccessor = new DataAccessor(req.adminizer, req.user, entity, "add");
|
|
25
25
|
let fields = dataAccessor.getFieldsConfig();
|
|
26
26
|
// add deprecated 'records' to config
|
|
27
27
|
fields = await FieldsHelper.loadAssociations(req, fields, "add");
|
|
@@ -91,6 +91,9 @@ export default async function add(req, res) {
|
|
|
91
91
|
await saveRelationsMediaManager(fields, rawReqData, entity.model.identity, record.id);
|
|
92
92
|
Adminizer.log.debug(`A new record was created: `, record);
|
|
93
93
|
if (req.body.jsonPopupCatalog) {
|
|
94
|
+
dataAccessor = new DataAccessor(req.adminizer, req.user, entity, "edit");
|
|
95
|
+
record = await entity.model.findOne({ id: record.id }, dataAccessor);
|
|
96
|
+
// await new Promise(resolve => setTimeout(resolve, 2000));
|
|
94
97
|
return res.json({ record: record });
|
|
95
98
|
}
|
|
96
99
|
else {
|
|
@@ -104,16 +107,13 @@ export default async function add(req, res) {
|
|
|
104
107
|
data = reqData;
|
|
105
108
|
}
|
|
106
109
|
}
|
|
110
|
+
const props = inertiaAddHelper(req, entity, fields);
|
|
107
111
|
if (req.query?.without_layout) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
// data: data
|
|
112
|
-
// });
|
|
113
|
-
return null;
|
|
112
|
+
return res.json({
|
|
113
|
+
props: props
|
|
114
|
+
});
|
|
114
115
|
}
|
|
115
116
|
else {
|
|
116
|
-
const props = inertiaAddHelper(req, entity, fields);
|
|
117
117
|
return req.Inertia.render({
|
|
118
118
|
component: 'add',
|
|
119
119
|
props: props
|
package/controllers/addGroup.js
CHANGED
|
@@ -4,10 +4,10 @@ import { inertiaGroupHelper } from "../helpers/inertiaGroupHelper";
|
|
|
4
4
|
export default async function addGroup(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(`create-${entity.name}-model`, req.
|
|
10
|
+
else if (!req.adminizer.accessRightsHelper.hasPermission(`create-${entity.name}-model`, req.user)) {
|
|
11
11
|
return res.sendStatus(403);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
@@ -25,7 +25,6 @@ export default async function addGroup(req, res) {
|
|
|
25
25
|
groupedTokens[department] = req.adminizer.accessRightsHelper.getTokensByDepartment(department);
|
|
26
26
|
}
|
|
27
27
|
if (req.method.toUpperCase() === 'POST') {
|
|
28
|
-
// console.log(req.body);
|
|
29
28
|
let allTokens = req.adminizer.accessRightsHelper.getTokens();
|
|
30
29
|
let usersInThisGroup = [];
|
|
31
30
|
let tokensOfThisGroup = [];
|
|
@@ -60,7 +59,6 @@ export default async function addGroup(req, res) {
|
|
|
60
59
|
Adminizer.log.error(e);
|
|
61
60
|
req.session.messages.adminError.push(e.message || 'Something went wrong...');
|
|
62
61
|
}
|
|
63
|
-
// console.log(group)
|
|
64
62
|
}
|
|
65
63
|
const props = inertiaGroupHelper(entity, req, users, groupedTokens);
|
|
66
64
|
return req.Inertia.render({
|
package/controllers/addUser.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(`create-${entity.name}-model`, req.
|
|
11
|
+
else if (!req.adminizer.accessRightsHelper.hasPermission(`create-${entity.name}-model`, req.user)) {
|
|
12
12
|
return res.sendStatus(403);
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -22,7 +22,6 @@ export default async function (req, res) {
|
|
|
22
22
|
}
|
|
23
23
|
let user;
|
|
24
24
|
if (req.method.toUpperCase() === 'POST') {
|
|
25
|
-
// console.log(req.body);
|
|
26
25
|
let userGroups = [];
|
|
27
26
|
for (let key in req.body) {
|
|
28
27
|
if (key.startsWith("group-checkbox-") && req.body[key] === true) {
|
|
@@ -40,12 +39,12 @@ export default async function (req, res) {
|
|
|
40
39
|
locale = req.body.locale === 'default' ? req.adminizer.config.translation.defaultLocale : req.body.locale;
|
|
41
40
|
}
|
|
42
41
|
try {
|
|
43
|
-
let passwordHashed = generate(req.body.login + req.body.userPassword);
|
|
42
|
+
let passwordHashed = generate(req.body.login + req.body.userPassword + process.env.AP_PASSWORD_SALT);
|
|
44
43
|
let password = 'masked';
|
|
45
44
|
// TODO refactor CRUD functions for DataAccessor usage
|
|
46
45
|
user = await req.adminizer.modelHandler.model.get("UserAP")["_create"]({
|
|
47
46
|
login: req.body.login, fullName: req.body.fullName, email: req.body.email,
|
|
48
|
-
|
|
47
|
+
passwordHashed: passwordHashed, timezone: req.body.timezone, expires: req.body.date,
|
|
49
48
|
locale: locale, isAdministrator: isAdministrator, isConfirmed: isConfirmed, groups: userGroups
|
|
50
49
|
});
|
|
51
50
|
Adminizer.log.debug(`A new user was created: `, user);
|
|
@@ -56,7 +55,6 @@ export default async function (req, res) {
|
|
|
56
55
|
Adminizer.log.error(e);
|
|
57
56
|
req.session.messages.adminError.push(e.message || 'Something went wrong...');
|
|
58
57
|
}
|
|
59
|
-
// console.log(user)
|
|
60
58
|
}
|
|
61
59
|
const props = inertiaUserHelper(entity, req, groups);
|
|
62
60
|
return req.Inertia.render({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function catalogController(req: ReqType, res: ResType): Promise<void |
|
|
1
|
+
export declare function catalogController(req: ReqType, res: ResType): Promise<void | import("express").Response<any, Record<string, any>>>;
|
|
@@ -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,70 @@ 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
|
|
85
|
+
return res.json({ data: await frontendCatalog.handleAction(data.data.actionID, data.data.items, data.data.config, req) });
|
|
81
86
|
case 'getPopUpHTML':
|
|
82
|
-
|
|
87
|
+
// TODO: deprecated, passing react module instead html
|
|
88
|
+
return res.json({ data: await frontendCatalog.getPopUpHTML(data.actionId) });
|
|
83
89
|
case 'updateItem':
|
|
84
|
-
return res.json({ data: await
|
|
90
|
+
return res.json({ data: await frontendCatalog.updateItem(item, data.modelId, data.data, req) });
|
|
85
91
|
}
|
|
86
92
|
break;
|
|
87
93
|
case 'DELETE':
|
|
88
|
-
return res.json({ data: await
|
|
94
|
+
return res.json({ data: await frontendCatalog.deleteItem(data.data, req) });
|
|
89
95
|
}
|
|
90
96
|
}
|
|
91
97
|
}
|
|
@@ -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,54 @@ 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.item" | "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.item" | "navigation.group" | "navigation.link" | "model";
|
|
41
|
+
data: any;
|
|
41
42
|
}>;
|
|
42
|
-
getitemTypes():
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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[], config: any, req: ReqType): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* @deprecated reason: migration for intertia
|
|
58
|
+
* // TODO: need passing custom React module
|
|
59
|
+
*/
|
|
46
60
|
getPopUpHTML(actionId: string): Promise<string>;
|
|
47
61
|
getLink(actionId: string): Promise<string>;
|
|
48
62
|
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(
|
|
63
|
+
createItem(data: any, req: ReqType): Promise<any>;
|
|
64
|
+
getChilds(data: any, req: ReqType): Promise<NodeModel<Item>[]>;
|
|
65
|
+
search(s: string, req: ReqType): Promise<NodeModel<Item>[]>;
|
|
66
|
+
updateTree(data: RequestData, req: ReqType): Promise<any>;
|
|
67
|
+
updateItem(item: any, modelId: string, data: any, req: ReqType): Promise<any>;
|
|
68
|
+
deleteItem(item: Item, req: ReqType): Promise<{
|
|
55
69
|
ok: boolean;
|
|
56
70
|
}>;
|
|
57
71
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import { AbstractCatalog } from "../../lib/catalog/AbstractCatalog";
|
|
1
|
+
import { AbstractCatalog } from "../../lib/v4/catalog/AbstractCatalog";
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated Now is React
|
|
4
|
+
* // TODO: refactor for react name
|
|
5
|
+
*/
|
|
2
6
|
export class VueCatalog {
|
|
3
7
|
catalog;
|
|
4
8
|
constructor(_catalog) {
|
|
@@ -10,11 +14,11 @@ export class VueCatalog {
|
|
|
10
14
|
getItemType(type) {
|
|
11
15
|
return this.catalog.getItemType(type);
|
|
12
16
|
}
|
|
13
|
-
|
|
14
|
-
return this.catalog.
|
|
17
|
+
getAddTemplate(item, req) {
|
|
18
|
+
return this.catalog.getAddTemplate(item, req);
|
|
15
19
|
}
|
|
16
|
-
|
|
17
|
-
return this.catalog.
|
|
20
|
+
getEditTemplate(item, id, req, modelId) {
|
|
21
|
+
return this.catalog.getEditTemplate(item, id, req, modelId);
|
|
18
22
|
}
|
|
19
23
|
getitemTypes() {
|
|
20
24
|
return this.catalog.getitemTypes();
|
|
@@ -28,22 +32,26 @@ export class VueCatalog {
|
|
|
28
32
|
"Select Item type": "",
|
|
29
33
|
"Select Items": "",
|
|
30
34
|
"Save": "",
|
|
31
|
-
"No
|
|
35
|
+
"No": "",
|
|
32
36
|
"Are you sure?": "",
|
|
33
|
-
"Yes
|
|
34
|
-
"Select Ids": ""
|
|
37
|
+
"Yes": "",
|
|
38
|
+
"Select Ids": "",
|
|
39
|
+
"OR": "",
|
|
40
|
+
"Open in a new window": "",
|
|
41
|
+
"Clean": "",
|
|
35
42
|
};
|
|
36
43
|
obj[this.catalog.name] = "";
|
|
37
44
|
for (const actionHandler of this.catalog.actionHandlers) {
|
|
38
45
|
obj[actionHandler.name] = "";
|
|
39
46
|
}
|
|
40
47
|
let messages = obj;
|
|
41
|
-
req.i18n.setLocale(req.session.UserAP.locale);
|
|
42
48
|
let outMessages = {};
|
|
43
49
|
for (const mess of Object.keys(messages)) {
|
|
44
50
|
outMessages[mess] = req.i18n.__(mess);
|
|
45
51
|
}
|
|
46
|
-
return
|
|
52
|
+
return {
|
|
53
|
+
...outMessages,
|
|
54
|
+
};
|
|
47
55
|
}
|
|
48
56
|
async getActions(items, type) {
|
|
49
57
|
let arrItems = [];
|
|
@@ -57,13 +65,17 @@ export class VueCatalog {
|
|
|
57
65
|
return (await this.catalog.getActions(arrItems))?.filter(e => e.displayContext);
|
|
58
66
|
}
|
|
59
67
|
}
|
|
60
|
-
async handleAction(actionId, items, config) {
|
|
68
|
+
async handleAction(actionId, items, config, req) {
|
|
61
69
|
let arrItems = [];
|
|
62
70
|
for (const item of items) {
|
|
63
71
|
arrItems.push(await this.catalog.find(item.data));
|
|
64
72
|
}
|
|
65
|
-
return this.catalog.handleAction(actionId, arrItems, config);
|
|
73
|
+
return this.catalog.handleAction(actionId, arrItems, config, req);
|
|
66
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* @deprecated reason: migration for intertia
|
|
77
|
+
* // TODO: need passing custom React module
|
|
78
|
+
*/
|
|
67
79
|
async getPopUpHTML(actionId) {
|
|
68
80
|
return this.catalog.getPopUpHTML(actionId);
|
|
69
81
|
}
|
|
@@ -72,80 +84,68 @@ export class VueCatalog {
|
|
|
72
84
|
}
|
|
73
85
|
//Below are the methods that require action
|
|
74
86
|
async getCatalog() {
|
|
75
|
-
let rootItems = await this.catalog.getChilds(
|
|
87
|
+
let rootItems = await this.catalog.getChilds(0);
|
|
76
88
|
return VueCatalogUtils.arrayToNode(rootItems, this.catalog.getGroupType().type);
|
|
77
89
|
}
|
|
78
|
-
createItem(data) {
|
|
90
|
+
async createItem(data, req) {
|
|
79
91
|
//data = VueCatalogUtils.refinement(data);
|
|
80
92
|
if (this.catalog.slug !== "navigation") {
|
|
81
93
|
let item = data.record;
|
|
82
94
|
item.parenId = data.parenId;
|
|
83
|
-
return this.catalog.createItem(item);
|
|
95
|
+
return await this.catalog.createItem(item, req);
|
|
84
96
|
}
|
|
85
97
|
else {
|
|
86
|
-
return this.catalog.createItem(data);
|
|
98
|
+
return await this.catalog.createItem(data, req);
|
|
87
99
|
}
|
|
88
100
|
}
|
|
89
|
-
async getChilds(data) {
|
|
101
|
+
async getChilds(data, req) {
|
|
90
102
|
data = VueCatalogUtils.refinement(data);
|
|
91
|
-
return VueCatalogUtils.arrayToNode(await this.catalog.getChilds(data.id), this.catalog.getGroupType().type);
|
|
103
|
+
return VueCatalogUtils.arrayToNode(await this.catalog.getChilds(data.id, undefined, req), this.catalog.getGroupType().type);
|
|
92
104
|
}
|
|
93
105
|
// Moved into actions
|
|
94
106
|
// getCreatedItems(data: any) {
|
|
95
107
|
// data = VueCatalogUtils.refinement(data);
|
|
96
108
|
// return this.catalog.getChilds(data.id);
|
|
97
109
|
// }
|
|
98
|
-
async search(s) {
|
|
99
|
-
let searchResult = await this.catalog.search(s);
|
|
110
|
+
async search(s, req) {
|
|
111
|
+
let searchResult = await this.catalog.search(s, undefined, req);
|
|
112
|
+
// console.log(searchResult)
|
|
113
|
+
// return ''
|
|
100
114
|
let itemsTree = AbstractCatalog.buildTree(searchResult);
|
|
101
115
|
return VueCatalogUtils.treeToNode(itemsTree, this.catalog.getGroupType().type);
|
|
102
116
|
}
|
|
103
|
-
async updateTree(data) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
reqNodes = [data.reqNode];
|
|
107
|
-
}
|
|
117
|
+
async updateTree(data, req) {
|
|
118
|
+
// console.dir(data, {depth: null})
|
|
119
|
+
// return
|
|
108
120
|
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
121
|
// Update all items into parent (for two reason: update parent, updare sorting order)
|
|
124
122
|
let sortCount = 0;
|
|
125
123
|
for (const childNode of reqParent.children) {
|
|
126
124
|
childNode.data.sortOrder = sortCount;
|
|
127
125
|
childNode.data.parentId = reqParent.data.id;
|
|
128
|
-
await this.catalog.updateItem(childNode.data.id, childNode.data.type, childNode.data);
|
|
126
|
+
await this.catalog.updateItem(childNode.data.id, childNode.data.type, childNode.data, req);
|
|
129
127
|
sortCount++;
|
|
130
128
|
}
|
|
131
129
|
return Promise.resolve('ok');
|
|
132
130
|
}
|
|
133
|
-
async updateItem(item, modelId, data) {
|
|
131
|
+
async updateItem(item, modelId, data, req) {
|
|
134
132
|
//data = VueCatalogUtils.refinement(data);
|
|
135
133
|
if (this.catalog.slug !== "navigation") {
|
|
136
|
-
return await this.catalog.updateModelItems(data.modelId, data.type, data.record);
|
|
134
|
+
return await this.catalog.updateModelItems(data.modelId, data.type, data.record, req);
|
|
137
135
|
}
|
|
138
136
|
else {
|
|
139
|
-
return await this.catalog.updateModelItems(modelId, item.type, data);
|
|
137
|
+
return await this.catalog.updateModelItems(modelId, item.type, data, req);
|
|
140
138
|
}
|
|
141
139
|
}
|
|
142
|
-
async deleteItem(
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
this.
|
|
140
|
+
async deleteItem(item, req) {
|
|
141
|
+
// Получаем всех непосредственных потомков текущего элемента
|
|
142
|
+
const children = await this.catalog.getChilds(item.id, undefined, req);
|
|
143
|
+
// Рекурсивно удаляем всех потомков
|
|
144
|
+
for (const child of children) {
|
|
145
|
+
await this.deleteItem(child, req);
|
|
148
146
|
}
|
|
147
|
+
// После удаления всех потомков удаляем сам элемент
|
|
148
|
+
await this.catalog.deleteItem(item.type, item.id, req);
|
|
149
149
|
return { ok: true };
|
|
150
150
|
}
|
|
151
151
|
}
|
|
@@ -162,16 +162,16 @@ export class VueCatalogUtils {
|
|
|
162
162
|
static toNode(data, groupTypeName) {
|
|
163
163
|
return {
|
|
164
164
|
data: data,
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
165
|
+
droppable: data.type === groupTypeName,
|
|
166
|
+
id: data.id,
|
|
167
|
+
text: data.name,
|
|
168
|
+
parent: data.parentId,
|
|
169
169
|
};
|
|
170
170
|
}
|
|
171
171
|
static expandTo(vueCatalogData, theseItemIdsNeedToBeOpened) {
|
|
172
172
|
function expand(node) {
|
|
173
173
|
if (theseItemIdsNeedToBeOpened.includes(node.data.id)) {
|
|
174
|
-
node.isExpanded = true;
|
|
174
|
+
// node.isExpanded = true;
|
|
175
175
|
}
|
|
176
176
|
if (node.children) {
|
|
177
177
|
for (const child of node.children) {
|
|
@@ -192,7 +192,7 @@ export class VueCatalogUtils {
|
|
|
192
192
|
// Sort the children before building their nodes
|
|
193
193
|
item.childs.sort((a, b) => (a.sortOrder || 0) - (b.sortOrder || 0));
|
|
194
194
|
node.children = buildNodes(item.childs);
|
|
195
|
-
node.isExpanded = !node.
|
|
195
|
+
// node.isExpanded = !node.droppable;
|
|
196
196
|
}
|
|
197
197
|
return node;
|
|
198
198
|
});
|
|
@@ -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
|
;
|