adminizer 4.1.0-build.23 → 4.1.0-build.25

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,6 +1,6 @@
1
1
  import inertiaActionsHelper from "./inertiaActionsHelper";
2
2
  import chalk from "chalk";
3
- import { isObject } from "lodash-es";
3
+ import { isObject } from "./JsUtils";
4
4
  export default function inertiaAddHelper(req, entity, fields, record, view = false) {
5
5
  const actionType = 'add';
6
6
  let props = {
@@ -1,6 +1,6 @@
1
1
  import { ControllerHelper } from "../../helpers/controllerHelper";
2
2
  import { Adminizer } from "../Adminizer";
3
- import { isObject } from "helpers/JsUtils";
3
+ import { isObject } from "../../helpers/JsUtils";
4
4
  export class DataAccessor {
5
5
  adminizer;
6
6
  user;
@@ -88,9 +88,10 @@ export class DataAccessor {
88
88
  const model = this.adminizer.modelHandler.model.get(modelName);
89
89
  if (model) {
90
90
  populatedModelFieldsConfig = this.getAssociatedFieldsConfig(modelName);
91
- if (!isObject(this.adminizer.config.models[modelName]))
92
- throw `type error: model config of ${modelName} is ${typeof (this.adminizer.config.models[modelName])} expected object`;
93
- associatedModelConfig = this.adminizer.config.models[modelName];
91
+ let _modelConfig = this.adminizer.config.models[model.identity];
92
+ if (!isObject(_modelConfig))
93
+ throw `type error: model config of ${model.identity} is ${typeof (this.adminizer.config.models[model.identity])} expected object`;
94
+ associatedModelConfig = _modelConfig;
94
95
  }
95
96
  else {
96
97
  Adminizer.log.error(`DataAccessor > getFieldsConfig > Model not found: ${modelName} when ${key}`);
@@ -110,8 +111,8 @@ export class DataAccessor {
110
111
  return result;
111
112
  }
112
113
  getAssociatedFieldsConfig(modelName) {
113
- const Model = this.adminizer.modelHandler.model.get(modelName);
114
- if (!Model || !this.adminizer.config.models[modelName] || typeof this.adminizer.config.models[modelName] === "boolean") {
114
+ const model = this.adminizer.modelHandler.model.get(modelName);
115
+ if (!model || !this.adminizer.config.models[model.identity] || typeof this.adminizer.config.models[model.identity] === "boolean") {
115
116
  return undefined;
116
117
  }
117
118
  // Check if user has access to the associated model
@@ -121,7 +122,9 @@ export class DataAccessor {
121
122
  return undefined;
122
123
  }
123
124
  const associatedFields = {};
124
- const modelConfig = this.adminizer.config.models[modelName];
125
+ const modelConfig = this.adminizer.config.models[model.identity];
126
+ if (!isObject(modelConfig))
127
+ throw `Type error ModelConfig should is object`;
125
128
  // Get the main fields configuration
126
129
  const fieldsConfig = modelConfig.fields || {};
127
130
  // Merge action-specific fields configuration if it exists
@@ -149,7 +152,7 @@ export class DataAccessor {
149
152
  }
150
153
  const mergedFieldsConfig = { ...fieldsConfig, ...actionSpecificConfig };
151
154
  // Loop through model attributes and apply access checks
152
- Object.entries(Model.attributes).forEach(([key, modelField]) => {
155
+ Object.entries(model.attributes).forEach(([key, modelField]) => {
153
156
  const fieldConfig = mergedFieldsConfig[key];
154
157
  // Creating a basic config
155
158
  let fldConfig = { key: key, title: key };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "adminizer",
3
3
  "type": "module",
4
- "version": "4.1.0-build.23",
4
+ "version": "4.1.0-build.25",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "test": "vitest --reporter verbose",
@@ -82,7 +82,6 @@
82
82
  "@types/json-schema": "^7.0.15",
83
83
  "@types/jsonwebtoken": "^9.0.9",
84
84
  "@types/leaflet": "^1.9.17",
85
- "@types/lodash-es": "^4.17.12",
86
85
  "@types/multer": "^1.4.12",
87
86
  "@types/node": "^22.10.5",
88
87
  "@types/password-hash": "^1.2.24",
@@ -104,7 +103,6 @@
104
103
  "json-schema": "^0.4.0",
105
104
  "leaflet": "^1.9.4",
106
105
  "leaflet-draw": "^1.0.4",
107
- "lodash-es": "^4.17.21",
108
106
  "lucide-react": "^0.485.0",
109
107
  "material-icons": "^1.13.14",
110
108
  "react": "^19.0.0",