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.
Files changed (292) hide show
  1. package/Readme.md +46 -0
  2. package/assets/{VanillaJSONEditor-FUe77pIA.js → VanillaJSONEditor-DfRefswH.js} +104 -104
  3. package/assets/add-CJ1-zeA1.js +1 -0
  4. package/assets/add-form-CbNl0wdS.js +1 -0
  5. package/assets/add-group-form-Bt_Dx9wm.js +1 -0
  6. package/assets/add-group-pIFJV5qL.js +1 -0
  7. package/assets/add-user-D2US8hL_.js +1 -0
  8. package/assets/add-user-form-Bt8Jy6S2.js +1 -0
  9. package/assets/{app-DMmad2-f.css → app-B6cCPfWk.css} +1 -1
  10. package/assets/app-layout-B86jl9bH.js +1 -0
  11. package/assets/app-shell-CiGyzQ0C.js +1 -0
  12. package/assets/app-sidebar-Bz-SRwBg.js +1 -0
  13. package/assets/app-sidebar-header-7CNCx7Rs.js +11 -0
  14. package/assets/app.js +45 -37
  15. package/assets/breadcrumbs-_jhtTcOi.js +1 -0
  16. package/assets/catalog-CON6moaA.js +16 -0
  17. package/assets/catalog-Cc6Mk9sX.css +1 -0
  18. package/assets/checkbox-CQdZw5mb.js +1 -0
  19. package/assets/dashboard-BOltB2Hq.css +1 -0
  20. package/assets/dashboard-es9ZT8qk.js +3 -0
  21. package/assets/{date-picker-B__dVVqj.js → date-picker-Dz-d-YWX.js} +2 -2
  22. package/assets/debounce-qdyXyOeG.js +1 -0
  23. package/assets/del-modal-D0mrZvki.js +11 -0
  24. package/assets/dialog-stack-BiMbfm58.js +1 -0
  25. package/assets/dropdown-menu-BSBcRiXx.js +1 -0
  26. package/assets/{field-renderer-CapylJU9.js → field-renderer-B6hFAeiU.js} +3 -3
  27. package/assets/form-Buslty7y.js +1 -0
  28. package/assets/form-aqiRmPix.js +1 -0
  29. package/assets/{geo-json-CwteYDGB.js → geo-json-BKmYmu3d.js} +2 -2
  30. package/assets/{handsontable-BCnjOpBr.js → handsontable-B8xVeMAQ.js} +5 -5
  31. package/assets/home-Dr72Jk-w.js +2 -0
  32. package/assets/icon-B-a7xg54.js +1 -0
  33. package/assets/index-B68_akQe.js +1 -0
  34. package/assets/index-B7-xTDyy.js +1 -0
  35. package/assets/index-BJFFlCSo.js +1 -0
  36. package/assets/{index-DTRTjOmh.js → index-BOuMo_nl.js} +3 -3
  37. package/assets/index-BzOcGsBq.js +1 -0
  38. package/assets/index-CFbQ2Rv0.js +1 -0
  39. package/assets/{index-D5ir9iUV.js → index-Cq31rrfZ.js} +1 -1
  40. package/assets/{index-BcE9FUM6.js → index-D5UDXTFs.js} +1 -1
  41. package/assets/index-oxIQWAdI.js +41 -0
  42. package/assets/init-user-5H689LP0.js +1 -0
  43. package/assets/input-CSJjrf2i.js +1 -0
  44. package/assets/input-error-CK92Shhm.js +1 -0
  45. package/assets/label-Muj0-Efy.js +1 -0
  46. package/assets/list-Cvh7zbyG.js +1 -0
  47. package/assets/list-table-Bs_vbQiV.js +52 -0
  48. package/assets/login-DliJrjMQ.js +6 -0
  49. package/assets/manifest.json +589 -666
  50. package/assets/material-icon-BRS58Qpk.js +1 -0
  51. package/assets/module-CjG21VCT.js +1 -0
  52. package/assets/{monaco-editor-DqAqwxw4.js → monaco-editor-9fDiyfuW.js} +2 -2
  53. package/assets/{multi-select-oabtVhUP.js → multi-select-CMQIJ0JT.js} +2 -2
  54. package/assets/nav-footer-IGMn9NiE.js +1 -0
  55. package/assets/nav-main-DBE4rMiZ.js +1 -0
  56. package/assets/nav-user-CjyLRyq-.js +1 -0
  57. package/assets/pagination-render-DUAq2klc.js +1 -0
  58. package/assets/popover-C_cww-4_.js +1 -0
  59. package/assets/register-UzQn3J0g.js +1 -0
  60. package/assets/{select-D1N8zRPY.js → select-DzBno-dc.js} +2 -2
  61. package/assets/{sidebar-4D-sX2l4.js → sidebar-Dc4iqfu-.js} +2 -2
  62. package/assets/skeleton-Dkmj2o2Z.js +1 -0
  63. package/assets/sonner-De1t71Gj.js +1 -0
  64. package/assets/{toast-editor-FbrFd1ft.js → toast-editor-1Pul3oMs.js} +2 -2
  65. package/assets/tooltip-CwPrC-HD.js +1 -0
  66. package/assets/use-appearance-J8J2w43p.js +1 -0
  67. package/assets/use-window-size-DLSEoR6e.js +1 -0
  68. package/assets/{user-info-DBYoAJYJ.js → user-info-8RyDk7qh.js} +2 -2
  69. package/assets/user-menu-content-CpxTLH56.js +6 -0
  70. package/assets/welcome-BYKI6yO-.js +1 -0
  71. package/controllers/add.js +10 -10
  72. package/controllers/addGroup.js +2 -4
  73. package/controllers/addUser.js +4 -6
  74. package/controllers/catalog/Catalog.d.ts +1 -1
  75. package/controllers/catalog/Catalog.js +42 -37
  76. package/controllers/catalog/FrontentCatalogAdapter.d.ts +36 -26
  77. package/controllers/catalog/FrontentCatalogAdapter.js +71 -73
  78. package/controllers/ckeditorUpload.js +2 -3
  79. package/controllers/dashboard.js +16 -2
  80. package/controllers/edit.js +10 -14
  81. package/controllers/editGroup.js +2 -4
  82. package/controllers/editUser.js +3 -5
  83. package/controllers/form.js +2 -3
  84. package/controllers/getAllWidgets.js +3 -3
  85. package/controllers/initUser.js +1 -2
  86. package/controllers/list.js +6 -6
  87. package/controllers/login.js +43 -18
  88. package/controllers/media-manager/mediaManagerAdapter.js +1 -2
  89. package/controllers/media-manager/mediaManagerApi.js +2 -2
  90. package/controllers/navigation/edit.js +2 -2
  91. package/controllers/register.js +1 -4
  92. package/controllers/remove.js +3 -3
  93. package/controllers/timezones.js +1 -1
  94. package/controllers/view.js +3 -3
  95. package/controllers/welcome.js +1 -1
  96. package/controllers/widgets/Action.js +2 -2
  97. package/controllers/widgets/Custom.js +2 -2
  98. package/controllers/widgets/Info.js +2 -2
  99. package/controllers/widgets/switch.js +2 -2
  100. package/controllers/widgetsDB.js +5 -5
  101. package/helpers/JsUtils.d.ts +1 -0
  102. package/helpers/JsUtils.js +3 -0
  103. package/helpers/accessRightsHelper.d.ts +6 -2
  104. package/helpers/accessRightsHelper.js +28 -5
  105. package/helpers/configHelper.js +2 -1
  106. package/helpers/controllerHelper.js +39 -18
  107. package/helpers/fieldsHelper.d.ts +4 -3
  108. package/helpers/fieldsHelper.js +5 -1
  109. package/helpers/inertiaActionsHelper.js +1 -1
  110. package/helpers/inertiaAddHelper.d.ts +3 -4
  111. package/helpers/inertiaAddHelper.js +27 -7
  112. package/helpers/inertiaFromHelper.js +2 -0
  113. package/helpers/inertiaGroupHelper.d.ts +4 -2
  114. package/helpers/inertiaGroupHelper.js +1 -1
  115. package/helpers/inertiaListHelper.js +5 -5
  116. package/helpers/inertiaMenuHelper.d.ts +1 -1
  117. package/helpers/inertiaMenuHelper.js +2 -2
  118. package/helpers/inertiaUserHelper.d.ts +7 -1
  119. package/helpers/inertiaUserHelper.js +5 -1
  120. package/helpers/menuHelper.d.ts +8 -3
  121. package/helpers/menuHelper.js +26 -17
  122. package/index.d.ts +6 -3
  123. package/index.js +9 -3
  124. package/interfaces/adminpanelConfig.d.ts +41 -32
  125. package/interfaces/global.d.ts +10 -28
  126. package/interfaces/types.d.ts +1 -1
  127. package/lib/Adminizer.d.ts +11 -3
  128. package/lib/Adminizer.js +49 -17
  129. package/lib/media-manager/AbstractMediaManager.d.ts +2 -2
  130. package/lib/media-manager/AbstractMediaManager.js +1 -1
  131. package/lib/media-manager/Items.js +0 -3
  132. package/lib/requestProcessor.js +10 -3
  133. package/lib/v4/DataAccessor.d.ts +5 -2
  134. package/lib/v4/DataAccessor.js +44 -19
  135. package/lib/v4/I18n.js +2 -0
  136. package/lib/v4/POWCaptcha.js +0 -1
  137. package/lib/v4/PolicyManager.js +0 -1
  138. package/lib/{catalog → v4/catalog}/AbstractCatalog.d.ts +89 -60
  139. package/lib/{catalog → v4/catalog}/AbstractCatalog.js +59 -55
  140. package/lib/v4/catalog/Navigation.d.ts +43 -0
  141. package/lib/v4/catalog/Navigation.js +457 -0
  142. package/lib/{controls → v4/controls}/AbstractControls.d.ts +1 -1
  143. package/lib/{controls → v4/controls}/codeEditor/MonacoEditor.d.ts +1 -1
  144. package/lib/{controls → v4/controls}/geojsoneditor/GeoEditor.d.ts +1 -1
  145. package/lib/{controls → v4/controls}/jsoneditor/JsonEditor.d.ts +1 -1
  146. package/lib/{controls → v4/controls}/markdown/ToastUiEditor.d.ts +1 -1
  147. package/lib/{controls → v4/controls}/table/Handsontable.d.ts +1 -1
  148. package/lib/{controls → v4/controls}/wysiwyg/CKeditor.d.ts +1 -1
  149. package/lib/{datatable → v4/datatable}/NodeTable.d.ts +3 -3
  150. package/lib/{datatable → v4/datatable}/NodeTable.js +8 -8
  151. package/lib/v4/helper/jwt.d.ts +10 -0
  152. package/lib/v4/helper/jwt.js +18 -0
  153. package/lib/{inertia → v4/inertia}/inertiaAdapter.js +0 -1
  154. package/lib/v4/model/AbstractModel.d.ts +5 -1
  155. package/lib/v4/model/AbstractModel.js +2 -3
  156. package/lib/v4/model/ModelHandler.js +1 -4
  157. package/lib/v4/model/adapter/sequelize.d.ts +11 -2
  158. package/lib/v4/model/adapter/sequelize.js +451 -118
  159. package/lib/v4/model/adapter/waterline.js +5 -3
  160. package/lib/{widgets → v4/widgets}/abstractAction.d.ts +1 -1
  161. package/lib/v4/widgets/abstractCustom.d.ts +28 -0
  162. package/lib/v4/widgets/abstractCustom.js +9 -0
  163. package/lib/{widgets → v4/widgets}/abstractInfo.d.ts +1 -1
  164. package/lib/{widgets → v4/widgets}/abstractInfo.js +1 -1
  165. package/lib/{widgets → v4/widgets}/abstractLink.d.ts +2 -1
  166. package/lib/{widgets → v4/widgets}/abstractSwitch.d.ts +1 -1
  167. package/lib/{widgets → v4/widgets}/abstractWidgetBase.d.ts +2 -2
  168. package/lib/{widgets → v4/widgets}/widgetHandler.d.ts +29 -5
  169. package/lib/{widgets → v4/widgets}/widgetHandler.js +25 -25
  170. package/models/GroupAP.d.ts +8 -0
  171. package/models/NavigationAP.d.ts +7 -3
  172. package/models/NavigationAP.js +5 -6
  173. package/models/UserAP.d.ts +24 -2
  174. package/models/UserAP.js +2 -2
  175. package/package.json +29 -11
  176. package/policies/checkAuth.js +4 -3
  177. package/policies/setLocale.js +2 -2
  178. package/system/Router.js +14 -17
  179. package/system/bindAccessRights.js +0 -4
  180. package/system/bindAuthorization.js +4 -5
  181. package/system/bindControls.js +6 -6
  182. package/system/bindDev.js +1 -0
  183. package/system/bindInertia.js +17 -12
  184. package/system/bindMediaManager.js +0 -1
  185. package/system/bindModels.js +9 -6
  186. package/system/bindNavigation.d.ts +2 -0
  187. package/system/bindNavigation.js +42 -42
  188. package/system/bindReqFunctions.js +15 -0
  189. package/system/defaults.js +13 -6
  190. package/translations/ar.json +70 -1
  191. package/translations/cn.json +70 -1
  192. package/translations/de.json +71 -3
  193. package/translations/en.json +70 -102
  194. package/translations/es.json +70 -1
  195. package/translations/fr.json +70 -1
  196. package/translations/hi.json +70 -1
  197. package/translations/jp.json +70 -1
  198. package/translations/ko.json +70 -1
  199. package/translations/pt.json +70 -1
  200. package/translations/ru.json +71 -94
  201. package/translations/ua.json +70 -1
  202. package/translations/uz.json +72 -0
  203. package/translations/vi.json +70 -1
  204. package/assets/add-ZITr43GJ.js +0 -1
  205. package/assets/add-form-CYOfr0Ef.js +0 -1
  206. package/assets/add-group-B332wN8K.js +0 -1
  207. package/assets/add-group-form-dzadPSfL.js +0 -1
  208. package/assets/add-user-TC-mYdsB.js +0 -1
  209. package/assets/add-user-form-y2f_1_lM.js +0 -1
  210. package/assets/app-layout-D1m9Kvxq.js +0 -1
  211. package/assets/app-shell-BWMRMkHM.js +0 -1
  212. package/assets/app-sidebar-BCtaEFGb.js +0 -1
  213. package/assets/app-sidebar-header-DLAFi13E.js +0 -11
  214. package/assets/breadcrumbs-CQNon4Vl.js +0 -1
  215. package/assets/button-CQ9t1kLz.js +0 -1
  216. package/assets/checkbox-W0nGAXIj.js +0 -1
  217. package/assets/compiler-runtime-tM4jBQ-T.js +0 -9
  218. package/assets/dashboard-BR602KhL.js +0 -1
  219. package/assets/dropdown-menu-SEBnEIiL.js +0 -1
  220. package/assets/form-DOUNk3o2.js +0 -1
  221. package/assets/form-lOKv4Qbw.js +0 -1
  222. package/assets/home-Ch6QfTIt.js +0 -2
  223. package/assets/icon-Bz9BMaD0.js +0 -1
  224. package/assets/index-BC0yfOHo.js +0 -1
  225. package/assets/index-BbXEMx9n.js +0 -1
  226. package/assets/index-C0SL3SHw.js +0 -41
  227. package/assets/index-Cdb9ACvz.js +0 -1
  228. package/assets/index-DEk3sC8d.js +0 -1
  229. package/assets/index-DrWfGwtf.js +0 -1
  230. package/assets/index-K81GbF6O.js +0 -1
  231. package/assets/init-user-D9mW-g14.js +0 -1
  232. package/assets/input-DF7Ue23C.js +0 -1
  233. package/assets/input-error-BBygona6.js +0 -1
  234. package/assets/label-Z506NKsW.js +0 -1
  235. package/assets/list-Qyd7ecQH.js +0 -1
  236. package/assets/list-table-DB1sEQLF.js +0 -62
  237. package/assets/login-DrGaTWhY.js +0 -6
  238. package/assets/material-icon-CItZiB53.js +0 -1
  239. package/assets/module-DBaykv8l.js +0 -1
  240. package/assets/nav-footer-CM-yHiRs.js +0 -1
  241. package/assets/nav-main-Q3xofGRT.js +0 -1
  242. package/assets/nav-user-Ds8i0Pa2.js +0 -1
  243. package/assets/pagination-render-B57pOpFy.js +0 -1
  244. package/assets/popover-I249Gg2O.js +0 -1
  245. package/assets/register-C9FQIDtS.js +0 -1
  246. package/assets/sonner-Dzckw3U3.js +0 -1
  247. package/assets/tooltip-D2ehgLlB.js +0 -1
  248. package/assets/use-appearance-Co6mO0dV.js +0 -1
  249. package/assets/use-window-size-B8l6Bpkf.js +0 -1
  250. package/assets/user-menu-content-qkvdkUVd.js +0 -6
  251. package/assets/utils-DjqsqOe8.js +0 -1
  252. package/assets/welcome-D2adQ8EU.js +0 -1
  253. package/controllers/processInstallFinalize.d.ts +0 -1
  254. package/controllers/processInstallFinalize.js +0 -16
  255. package/controllers/processInstallStep.d.ts +0 -1
  256. package/controllers/processInstallStep.js +0 -132
  257. package/lib/catalog/Navigation.d.ts +0 -0
  258. package/lib/catalog/Navigation.js +0 -532
  259. package/lib/installStepper/InstallStepAbstract.d.ts +0 -52
  260. package/lib/installStepper/InstallStepAbstract.js +0 -69
  261. package/lib/installStepper/finalizeStep.d.ts +0 -21
  262. package/lib/installStepper/finalizeStep.js +0 -48
  263. package/lib/installStepper/installStepper.d.ts +0 -40
  264. package/lib/installStepper/installStepper.js +0 -195
  265. package/lib/widgets/abstractCustom.d.ts +0 -13
  266. package/lib/widgets/abstractCustom.js +0 -3
  267. package/models/MediaManagerAP.d.ts +0 -46
  268. package/models/MediaManagerAP.js +0 -45
  269. package/models/MediaManagerAssociationsAP.d.ts +0 -28
  270. package/models/MediaManagerAssociationsAP.js +0 -27
  271. package/models/MediaManagerMetaAP.d.ts +0 -22
  272. package/models/MediaManagerMetaAP.js +0 -21
  273. package/system/bindInstallStepper.d.ts +0 -2
  274. package/system/bindInstallStepper.js +0 -23
  275. /package/lib/{catalog → v4/catalog}/CatalogHandler.d.ts +0 -0
  276. /package/lib/{catalog → v4/catalog}/CatalogHandler.js +0 -0
  277. /package/lib/{controls → v4/controls}/AbstractControls.js +0 -0
  278. /package/lib/{controls → v4/controls}/ControlsHandler.d.ts +0 -0
  279. /package/lib/{controls → v4/controls}/ControlsHandler.js +0 -0
  280. /package/lib/{controls → v4/controls}/codeEditor/MonacoEditor.js +0 -0
  281. /package/lib/{controls → v4/controls}/geojsoneditor/GeoEditor.js +0 -0
  282. /package/lib/{controls → v4/controls}/jsoneditor/JsonEditor.js +0 -0
  283. /package/lib/{controls → v4/controls}/markdown/ToastUiEditor.js +0 -0
  284. /package/lib/{controls → v4/controls}/table/Handsontable.js +0 -0
  285. /package/lib/{controls → v4/controls}/wysiwyg/CKeditor.js +0 -0
  286. /package/lib/{inertia → v4/inertia}/flash.d.ts +0 -0
  287. /package/lib/{inertia → v4/inertia}/flash.js +0 -0
  288. /package/lib/{inertia → v4/inertia}/inertiaAdapter.d.ts +0 -0
  289. /package/lib/{widgets → v4/widgets}/abstractAction.js +0 -0
  290. /package/lib/{widgets → v4/widgets}/abstractLink.js +0 -0
  291. /package/lib/{widgets → v4/widgets}/abstractSwitch.js +0 -0
  292. /package/lib/{widgets → v4/widgets}/abstractWidgetBase.js +0 -0
