adminizer 4.1.0-commit.d8a06d3 → 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 (253) hide show
  1. package/Readme.md +46 -0
  2. package/assets/{VanillaJSONEditor-D-Lx670g.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-WTooYWC3.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-es9ZT8qk.js +3 -0
  20. package/assets/{date-picker-DI1cCO7K.js → date-picker-Dz-d-YWX.js} +2 -2
  21. package/assets/debounce-qdyXyOeG.js +1 -0
  22. package/assets/del-modal-D0mrZvki.js +11 -0
  23. package/assets/dialog-stack-BiMbfm58.js +1 -0
  24. package/assets/dropdown-menu-BSBcRiXx.js +1 -0
  25. package/assets/{field-renderer-DVHZF6HS.js → field-renderer-B6hFAeiU.js} +3 -3
  26. package/assets/form-Buslty7y.js +1 -0
  27. package/assets/form-aqiRmPix.js +1 -0
  28. package/assets/{geo-json-BjiyTtMu.js → geo-json-BKmYmu3d.js} +2 -2
  29. package/assets/{handsontable-4mjU_b0n.js → handsontable-B8xVeMAQ.js} +5 -5
  30. package/assets/home-Dr72Jk-w.js +2 -0
  31. package/assets/icon-B-a7xg54.js +1 -0
  32. package/assets/index-B68_akQe.js +1 -0
  33. package/assets/index-B7-xTDyy.js +1 -0
  34. package/assets/index-BJFFlCSo.js +1 -0
  35. package/assets/{index-Cw5o84pO.js → index-BOuMo_nl.js} +3 -3
  36. package/assets/index-BzOcGsBq.js +1 -0
  37. package/assets/index-CFbQ2Rv0.js +1 -0
  38. package/assets/{index-D5ir9iUV.js → index-Cq31rrfZ.js} +1 -1
  39. package/assets/{index-Cgp8OfuI.js → index-D5UDXTFs.js} +1 -1
  40. package/assets/index-oxIQWAdI.js +41 -0
  41. package/assets/init-user-5H689LP0.js +1 -0
  42. package/assets/input-CSJjrf2i.js +1 -0
  43. package/assets/input-error-CK92Shhm.js +1 -0
  44. package/assets/label-Muj0-Efy.js +1 -0
  45. package/assets/list-Cvh7zbyG.js +1 -0
  46. package/assets/list-table-Bs_vbQiV.js +52 -0
  47. package/assets/login-DliJrjMQ.js +6 -0
  48. package/assets/manifest.json +575 -673
  49. package/assets/material-icon-BRS58Qpk.js +1 -0
  50. package/assets/module-CjG21VCT.js +1 -0
  51. package/assets/{monaco-editor-CJs0_GlD.js → monaco-editor-9fDiyfuW.js} +2 -2
  52. package/assets/{multi-select-BvRpAW8r.js → multi-select-CMQIJ0JT.js} +2 -2
  53. package/assets/nav-footer-IGMn9NiE.js +1 -0
  54. package/assets/nav-main-DBE4rMiZ.js +1 -0
  55. package/assets/nav-user-CjyLRyq-.js +1 -0
  56. package/assets/pagination-render-DUAq2klc.js +1 -0
  57. package/assets/popover-C_cww-4_.js +1 -0
  58. package/assets/register-UzQn3J0g.js +1 -0
  59. package/assets/{select-BWepUw-9.js → select-DzBno-dc.js} +2 -2
  60. package/assets/{sidebar-CAHsHdjM.js → sidebar-Dc4iqfu-.js} +2 -2
  61. package/assets/skeleton-Dkmj2o2Z.js +1 -0
  62. package/assets/sonner-De1t71Gj.js +1 -0
  63. package/assets/{toast-editor-CMK7QtF1.js → toast-editor-1Pul3oMs.js} +2 -2
  64. package/assets/tooltip-CwPrC-HD.js +1 -0
  65. package/assets/use-appearance-J8J2w43p.js +1 -0
  66. package/assets/use-window-size-DLSEoR6e.js +1 -0
  67. package/assets/{user-info-DFrmpJ4y.js → user-info-8RyDk7qh.js} +2 -2
  68. package/assets/user-menu-content-CpxTLH56.js +6 -0
  69. package/assets/welcome-BYKI6yO-.js +1 -0
  70. package/controllers/add.js +8 -8
  71. package/controllers/catalog/Catalog.d.ts +1 -1
  72. package/controllers/catalog/Catalog.js +40 -35
  73. package/controllers/catalog/FrontentCatalogAdapter.d.ts +36 -26
  74. package/controllers/catalog/FrontentCatalogAdapter.js +71 -72
  75. package/controllers/edit.js +8 -11
  76. package/controllers/list.js +2 -2
  77. package/controllers/login.js +16 -7
  78. package/controllers/navigation/edit.js +1 -1
  79. package/controllers/remove.js +1 -1
  80. package/controllers/view.js +1 -1
  81. package/helpers/JsUtils.d.ts +1 -0
  82. package/helpers/JsUtils.js +3 -0
  83. package/helpers/accessRightsHelper.d.ts +3 -0
  84. package/helpers/accessRightsHelper.js +27 -4
  85. package/helpers/controllerHelper.js +39 -18
  86. package/helpers/fieldsHelper.d.ts +3 -2
  87. package/helpers/fieldsHelper.js +5 -1
  88. package/helpers/inertiaAddHelper.d.ts +4 -5
  89. package/helpers/inertiaAddHelper.js +25 -7
  90. package/helpers/inertiaFromHelper.js +1 -1
  91. package/helpers/inertiaMenuHelper.d.ts +1 -1
  92. package/helpers/inertiaMenuHelper.js +1 -1
  93. package/helpers/menuHelper.d.ts +8 -3
  94. package/helpers/menuHelper.js +26 -17
  95. package/index.d.ts +2 -6
  96. package/index.js +5 -6
  97. package/interfaces/adminpanelConfig.d.ts +35 -30
  98. package/interfaces/global.d.ts +5 -2
  99. package/interfaces/types.d.ts +1 -1
  100. package/lib/Adminizer.d.ts +9 -3
  101. package/lib/Adminizer.js +32 -16
  102. package/lib/media-manager/Items.js +0 -3
  103. package/lib/requestProcessor.js +10 -3
  104. package/lib/v4/DataAccessor.d.ts +3 -1
  105. package/lib/v4/DataAccessor.js +43 -18
  106. package/lib/v4/I18n.js +2 -0
  107. package/lib/{catalog → v4/catalog}/AbstractCatalog.d.ts +89 -60
  108. package/lib/{catalog → v4/catalog}/AbstractCatalog.js +59 -54
  109. package/lib/v4/catalog/Navigation.d.ts +43 -0
  110. package/lib/v4/catalog/Navigation.js +457 -0
  111. package/lib/{controls → v4/controls}/AbstractControls.d.ts +1 -1
  112. package/lib/{controls → v4/controls}/codeEditor/MonacoEditor.d.ts +1 -1
  113. package/lib/{controls → v4/controls}/geojsoneditor/GeoEditor.d.ts +1 -1
  114. package/lib/{controls → v4/controls}/jsoneditor/JsonEditor.d.ts +1 -1
  115. package/lib/{controls → v4/controls}/markdown/ToastUiEditor.d.ts +1 -1
  116. package/lib/{controls → v4/controls}/table/Handsontable.d.ts +1 -1
  117. package/lib/{controls → v4/controls}/wysiwyg/CKeditor.d.ts +1 -1
  118. package/lib/{datatable → v4/datatable}/NodeTable.d.ts +3 -3
  119. package/lib/{datatable → v4/datatable}/NodeTable.js +8 -5
  120. package/lib/v4/model/AbstractModel.d.ts +5 -1
  121. package/lib/v4/model/AbstractModel.js +2 -1
  122. package/lib/v4/model/ModelHandler.js +1 -3
  123. package/lib/v4/model/adapter/sequelize.d.ts +8 -0
  124. package/lib/v4/model/adapter/sequelize.js +274 -133
  125. package/lib/v4/model/adapter/waterline.js +5 -2
  126. package/lib/{widgets → v4/widgets}/abstractLink.d.ts +1 -1
  127. package/lib/{widgets → v4/widgets}/abstractWidgetBase.d.ts +1 -1
  128. package/lib/{widgets → v4/widgets}/widgetHandler.d.ts +11 -4
  129. package/lib/{widgets → v4/widgets}/widgetHandler.js +1 -1
  130. package/models/NavigationAP.d.ts +2 -3
  131. package/models/NavigationAP.js +5 -6
  132. package/models/UserAP.d.ts +2 -3
  133. package/package.json +17 -6
  134. package/system/Router.js +8 -11
  135. package/system/bindAccessRights.js +0 -4
  136. package/system/bindControls.js +6 -6
  137. package/system/bindDev.js +1 -0
  138. package/system/bindInertia.js +9 -4
  139. package/system/bindMediaManager.js +0 -1
  140. package/system/bindModels.js +9 -6
  141. package/system/bindNavigation.d.ts +2 -0
  142. package/system/bindNavigation.js +42 -42
  143. package/system/bindReqFunctions.js +0 -1
  144. package/system/defaults.js +13 -6
  145. package/translations/ar.json +70 -1
  146. package/translations/cn.json +70 -1
  147. package/translations/de.json +71 -3
  148. package/translations/en.json +70 -102
  149. package/translations/es.json +70 -1
  150. package/translations/fr.json +70 -1
  151. package/translations/hi.json +70 -1
  152. package/translations/jp.json +70 -1
  153. package/translations/ko.json +70 -1
  154. package/translations/pt.json +70 -1
  155. package/translations/ru.json +71 -103
  156. package/translations/ua.json +70 -1
  157. package/translations/uz.json +72 -0
  158. package/translations/vi.json +70 -1
  159. package/assets/add-BP_u3Tjl.js +0 -1
  160. package/assets/add-form-nffmiYTh.js +0 -1
  161. package/assets/add-group-D4vcHlm-.js +0 -1
  162. package/assets/add-group-form-gNJW11-q.js +0 -1
  163. package/assets/add-user-DWh3Nas0.js +0 -1
  164. package/assets/add-user-form-BJ0FsZYJ.js +0 -1
  165. package/assets/app-layout-DYsRFUuP.js +0 -1
  166. package/assets/app-shell-Dd9Eknik.js +0 -1
  167. package/assets/app-sidebar-BOmu6-Sl.js +0 -1
  168. package/assets/app-sidebar-header-CoXSzWxk.js +0 -11
  169. package/assets/breadcrumbs-BmAq4fHT.js +0 -1
  170. package/assets/button-C9B_5Jf_.js +0 -1
  171. package/assets/checkbox-Fg27sL_1.js +0 -1
  172. package/assets/compiler-runtime-hB6dAw2d.js +0 -9
  173. package/assets/dashboard-BACj996r.js +0 -3
  174. package/assets/dropdown-menu-Bhj17ENm.js +0 -1
  175. package/assets/form-BgWdwvz1.js +0 -1
  176. package/assets/form-DgtErfln.js +0 -1
  177. package/assets/home-CHntBHJa.js +0 -2
  178. package/assets/icon-Dt0vBgDO.js +0 -1
  179. package/assets/index-B8BS9wMC.js +0 -1
  180. package/assets/index-BC0yfOHo.js +0 -1
  181. package/assets/index-BKCgnGj_.js +0 -1
  182. package/assets/index-BbXEMx9n.js +0 -1
  183. package/assets/index-BykbU6Ee.js +0 -41
  184. package/assets/index-CaJgc5EZ.js +0 -1
  185. package/assets/index-DrWfGwtf.js +0 -1
  186. package/assets/init-user-JfCKJ5Ce.js +0 -1
  187. package/assets/input-CvRbIbk4.js +0 -1
  188. package/assets/input-error-DMK7cAt7.js +0 -1
  189. package/assets/label-CSLFe9Bz.js +0 -1
  190. package/assets/list-B2Oa5O_Q.js +0 -1
  191. package/assets/list-table-DA9MhywL.js +0 -62
  192. package/assets/login-DQwGtdis.js +0 -6
  193. package/assets/material-icon-BJg8o_fs.js +0 -1
  194. package/assets/module-DWXp59Vg.js +0 -1
  195. package/assets/nav-footer-Bs4dmN1d.js +0 -1
  196. package/assets/nav-main-Bq3IMk4C.js +0 -1
  197. package/assets/nav-user-CbB22J5O.js +0 -1
  198. package/assets/pagination-render-DuXDDbC_.js +0 -1
  199. package/assets/popover-DtoGI2b1.js +0 -1
  200. package/assets/register-BSogVF0h.js +0 -1
  201. package/assets/skeleton-COOcAA8f.js +0 -1
  202. package/assets/sonner-BI0IFOQN.js +0 -1
  203. package/assets/tooltip-DHwpLKOI.js +0 -1
  204. package/assets/use-appearance-DRfIqTgw.js +0 -1
  205. package/assets/use-window-size-h0Sh_NvX.js +0 -1
  206. package/assets/user-menu-content-DPXQdERj.js +0 -6
  207. package/assets/utils-DjqsqOe8.js +0 -1
  208. package/assets/welcome-B4WCIXKf.js +0 -1
  209. package/controllers/processInstallFinalize.d.ts +0 -1
  210. package/controllers/processInstallFinalize.js +0 -16
  211. package/controllers/processInstallStep.d.ts +0 -0
  212. package/controllers/processInstallStep.js +0 -122
  213. package/lib/catalog/Navigation.d.ts +0 -0
  214. package/lib/catalog/Navigation.js +0 -532
  215. package/lib/installStepper/InstallStepAbstract.d.ts +0 -52
  216. package/lib/installStepper/InstallStepAbstract.js +0 -69
  217. package/lib/installStepper/finalizeStep.d.ts +0 -21
  218. package/lib/installStepper/finalizeStep.js +0 -48
  219. package/lib/installStepper/installStepper.d.ts +0 -40
  220. package/lib/installStepper/installStepper.js +0 -195
  221. package/models/MediaManagerAP.d.ts +0 -62
  222. package/models/MediaManagerAP.js +0 -45
  223. package/models/MediaManagerAssociationsAP.d.ts +0 -38
  224. package/models/MediaManagerAssociationsAP.js +0 -27
  225. package/models/MediaManagerMetaAP.d.ts +0 -30
  226. package/models/MediaManagerMetaAP.js +0 -21
  227. package/system/bindInstallStepper.d.ts +0 -2
  228. package/system/bindInstallStepper.js +0 -23
  229. /package/lib/{catalog → v4/catalog}/CatalogHandler.d.ts +0 -0
  230. /package/lib/{catalog → v4/catalog}/CatalogHandler.js +0 -0
  231. /package/lib/{controls → v4/controls}/AbstractControls.js +0 -0
  232. /package/lib/{controls → v4/controls}/ControlsHandler.d.ts +0 -0
  233. /package/lib/{controls → v4/controls}/ControlsHandler.js +0 -0
  234. /package/lib/{controls → v4/controls}/codeEditor/MonacoEditor.js +0 -0
  235. /package/lib/{controls → v4/controls}/geojsoneditor/GeoEditor.js +0 -0
  236. /package/lib/{controls → v4/controls}/jsoneditor/JsonEditor.js +0 -0
  237. /package/lib/{controls → v4/controls}/markdown/ToastUiEditor.js +0 -0
  238. /package/lib/{controls → v4/controls}/table/Handsontable.js +0 -0
  239. /package/lib/{controls → v4/controls}/wysiwyg/CKeditor.js +0 -0
  240. /package/lib/{inertia → v4/inertia}/flash.d.ts +0 -0
  241. /package/lib/{inertia → v4/inertia}/flash.js +0 -0
  242. /package/lib/{inertia → v4/inertia}/inertiaAdapter.d.ts +0 -0
  243. /package/lib/{inertia → v4/inertia}/inertiaAdapter.js +0 -0
  244. /package/lib/{widgets → v4/widgets}/abstractAction.d.ts +0 -0
  245. /package/lib/{widgets → v4/widgets}/abstractAction.js +0 -0
  246. /package/lib/{widgets → v4/widgets}/abstractCustom.d.ts +0 -0
  247. /package/lib/{widgets → v4/widgets}/abstractCustom.js +0 -0
  248. /package/lib/{widgets → v4/widgets}/abstractInfo.d.ts +0 -0
  249. /package/lib/{widgets → v4/widgets}/abstractInfo.js +0 -0
  250. /package/lib/{widgets → v4/widgets}/abstractLink.js +0 -0
  251. /package/lib/{widgets → v4/widgets}/abstractSwitch.d.ts +0 -0
  252. /package/lib/{widgets → v4/widgets}/abstractSwitch.js +0 -0
  253. /package/lib/{widgets → v4/widgets}/abstractWidgetBase.js +0 -0
@@ -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
- title: string;
4
- isLeaf: boolean;
5
- isExpanded: boolean;
6
- ind: number;
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
- getAddHTML(item: any, req: ReqType): Promise<{
35
- type: "link" | "html" | "jsonForm";
36
- data: string;
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
- getEditHTML(item: any, id: string | number, req: ReqType, modelId: string | number): Promise<{
39
- type: "link" | "html" | "jsonForm";
40
- data: string;
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(): import("../../lib/catalog/AbstractCatalog").BaseItem<Item>[];
43
- getLocales(req: ReqType): obj;
44
- getActions(items: NodeModel<any>[], type: string): Promise<import("../../lib/catalog/AbstractCatalog").ActionHandler[]>;
45
- handleAction(actionId: string, items: any[], config: any): Promise<void>;
46
- getPopUpHTML(actionId: string): Promise<string>;
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(items: NodeModel<any>[]): Promise<{
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
- import { AbstractCatalog } from "../../lib/catalog/AbstractCatalog";
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
- getAddHTML(item, req) {
14
- return this.catalog.getAddHTML(item, req);
16
+ getAddTemplate(item, req) {
17
+ return this.catalog.getAddTemplate(item, req);
15
18
  }
16
- getEditHTML(item, id, req, modelId) {
17
- return this.catalog.getEditHTML(item, id, req, modelId);
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, cancel": "",
34
+ "No": "",
32
35
  "Are you sure?": "",
33
- "Yes, I'm sure": "",
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 outMessages;
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, config) {
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
- return this.catalog.handleAction(actionId, arrItems, config);
75
+ console.log(arrItems);
76
+ return this.catalog.handleAction(actionId, arrItems, data, req);
66
77
  }
67
- async getPopUpHTML(actionId) {
68
- return this.catalog.getPopUpHTML(actionId);
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(null);
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
- let item = data.record;
82
- item.parenId = data.parenId;
83
- return this.catalog.createItem(item);
84
- }
85
- else {
86
- return this.catalog.createItem(data);
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
- return VueCatalogUtils.treeToNode(itemsTree, this.catalog.getGroupType().type);
102
- }
103
- async updateTree(data) {
104
- let reqNodes = data.reqNode;
105
- if (!Array.isArray(data.reqNode)) {
106
- reqNodes = [data.reqNode];
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
- return await this.catalog.updateModelItems(data.modelId, data.type, data.record);
136
- }
137
- else {
138
- return await this.catalog.updateModelItems(modelId, item.type, data);
139
- }
140
- }
141
- async deleteItem(items) {
142
- for (const item1 of items) {
143
- if (item1.children?.length) {
144
- await this.deleteItem(item1.children);
145
- }
146
- this.catalog.deleteItem(item1.data.type, item1.data.id);
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
- isLeaf: data.type !== groupTypeName,
165
- isExpanded: false,
166
- ind: data.sortOrder,
167
- title: data.name
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.isLeaf;
193
+ // node.isExpanded = !node.droppable;
195
194
  }
196
195
  return node;
197
196
  });
@@ -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
- if (req.query.without_layout) {
159
- // return res.viewAdmin("./../ejs/partials/content/editPopup.ejs", {
160
- // entity: entity,
161
- // record: record,
162
- // fields: fields
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
@@ -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";
@@ -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
- const isCaptchaValid = powCaptcha.check(captchaSolution, `login:${req.ip}`);
38
- if (!isCaptchaValid) {
39
- return inertiaAdminMessage(req, "Invalid CAPTCHA solution", 'captchaSolution');
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 job
70
- const captchaTask = await powCaptcha.getJob(`login:${req.ip}`);
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
- const captchaTask = await powCaptcha.getJob(`login:${req.ip}`);
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
  }
@@ -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) {
@@ -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;
@@ -0,0 +1,3 @@
1
+ export function isObject(obj) {
2
+ return typeof obj === "object" && obj !== null;
3
+ }
@@ -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 token of this._tokens) {
13
- if (token.id === accessRightsToken.id) {
14
- throw new Error("Adminpanel > Can not register token: Token with this id already registered");
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
+ }
@@ -28,7 +28,15 @@ export class ControllerHelper {
28
28
  * @private
29
29
  */
30
30
  static _isValidModelConfig(config) {
31
- return (typeof config === "object" && typeof config.model === "string");
31
+ try {
32
+ if (!config)
33
+ throw `Config is not defined ${config}`;
34
+ return (typeof config === "object" && typeof config.model === "string");
35
+ }
36
+ catch (error) {
37
+ Adminizer.log.error(error);
38
+ return false;
39
+ }
32
40
  }
33
41
  ;
34
42
  /**
@@ -84,7 +92,7 @@ export class ControllerHelper {
84
92
  const entityType = req.params.entityType;
85
93
  if (!entityType) {
86
94
  const extractedEntityType = req.originalUrl.split('/')[2];
87
- if (["form", "model", "wizard"].includes(extractedEntityType)) {
95
+ if (["form", "model"].includes(extractedEntityType)) {
88
96
  return extractedEntityType;
89
97
  }
90
98
  else {
@@ -101,22 +109,28 @@ export class ControllerHelper {
101
109
  * @returns {?string}
102
110
  */
103
111
  static findEntityName(req) {
104
- if (!req.params.entityName) {
105
- let entityType = req.originalUrl.split('/')[2];
106
- let entityName = req.originalUrl.split('/')[3];
107
- if (entityType === "form" && (!req.adminizer.config.forms || !req.adminizer.config.forms.data || !req.adminizer.config.forms.data[entityName])) {
108
- return null;
109
- }
110
- else if (entityType === "model" && (!req.adminizer.config.models || !req.adminizer.config.models[entityName])) {
111
- return null;
112
+ if (req.params.entityName) {
113
+ return req.params.entityName;
114
+ }
115
+ const urlParts = req.originalUrl.split('/');
116
+ const entityType = urlParts[2];
117
+ const entityName = urlParts[3];
118
+ if (entityType === 'form') {
119
+ const forms = req.adminizer.config.forms?.data;
120
+ if (!forms || !Object.keys(forms).some(key => key.toLowerCase() === entityName.toLowerCase())) {
121
+ throw new Error(`Form "${entityName}" not found`);
112
122
  }
113
- else {
114
- return entityName;
123
+ return Object.keys(forms).find(key => key.toLowerCase() === entityName.toLowerCase());
124
+ }
125
+ if (entityType === 'model') {
126
+ const models = req.adminizer.config.models;
127
+ if (!models || !Object.keys(models).some(key => key.toLowerCase() === entityName.toLowerCase())) {
128
+ throw new Error(`Model "${entityName}" not found`);
115
129
  }
130
+ return Object.keys(models).find(key => key.toLowerCase() === entityName.toLowerCase());
116
131
  }
117
- return req.params.entityName;
132
+ throw new Error(`Unsupported entity type "${entityType}" in URL`);
118
133
  }
119
- ;
120
134
  /**
121
135
  * Searches for config from admin panel
122
136
  *
@@ -125,11 +139,17 @@ export class ControllerHelper {
125
139
  * @returns {?Object}
126
140
  */
127
141
  static findModelConfig(req, entityName) {
128
- if (!req.adminizer.config.models || !req.adminizer.config.models[entityName]) {
129
- Adminizer.log.error('No such route exists');
142
+ const models = req.adminizer.config.models;
143
+ if (!models) {
144
+ Adminizer.log.error('No models configuration found');
145
+ return null;
146
+ }
147
+ const foundKey = Object.keys(models).find(key => key.toLowerCase() === entityName.toLowerCase());
148
+ if (!foundKey) {
149
+ Adminizer.log.error(`No such route exists: ${entityName}`);
130
150
  return null;
131
151
  }
132
- return this._normalizeModelConfig(entityName, req.adminizer.config.models[entityName]);
152
+ return this._normalizeModelConfig(foundKey, models[foundKey]);
133
153
  }
134
154
  /**
135
155
  * Will get action config from configuration file depending to given action
@@ -200,7 +220,8 @@ export class ControllerHelper {
200
220
  name: entityName,
201
221
  uri: entityUri,
202
222
  type: entityType,
203
- model: null
223
+ model: null,
224
+ config: null
204
225
  };
205
226
  // If the entity type is "model", add additional properties
206
227
  if (entityType === "model") {
@@ -1,9 +1,9 @@
1
- import { ActionType, BaseFieldConfig, FieldsTypes } from "../interfaces/adminpanelConfig";
1
+ import { ActionType, BaseFieldConfig, FieldsTypes, ModelConfig } from "../interfaces/adminpanelConfig";
2
2
  import { Attribute } from "../lib/v4/model/AbstractModel";
3
3
  export type Field = {
4
4
  config: BaseFieldConfig & {
5
5
  /** @deprecated record should not be in config anymore */
6
- records?: object[];
6
+ records?: Record<string, any>[];
7
7
  file?: string;
8
8
  key?: string;
9
9
  required?: boolean;
@@ -15,6 +15,7 @@ export type Field = {
15
15
  [key: string]: Field;
16
16
  } | undefined;
17
17
  model: Attribute;
18
+ modelConfig: ModelConfig;
18
19
  };
19
20
  export type Fields = {
20
21
  [key: string]: Field;