adminizer 4.2.0-build.59 → 4.2.0-build.61

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.
@@ -1,4 +1,3 @@
1
- import { CatalogHandler } from "../../lib/v4/catalog/CatalogHandler";
2
1
  import { VueCatalog } from "./FrontentCatalogAdapter";
3
2
  import { Adminizer } from "../../lib/Adminizer";
4
3
  export async function catalogController(req, res) {
@@ -16,7 +15,7 @@ export async function catalogController(req, res) {
16
15
  if (slug === 'navigation' && !id) {
17
16
  return res.sendStatus(404);
18
17
  }
19
- const _catalog = CatalogHandler.getCatalog(slug);
18
+ const _catalog = req.adminizer.catalogHandler.getCatalog(slug);
20
19
  if (_catalog === undefined)
21
20
  return res.sendStatus(404);
22
21
  const idList = await _catalog.getIdList();
@@ -1,7 +1,6 @@
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/v4/catalog/CatalogHandler";
5
4
  import { getRelationsMediaManager, saveRelationsMediaManager } from "../lib/media-manager/helpers/MediaManagerHelper";
6
5
  import { DataAccessor } from "../lib/v4/DataAccessor";
7
6
  import { Adminizer } from "../lib/Adminizer";
@@ -122,7 +121,7 @@ export default async function edit(req, res) {
122
121
  // update navigation tree after model updated
123
122
  if (req.adminizer.config.navigation) {
124
123
  for (const section of req.adminizer.config.navigation.sections) {
125
- let navigation = CatalogHandler.getCatalog('navigation');
124
+ let navigation = req.adminizer.catalogHandler.getCatalog('navigation');
126
125
  navigation.setId(section);
127
126
  let navItem = navigation.itemTypes.find(item => item.type === entity.name.toLowerCase());
128
127
  if (navItem) {
@@ -11,6 +11,7 @@ import { AbstractAdapter } from "./v4/model/AbstractModel";
11
11
  import type { ViteDevServer } from 'vite';
12
12
  import { MenuHelper } from "../helpers/menuHelper";
13
13
  import { ControlsHandler } from "./v4/controls/ControlsHandler";
14
+ import { CatalogHandler } from "./v4/catalog/CatalogHandler";
14
15
  export declare class Adminizer {
15
16
  /**
16
17
  * If you convey this default Middleware, it will add it to the very top of the router,
@@ -29,6 +30,7 @@ export declare class Adminizer {
29
30
  widgetHandler: WidgetHandler;
30
31
  vite: ViteDevServer;
31
32
  controlsHandler: ControlsHandler;
33
+ catalogHandler: CatalogHandler;
32
34
  jwtSecret: string;
33
35
  static logger: winston.Logger;
34
36
  constructor(ormAdapters: AbstractAdapter[]);
package/lib/Adminizer.js CHANGED
@@ -27,6 +27,7 @@ import { bindInertia } from "../system/bindInertia";
27
27
  import { MenuHelper } from "../helpers/menuHelper";
28
28
  import { bindControls } from "../system/bindControls";
29
29
  import { ControlsHandler } from "./v4/controls/ControlsHandler";
30
+ import { CatalogHandler } from "./v4/catalog/CatalogHandler";
30
31
  import { v4 as uuid } from "uuid";
31
32
  export class Adminizer {
32
33
  // Preconfigures
@@ -48,6 +49,7 @@ export class Adminizer {
48
49
  widgetHandler;
49
50
  vite;
50
51
  controlsHandler;
52
+ catalogHandler;
51
53
  // Constants
52
54
  jwtSecret = process.env.JWT_SECRET ?? uuid();
53
55
  static logger = winston.createLogger({
@@ -145,6 +147,7 @@ export class Adminizer {
145
147
  this.configHelper = new ConfigHelper(this);
146
148
  this.menuHelper = new MenuHelper(this.config);
147
149
  this.widgetHandler = new WidgetHandler(this);
150
+ this.catalogHandler = new CatalogHandler();
148
151
  bindExpressUtils(this.app);
149
152
  bindReqFunctions(this);
150
153
  // Bind assets
@@ -1,7 +1,7 @@
1
1
  import { AbstractCatalog } from "./AbstractCatalog";
2
2
  export declare class CatalogHandler {
3
- private static catalog;
4
- static add(catalog: AbstractCatalog): AbstractCatalog;
5
- static getAll(): AbstractCatalog[];
6
- static getCatalog(slug: string): AbstractCatalog;
3
+ private catalog;
4
+ add(catalog: AbstractCatalog): AbstractCatalog;
5
+ getAll(): AbstractCatalog[];
6
+ getCatalog(slug: string): AbstractCatalog;
7
7
  }
@@ -1,13 +1,13 @@
1
1
  export class CatalogHandler {
2
- static catalog = [];
3
- static add(catalog) {
2
+ catalog = [];
3
+ add(catalog) {
4
4
  this.catalog.push(catalog);
5
5
  return catalog;
6
6
  }
7
- static getAll() {
7
+ getAll() {
8
8
  return this.catalog;
9
9
  }
10
- static getCatalog(slug) {
10
+ getCatalog(slug) {
11
11
  return this.catalog.find((catalog) => catalog.slug === slug);
12
12
  }
13
13
  }
@@ -1,8 +1,3 @@
1
- import { SwitchBase } from "./abstractSwitch";
2
- import { InfoBase } from "./abstractInfo";
3
- import { ActionBase } from "./abstractAction";
4
- import { LinkBase } from "./abstractLink";
5
- import { CustomBase } from "./abstractCustom";
6
1
  import * as process from "node:process";
7
2
  export class WidgetHandler {
8
3
  widgets = [];
@@ -40,7 +35,7 @@ export class WidgetHandler {
40
35
  if (this.widgets.length) {
41
36
  let id_key = 0;
42
37
  for (const widget of this.widgets) {
43
- if (widget instanceof SwitchBase) {
38
+ if (widget.widgetType === 'switcher') {
44
39
  if (this.adminizer.accessRightsHelper.hasPermission(`widget-${widget.id}`, user)) {
45
40
  widgets.push({
46
41
  id: `${widget.id}__${id_key}`,
@@ -54,7 +49,7 @@ export class WidgetHandler {
54
49
  });
55
50
  }
56
51
  }
57
- else if (widget instanceof InfoBase) {
52
+ else if (widget.widgetType === 'info') {
58
53
  if (this.adminizer.accessRightsHelper.hasPermission(`widget-${widget.id}`, user)) {
59
54
  widgets.push({
60
55
  id: `${widget.id}__${id_key}`,
@@ -68,7 +63,7 @@ export class WidgetHandler {
68
63
  });
69
64
  }
70
65
  }
71
- else if (widget instanceof ActionBase) {
66
+ else if (widget.widgetType === 'action') {
72
67
  if (this.adminizer.accessRightsHelper.hasPermission(`widget-${widget.id}`, user)) {
73
68
  widgets.push({
74
69
  id: `${widget.id}__${id_key}`,
@@ -82,7 +77,7 @@ export class WidgetHandler {
82
77
  });
83
78
  }
84
79
  }
85
- else if (widget instanceof LinkBase) {
80
+ else if (widget.widgetType === 'link') {
86
81
  if (this.adminizer.accessRightsHelper.hasPermission(`widget-${widget.id}`, user)) {
87
82
  let links_id_key = 0;
88
83
  for (const link of widget.links) {
@@ -100,7 +95,7 @@ export class WidgetHandler {
100
95
  }
101
96
  }
102
97
  }
103
- else if (widget instanceof CustomBase) {
98
+ else if (widget.widgetType === 'custom') {
104
99
  if (this.adminizer.accessRightsHelper.hasPermission(`widget-${widget.id}`, user)) {
105
100
  widgets.push({
106
101
  id: `${widget.id}_${id_key}`,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "adminizer",
3
3
  "type": "module",
4
- "version": "4.2.0-build.59",
4
+ "version": "4.2.0-build.61",
5
5
  "main": "index.js",
6
6
  "exports": {
7
7
  ".": "./index.js",
@@ -1,12 +1,11 @@
1
1
  import { Navigation } from "../lib/v4/catalog/Navigation";
2
- import { CatalogHandler } from "../lib/v4/catalog/CatalogHandler";
3
2
  export default function bindNavigation(adminizer) {
4
3
  adminizer.emitter.on("adminizer:loaded", async () => {
5
4
  if (adminizer.config.navigation) {
6
5
  try {
7
6
  adminizer.config.navigation.model = adminizer.config.navigation.model ? adminizer.config.navigation.model : 'NavigationAP';
8
7
  let navigation = new Navigation(adminizer, adminizer.config.navigation);
9
- CatalogHandler.add(navigation);
8
+ adminizer.catalogHandler.add(navigation);
10
9
  adminizer.config.models[adminizer.config.navigation.model.toLowerCase()] = {
11
10
  add: false,
12
11
  edit: {