@@ -1,5 +1,6 @@
1
1
  import { DataAccessor } from "../lib/v4/DataAccessor";
2
2
  import { Adminizer } from "../lib/Adminizer";
3
+ import { isObject } from "./JsUtils";
3
4
  export class FieldsHelper {
4
5
  /**
5
6
  * Load list of records for all associations into `fields`
@@ -20,6 +21,9 @@ export class FieldsHelper {
20
21
  */
21
22
  let loadAssoc = async function (key, action) {
22
23
  let fieldConfigConfig = fields[key].config;
24
+ if (!isObject(fieldConfigConfig)) {
25
+ throw 'type error: fieldConfigConfig should be normalized';
26
+ }
23
27
  if (fieldConfigConfig.type !== 'association' && fieldConfigConfig.type !== 'association-many') {
24
28
  return;
25
29
  }
@@ -42,7 +46,7 @@ export class FieldsHelper {
42
46
  name: modelName, config: req.adminizer.config.models[modelName],
43
47
  model: Model, uri: `${req.adminizer.config.routePrefix}/model/${modelName}`, type: "model"
44
48
  };
45
- let dataAccessor = new DataAccessor(req, entity, action);
49
+ let dataAccessor = new DataAccessor(req.adminizer, req.user, entity, "view");
46
50
  list = await Model.find({}, dataAccessor);
47
51
  }
48
52
  catch (e) {
@@ -4,7 +4,7 @@ export default function inertiaActionsHelper(actionType, entity, req) {
4
4
  const actions = req.adminizer.menuHelper.getGlobalActions(entity.config, actionType);
5
5
  if (actions && actions.length > 0) {
6
6
  actions.forEach(function (action) {
7
- if (req.adminizer.accessRightsHelper.hasPermission(action.accessRightsToken, req.session.UserAP)) {
7
+ if (req.adminizer.accessRightsHelper.hasPermission(action.accessRightsToken, req.user)) {
8
8
  resActions.push({
9
9
  link: action.link,
10
10
  id: action.id,
@@ -1,8 +1,7 @@
1
1
  import { Entity, PropsField } from "../interfaces/types";
2
2
  import { Actions } from "./inertiaActionsHelper";
3
- import { Fields } from "./fieldsHelper";
4
- import { BaseFieldConfig } from "../interfaces/adminpanelConfig";
5
- import { AbstractControls, ControlType } from "../lib/controls/AbstractControls";
3
+ import { Fields, Field } from "./fieldsHelper";
4
+ import { AbstractControls, ControlType } from "../lib/v4/controls/AbstractControls";
6
5
  export type PropsFieldType = 'text' | 'number' | 'range' | 'week' | 'month' | 'email' | 'color' | 'time' | 'date' | 'datetime-local' | 'password' | 'select' | 'select-many' | 'association-many' | 'association' | 'textarea' | 'checkbox' | ControlType;
7
6
  interface FieldProps extends Record<string | number | symbol, unknown> {
8
7
  edit: boolean;
@@ -21,7 +20,7 @@ interface FieldProps extends Record<string | number | symbol, unknown> {
21
20
  postLink: string;
22
21
  }
23
22
  export default function inertiaAddHelper(req: ReqType, entity: Entity, fields: Fields, record?: Record<string, string | boolean | number | string[]>, view?: boolean): FieldProps;
24
- export declare function getControlsOptions(fieldConfig: BaseFieldConfig, req: ReqType, type: ControlType, defaultControlName: string): {
23
+ export declare function getControlsOptions(fieldConfig: Field["config"], req: ReqType, type: ControlType, defaultControlName: string): {
25
24
  name: string;
26
25
  config: {
27
26
  el?: HTMLElement;
@@ -1,5 +1,6 @@
1
1
  import inertiaActionsHelper from "./inertiaActionsHelper";
2
2
  import chalk from "chalk";
3
+ import { isObject } from "./JsUtils";
3
4
  export default function inertiaAddHelper(req, entity, fields, record, view = false) {
4
5
  const actionType = 'add';
5
6
  let props = {
@@ -25,6 +26,10 @@ export default function inertiaAddHelper(req, entity, fields, record, view = fal
25
26
  continue;
26
27
  let field = fields[key];
27
28
  let fieldConfig = field.config;
29
+ if (!isObject(fieldConfig))
30
+ throw `Type error: fieldConfig is object`;
31
+ if (!!fieldConfig.visible === false)
32
+ continue;
28
33
  const type = (fieldConfig.type || fieldConfig.type).toLowerCase();
29
34
  //@ts-ignore TODO: fix model validations
30
35
  const isIn = typeof fieldConfig.isIn === 'object' ? fieldConfig.isIn : (field.model && typeof { ...field.model.validations }.isIn === 'object' ? { ...field.model.validations }.isIn : []);
@@ -113,6 +118,8 @@ export default function inertiaAddHelper(req, entity, fields, record, view = fal
113
118
  return props;
114
119
  }
115
120
  export function getControlsOptions(fieldConfig, req, type, defaultControlName) {
121
+ if (!isObject(fieldConfig))
122
+ throw `Type error: fieldConfig is object`;
116
123
  const fieldOptions = fieldConfig?.options;
117
124
  let control = getControl(req, type, fieldOptions?.name, defaultControlName);
118
125
  let editorName = control.getName();
@@ -190,6 +197,8 @@ function setAssociationValues(field, value) {
190
197
  let options = [];
191
198
  let initValue = [];
192
199
  const config = field.config;
200
+ if (!isObject(config))
201
+ throw `Type error: config is object`;
193
202
  const isOptionSelected = (option, value) => {
194
203
  if (Array.isArray(value)) {
195
204
  return value.includes(option);
@@ -198,8 +207,8 @@ function setAssociationValues(field, value) {
198
207
  return (option == value);
199
208
  }
200
209
  };
201
- const getAssociationValue = (value, config) => {
202
- const displayField = config.displayField || 'id';
210
+ const getAssociationValue = (value, field) => {
211
+ const displayField = field.modelConfig?.titleField || 'id';
203
212
  if (value === null)
204
213
  return [];
205
214
  if (Array.isArray(value)) {
@@ -212,13 +221,24 @@ function setAssociationValues(field, value) {
212
221
  return String(value);
213
222
  };
214
223
  for (let opt of config.records) {
224
+ const optAny = opt;
225
+ const displayField = typeof field.modelConfig.titleField !== 'undefined'
226
+ ? field.modelConfig.titleField
227
+ : typeof optAny.title !== 'undefined'
228
+ ? 'title'
229
+ : typeof optAny.name !== 'undefined'
230
+ ? 'name'
231
+ : config.identifierField;
232
+ const label = typeof config.displayModifier === 'function'
233
+ ? config.displayModifier(opt)
234
+ : optAny[displayField];
215
235
  options.push({
216
- label: config.displayModifier && typeof config.displayModifier === 'function'
217
- ? config.displayModifier(opt)
218
- : (config.displayField ? opt[config.displayField] : opt[config.identifierField]),
219
- value: opt[config.identifierField],
236
+ label,
237
+ value: optAny[config.identifierField],
220
238
  });
221
- if (isOptionSelected(opt[config.identifierField], getAssociationValue(value, config))) {
239
+ if (!isObject(config))
240
+ throw `Type error: config is object`;
241
+ if (config.identifierField && isOptionSelected(opt[config.identifierField], getAssociationValue(value, field))) {
222
242
  initValue.push(opt[config.identifierField]);
223
243
  }
224
244
  }
@@ -9,6 +9,8 @@ export default function inertiaFormHelper(req, postLink, formData) {
9
9
  };
10
10
  for (const key of Object.keys(formData)) {
11
11
  let field = formData[key];
12
+ if (!!field.visible === false)
13
+ continue;
12
14
  const type = (field.type || field.type).toLowerCase();
13
15
  const isIn = field.isIn ?? [];
14
16
  let label = field.title ?? '';
@@ -1,3 +1,5 @@
1
+ import { GroupAP } from "models/GroupAP";
2
+ import { UserAP } from "models/UserAP";
1
3
  import { AccessRightsToken, Entity, PropsField } from "../interfaces/types";
2
4
  interface groupedTokens {
3
5
  header: string;
@@ -20,7 +22,7 @@ interface listProps extends Record<string | number | symbol, unknown> {
20
22
  users: PropsField[];
21
23
  groupedTokens: groupedTokens[];
22
24
  }
23
- export declare function inertiaGroupHelper(entity: Entity, req: ReqType, users: ModelsAP["UserAP"][], groupedTokens: {
25
+ export declare function inertiaGroupHelper(entity: Entity, req: ReqType, users: UserAP[], groupedTokens: {
24
26
  [key: string]: AccessRightsToken[];
25
- }, group?: ModelsAP["GroupAP"], view?: boolean): listProps;
27
+ }, group?: GroupAP, view?: boolean): listProps;
26
28
  export {};
@@ -55,7 +55,7 @@ export function inertiaGroupHelper(entity, req, users, groupedTokens, group, vie
55
55
  label: token.name,
56
56
  tooltip: token.description,
57
57
  name: `token-checkbox-${token.id}`,
58
- value: group ? (group.tokens && group.tokens.includes(token.id)) : false,
58
+ value: group ? (group.tokens && group.tokens?.includes(token.id)) : false,
59
59
  type: 'checkbox'
60
60
  });
61
61
  }
@@ -24,22 +24,22 @@ export function inertiaListHelper(entity, req, fields) {
24
24
  searchBtn: req.i18n.__('Search'),
25
25
  resetBtn: req.i18n.__('Reset'),
26
26
  };
27
- if (entity.config.add && req.adminizer.accessRightsHelper.hasPermission(`create-${entity.name}-model`, req.session.UserAP)) {
27
+ if (entity.config.add && req.adminizer.accessRightsHelper.hasPermission(`create-${entity.name}-model`, req.user)) {
28
28
  props.crudActions.createTitle = req.i18n.__('create');
29
29
  }
30
- if (req.adminizer.accessRightsHelper.hasPermission(`update-${entity.name}-model`, req.session.UserAP)) {
30
+ if (req.adminizer.accessRightsHelper.hasPermission(`update-${entity.name}-model`, req.user)) {
31
31
  props.crudActions.editTitle = req.i18n.__('Edit');
32
32
  }
33
- if (req.adminizer.accessRightsHelper.hasPermission(`read-${entity.name}-model`, req.session.UserAP)) {
33
+ if (req.adminizer.accessRightsHelper.hasPermission(`read-${entity.name}-model`, req.user)) {
34
34
  props.crudActions.viewsTitle = req.i18n.__('View');
35
35
  }
36
- if (req.adminizer.accessRightsHelper.hasPermission(`delete-${entity.name}-model`, req.session.UserAP)) {
36
+ if (req.adminizer.accessRightsHelper.hasPermission(`delete-${entity.name}-model`, req.user)) {
37
37
  props.crudActions.deleteTitle = req.i18n.__('Delete');
38
38
  }
39
39
  props.actions = inertiaActionsHelper(actionType, entity, req);
40
40
  if (req.adminizer.menuHelper.hasInlineActions(entity.config, 'list')) {
41
41
  for (const inlineAction of req.adminizer.menuHelper.getInlineActions(entity.config, 'list')) {
42
- if (req.adminizer.accessRightsHelper.hasPermission(inlineAction.accessRightsToken, req.session.UserAP)) {
42
+ if (req.adminizer.accessRightsHelper.hasPermission(inlineAction.accessRightsToken, req.user)) {
43
43
  props.inlineActions.push({
44
44
  icon: inlineAction.icon,
45
45
  id: inlineAction.id,
@@ -3,6 +3,6 @@ export declare class InertiaMenuHelper {
3
3
  private adminizer;
4
4
  constructor(adminizer: Adminizer);
5
5
  getMenuItems(req: ReqType): import("./menuHelper").MenuItem[];
6
- getBrandTitle(): any;
6
+ getBrandTitle(): string;
7
7
  getLogoutUrl(): string;
8
8
  }
@@ -5,7 +5,7 @@ export class InertiaMenuHelper {
5
5
  }
6
6
  getMenuItems(req) {
7
7
  let menu = [];
8
- for (const menuItem of this.adminizer.menuHelper.getMenuItems()) {
8
+ for (const menuItem of this.adminizer.menuHelper.getMenuItems(req.user)) {
9
9
  const menuItemTokens = menuItem.actions ? menuItem.actions.map(item => {
10
10
  return item.accessRightsToken;
11
11
  }).filter(item => {
@@ -13,7 +13,7 @@ export class InertiaMenuHelper {
13
13
  }) : [];
14
14
  if (menuItem.accessRightsToken)
15
15
  menuItemTokens.push(menuItem.accessRightsToken);
16
- if (this.adminizer.accessRightsHelper.enoughPermissions(menuItemTokens, req.session.UserAP)) {
16
+ if (this.adminizer.accessRightsHelper.enoughPermissions(menuItemTokens, req.user)) {
17
17
  menu.push(menuItem);
18
18
  }
19
19
  }
@@ -1,3 +1,5 @@
1
+ import { GroupAP } from "models/GroupAP";
2
+ import { UserAP } from "models/UserAP";
1
3
  import { Entity, PropsField } from "../interfaces/types";
2
4
  interface listProps extends Record<string | number | symbol, unknown> {
3
5
  edit: boolean;
@@ -16,6 +18,10 @@ interface listProps extends Record<string | number | symbol, unknown> {
16
18
  fields: PropsField[];
17
19
  groups: PropsField[];
18
20
  locales: Record<string, string>[];
21
+ userPretend: {
22
+ label: string;
23
+ postLink: string;
24
+ };
19
25
  }
20
- export declare function inertiaUserHelper(entity: Entity, req: ReqType, groups: ModelsAP["GroupAP"][], user?: ModelsAP["UserAP"], view?: boolean): listProps;
26
+ export declare function inertiaUserHelper(entity: Entity, req: ReqType, groups: GroupAP[], user?: UserAP, view?: boolean): listProps;
21
27
  export {};
@@ -6,6 +6,10 @@ export function inertiaUserHelper(entity, req, groups, user, view = false) {
6
6
  title: req.i18n.__('Back'),
7
7
  link: entity.uri
8
8
  },
9
+ userPretend: {
10
+ label: req.i18n.__('Pretend to be a user'),
11
+ postLink: `${req.adminizer.config.routePrefix}/model/userap/login`
12
+ },
9
13
  passwordError: req.i18n.__('Values in "password" and "repeatPassword" fields should be the same'),
10
14
  btnSave: {
11
15
  title: req.i18n.__('Save')
@@ -58,7 +62,7 @@ export function inertiaUserHelper(entity, req, groups, user, view = false) {
58
62
  value: user?.locale ?? ''
59
63
  });
60
64
  }
61
- if (req.session.UserAP.isAdministrator) {
65
+ if (req.user.isAdministrator) {
62
66
  props.fields.push({
63
67
  label: req.i18n.__('Profile expires'),
64
68
  type: 'date',
@@ -3,6 +3,7 @@
3
3
  *
4
4
  * @constructor
5
5
  */
6
+ import { UserAP } from "models/UserAP";
6
7
  import { ActionType, AdminpanelConfig, HrefConfig, ModelConfig } from "../interfaces/adminpanelConfig";
7
8
  export type MenuItem = {
8
9
  link: string;
@@ -13,16 +14,20 @@ export type MenuItem = {
13
14
  icon: string;
14
15
  accessRightsToken: string;
15
16
  entityName?: string;
17
+ /**
18
+ * Section grouping for navbar items (side navigation)
19
+ */
20
+ section?: string;
16
21
  };
17
22
  export declare class MenuHelper {
18
- private static config;
23
+ private config;
19
24
  constructor(config: AdminpanelConfig);
20
25
  /**
21
26
  * Get menu brand title
22
27
  *
23
28
  * @returns {string}
24
29
  */
25
- getBrandTitle(): any;
30
+ getBrandTitle(): string;
26
31
  /**
27
32
  * Check if global actions buttons added to action
28
33
  *
@@ -60,5 +65,5 @@ export declare class MenuHelper {
60
65
  *
61
66
  * @returns {Array}
62
67
  */
63
- getMenuItems(): MenuItem[];
68
+ getMenuItems(user: UserAP): MenuItem[];
64
69
  }
@@ -1,7 +1,8 @@
1
+ import { GroupsAccessRightsHelper } from "./accessRightsHelper";
1
2
  export class MenuHelper {
2
- static config;
3
+ config;
3
4
  constructor(config) {
4
- MenuHelper.config = config;
5
+ this.config = config;
5
6
  }
6
7
  /**
7
8
  * Get menu brand title
@@ -9,14 +10,14 @@ export class MenuHelper {
9
10
  * @returns {string}
10
11
  */
11
12
  getBrandTitle() {
12
- if (!MenuHelper.config.brand || !MenuHelper.config.brand.link) {
13
+ if (!this.config.brand || !this.config.brand.link) {
13
14
  return 'Adminizer';
14
15
  }
15
- if (typeof MenuHelper.config.brand.link === "string") {
16
- return MenuHelper.config.brand.link;
16
+ if (typeof this.config.brand.link === "string") {
17
+ return this.config.brand.link;
17
18
  }
18
- if (typeof MenuHelper.config.brand.link === "object" && typeof MenuHelper.config.brand.link.title === "string") {
19
- return MenuHelper.config.brand.link.title;
19
+ if (typeof this.config.brand.link === "object" && typeof this.config.brand.link.title === "string") {
20
+ return this.config.brand.link.title;
20
21
  }
21
22
  return 'Adminizer';
22
23
  }
@@ -98,10 +99,10 @@ export class MenuHelper {
98
99
  *
99
100
  * @returns {Array}
100
101
  */
101
- getMenuItems() {
102
+ getMenuItems(user) {
102
103
  let menus = [];
103
- if (MenuHelper.config.navbar.additionalLinks && MenuHelper.config.navbar.additionalLinks.length > 0) {
104
- MenuHelper.config.navbar.additionalLinks.forEach(function (additionalLink) {
104
+ if (this.config.navbar.additionalLinks && this.config.navbar.additionalLinks.length > 0) {
105
+ this.config.navbar.additionalLinks.forEach(function (additionalLink) {
105
106
  if (!additionalLink.link || !additionalLink.title || additionalLink.disabled) {
106
107
  return;
107
108
  }
@@ -112,17 +113,24 @@ export class MenuHelper {
112
113
  id: additionalLink.id || additionalLink.title.replace(" ", "_"),
113
114
  actions: additionalLink.subItems || null,
114
115
  icon: additionalLink.icon || null,
115
- accessRightsToken: additionalLink.accessRightsToken || null
116
+ accessRightsToken: additionalLink.accessRightsToken || null,
117
+ section: additionalLink.section || 'Platform',
116
118
  });
117
119
  });
118
120
  }
119
- if (MenuHelper.config.models) {
120
- Object.entries(MenuHelper.config.models).forEach(function ([key, val]) {
121
- if (!val.hide) {
121
+ if (this.config.models) {
122
+ const _this = this;
123
+ Object.entries(this.config.models).forEach(function ([key, val]) {
124
+ const hide = typeof val.navbar?.visible === 'boolean'
125
+ ? !val.navbar.visible
126
+ : val.navbar?.groupsAccessRights
127
+ ? !GroupsAccessRightsHelper.hasAccess(user, val.navbar.groupsAccessRights)
128
+ : false;
129
+ if (!hide) {
122
130
  if (val.tools && val.tools.length > 0 && val.tools[0].id !== "overview") {
123
131
  val.tools.unshift({
124
132
  id: "overview",
125
- link: MenuHelper.config.routePrefix + '/model/' + key,
133
+ link: _this.config.routePrefix + '/model/' + key,
126
134
  title: 'Overview',
127
135
  type: 'self',
128
136
  icon: "list",
@@ -130,13 +138,14 @@ export class MenuHelper {
130
138
  });
131
139
  }
132
140
  menus.push({
133
- link: MenuHelper.config.routePrefix + '/model/' + key,
141
+ link: _this.config.routePrefix + '/model/' + key,
134
142
  title: val.title || key,
135
143
  icon: val.icon || null,
136
144
  actions: val.tools || null,
137
145
  id: val.title ? val.title.replace(" ", "_") : key,
138
146
  entityName: key,
139
- accessRightsToken: `read-${key}-model`
147
+ accessRightsToken: `read-${key}-model`,
148
+ section: val.navbar?.section || 'Platform',
140
149
  });
141
150
  }
142
151
  });
package/index.d.ts CHANGED
@@ -1,11 +1,14 @@
1
1
  export * from "./helpers/configHelper";
2
2
  export * from "./helpers/accessRightsHelper";
3
- export * from "./lib/installStepper/installStepper";
4
- export * from "./lib/widgets/widgetHandler";
5
- export * from "./lib/catalog/CatalogHandler";
3
+ export * from "./lib/v4/widgets/widgetHandler";
4
+ export * from "./lib/v4/catalog/CatalogHandler";
6
5
  export * from "./lib/media-manager/MediaManagerHandler";
7
6
  export * from "./interfaces/adminpanelConfig";
8
7
  export * from "./lib/v4/model/AbstractModel";
9
8
  export * from "./lib/v4/model/adapter/waterline";
10
9
  export * from "./lib/v4/model/adapter/typeorm";
10
+ export * from "./lib/v4/model/adapter/sequelize";
11
11
  export * from "./lib/Adminizer";
12
+ export * from "./models/GroupAP";
13
+ export * from "./models/UserAP";
14
+ export * from "./models/NavigationAP";
package/index.js CHANGED
@@ -1,11 +1,17 @@
1
1
  export * from "./helpers/configHelper";
2
2
  export * from "./helpers/accessRightsHelper";
3
- export * from "./lib/installStepper/installStepper";
4
- export * from "./lib/widgets/widgetHandler";
5
- export * from "./lib/catalog/CatalogHandler";
3
+ export * from "./lib/v4/widgets/widgetHandler";
4
+ export * from "./lib/v4/catalog/CatalogHandler";
6
5
  export * from "./lib/media-manager/MediaManagerHandler";
7
6
  export * from "./interfaces/adminpanelConfig";
8
7
  export * from "./lib/v4/model/AbstractModel";
9
8
  export * from "./lib/v4/model/adapter/waterline";
10
9
  export * from "./lib/v4/model/adapter/typeorm";
10
+ export * from "./lib/v4/model/adapter/sequelize";
11
11
  export * from "./lib/Adminizer";
12
+ export * from "./models/GroupAP";
13
+ export * from "./models/UserAP";
14
+ // export * from "./models/MediaManagerAP"
15
+ // export * from "./models/MediaManagerAssociationsAP"
16
+ // export * from "./models/MediaManagerMetaAP"
17
+ export * from "./models/NavigationAP";
@@ -1,6 +1,8 @@
1
1
  import { MaterialIcon } from "./MaaterialIcons";
2
2
  import { EditorOptions } from "@toast-ui/editor/types/editor";
3
3
  import { GridSettings as HandsontableSettings } from "handsontable/settings";
4
+ import { GroupAP } from "models/GroupAP";
5
+ import { UserAP } from "models/UserAP";
4
6
  export type AdminpanelIcon = MaterialIcon;
5
7
  export type FieldsTypes = "string" | "password" | "date" | "datetime" | "time" | "integer" | "number" | "float" | "color" | "email" | "month" | "week" | "range" | "boolean" | "binary" | "text" | "longtext" | "mediumtext" | "ckeditor" | "wysiwyg" | "texteditor" | "word" | 'tui' | 'tuieditor' | 'toast-ui' | "jsoneditor" | "json" | "array" | "object" | "ace" | "code" | "html" | "xml" | "aceeditor" | "menu" | "schedule" | "worktime" | "association" | "association-many" | "select" | "select-many" | "table" | "geojson" | "mediamanager" |
6
8
  /**
@@ -28,7 +30,11 @@ export interface AdminpanelConfig {
28
30
  * by default is false
29
31
  */
30
32
  auth?: {
33
+ /** Enable or disable authentication for admin panel */
31
34
  enable: boolean;
35
+ /** Enable crypto-puzzle CAPTCHA (default: true) */
36
+ captcha?: boolean;
37
+ /** Description displayed on login page */
32
38
  description?: string;
33
39
  };
34
40
  /**
@@ -37,7 +43,7 @@ export interface AdminpanelConfig {
37
43
  * reference upload contoroller ~50 line
38
44
  * */
39
45
  models: {
40
- [key: string]: ModelConfig | boolean;
46
+ [key: string]: ModelConfig;
41
47
  };
42
48
  /**
43
49
  * For custom adminpanel sections, displays inside header
@@ -121,23 +127,6 @@ export interface AdminpanelConfig {
121
127
  * */
122
128
  set?: SetFunction;
123
129
  };
124
- /**
125
- * Wizards
126
- * */
127
- installStepper?: {
128
- path: string;
129
- data: {
130
- [key: string]: FieldsModels;
131
- };
132
- /**
133
- * Custom getter
134
- * */
135
- get?: GetFunction;
136
- /**
137
- * Custom setter
138
- * */
139
- set?: SetFunction;
140
- };
141
130
  /**
142
131
  * Prime administrator login credentials
143
132
  * */
@@ -178,12 +167,6 @@ export interface AdminpanelConfig {
178
167
  * Navigation
179
168
  */
180
169
  navigation?: NavigationConfig;
181
- /**
182
- * Path to modules views
183
- */
184
- modulesViewsPath?: string;
185
- /** @deprecated (module manager can be used it somehow) */
186
- templateRootPath?: string;
187
170
  mediamanager?: MediaManagerConfig;
188
171
  /** System settings */
189
172
  system?: {
@@ -199,9 +182,23 @@ export interface ModelConfig {
199
182
  * */
200
183
  model: string;
201
184
  /**
202
- * Hide entity in left navbar
185
+ * If the field is not definitely, then it will appear in Navbar
203
186
  * */
204
- hide?: boolean;
187
+ navbar?: {
188
+ /**
189
+ * @default true
190
+ */
191
+ visible?: boolean;
192
+ /**
193
+ * User groups who will see the menu item
194
+ * For which it will be shown if not established will be shown to all groups who have the rights to read
195
+ */
196
+ groupsAccessRights?: string[];
197
+ /**
198
+ * Optional section grouping for navbar items (side navigation)
199
+ */
200
+ section?: string;
201
+ };
205
202
  /**
206
203
  * Entity fields configuration
207
204
  * */
@@ -228,7 +225,7 @@ export interface ModelConfig {
228
225
  filter?: {
229
226
  [key: string]: {
230
227
  name: string;
231
- criteria: any;
228
+ criteria: Record<string, any>;
232
229
  };
233
230
  };
234
231
  } | boolean;
@@ -256,6 +253,11 @@ export interface ModelConfig {
256
253
  * Entity icon
257
254
  * */
258
255
  icon?: MaterialIcon;
256
+ /**
257
+ * The field that will be shown for communication
258
+ * @default `title` or `name`
259
+ */
260
+ titleField?: string;
259
261
  /**
260
262
  * Force set primary key
261
263
  * */
@@ -264,12 +266,12 @@ export interface ModelConfig {
264
266
  * May be association or association-many to UserAP or GroupAP */
265
267
  userAccessRelation?: {
266
268
  field: string;
267
- via: string;
269
+ via?: string;
268
270
  } | string;
269
271
  userAccessRelationCallback?: (userWithGroups: UserWithGroups, record: any) => boolean;
270
272
  }
271
- type UserWithGroups = ModelsAP["UserAP"] & {
272
- groups: ModelsAP["GroupAP"][];
273
+ type UserWithGroups = UserAP & {
274
+ groups: GroupAP[];
273
275
  };
274
276
  export interface FieldsForms {
275
277
  [key: string]: FormFieldConfig;
@@ -306,6 +308,7 @@ export interface BaseFieldConfig {
306
308
  identifierField?: string;
307
309
  /**
308
310
  * Label for associations
311
+ * @deprecated use model labelField prop
309
312
  * */
310
313
  displayField?: string;
311
314
  /**
@@ -316,6 +319,8 @@ export interface BaseFieldConfig {
316
319
  disabled?: boolean;
317
320
  /** Show as required element HTML */
318
321
  required?: boolean;
322
+ /** show or hode element, default `true` */
323
+ visible?: boolean;
319
324
  }
320
325
  export interface TuiEditorFieldConfig extends BaseFieldConfig {
321
326
  type: 'tui' | 'tuieditor' | 'toast-ui';
@@ -403,11 +408,15 @@ export interface HrefConfig {
403
408
  /**
404
409
  * Only for view, controller still uses his own access rights token
405
410
  * */
406
- accessRightsToken?: string;
411
+ accessRightsToken?: string | undefined;
407
412
  /**
408
413
  * For menu items only
409
414
  * */
410
415
  subItems?: HrefConfig[];
416
+ /**
417
+ * Optional section grouping for navbar items (side navigation)
418
+ */
419
+ section?: string;
411
420
  }
412
421
  export interface NavigationItemTypeConfig {
413
422
  model: string;
@@ -426,7 +435,7 @@ export interface NavigationConfig {
426
435
  }[];
427
436
  allowContentInGroup?: boolean;
428
437
  items: NavigationItemTypeConfig[];
429
- movingGroupsRootOnly: boolean;
438
+ movingGroupsRootOnly?: boolean;
430
439
  }
431
440
  export interface MediaManagerConfig {
432
441
  allowMIME?: string[];