adminizer 4.1.0-build.3 → 4.1.0-build.5

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.
@@ -77,7 +77,7 @@ export class ConfigHelper {
77
77
  }
78
78
  // Boolean notation: `true` means field is visible; `false` means field is hidden.
79
79
  if (typeof config === "boolean") {
80
- return config ? { title: key } : false;
80
+ return config ? { title: key } : { visible: false };
81
81
  }
82
82
  // String notation: Interpreted as the field title.
83
83
  if (typeof config === "string") {
@@ -86,6 +86,7 @@ export class ConfigHelper {
86
86
  // Object notation: Allows full customization of the field.
87
87
  if (typeof config === "object" && config !== null) {
88
88
  config.title = config.title || key;
89
+ config.visible = Boolean(config.visible);
89
90
  // For association types, determine display field by checking model attributes.
90
91
  if (["association", "association-many"].includes(config.type)) {
91
92
  let associatedModelAttributes = {};
@@ -25,6 +25,8 @@ export default function inertiaAddHelper(req, entity, fields, record, view = fal
25
25
  continue;
26
26
  let field = fields[key];
27
27
  let fieldConfig = field.config;
28
+ if (fieldConfig.visible === false)
29
+ continue;
28
30
  const type = (fieldConfig.type || fieldConfig.type).toLowerCase();
29
31
  //@ts-ignore TODO: fix model validations
30
32
  const isIn = typeof fieldConfig.isIn === 'object' ? fieldConfig.isIn : (field.model && typeof { ...field.model.validations }.isIn === 'object' ? { ...field.model.validations }.isIn : []);
@@ -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 ?? '';
@@ -316,6 +316,8 @@ export interface BaseFieldConfig {
316
316
  disabled?: boolean;
317
317
  /** Show as required element HTML */
318
318
  required?: boolean;
319
+ /** show or hode element */
320
+ visible?: boolean;
319
321
  }
320
322
  export interface TuiEditorFieldConfig extends BaseFieldConfig {
321
323
  type: 'tui' | 'tuieditor' | 'toast-ui';
@@ -26,6 +26,7 @@ export declare class Adminizer {
26
26
  controlsHandler: ControlsHandler;
27
27
  static logger: winston.Logger;
28
28
  constructor(ormAdapters: AbstractAdapter[]);
29
+ getMiddleware(): (req: any, res: any) => void;
29
30
  /**
30
31
  * Vite middleware
31
32
  * @protected
package/lib/Adminizer.js CHANGED
@@ -58,6 +58,21 @@ export class Adminizer {
58
58
  this._emitter = new EventEmitter();
59
59
  this.ormAdapters = ormAdapters;
60
60
  }
61
+ getMiddleware() {
62
+ return (req, res) => {
63
+ this.app(req, res, (err) => {
64
+ if (err) {
65
+ console.log("Error in Adminizer", err);
66
+ res.writeHead(500, { 'Content-Type': 'text/plain' });
67
+ res.end('Internal Server Error');
68
+ }
69
+ else {
70
+ res.writeHead(404, { 'Content-Type': 'text/plain' });
71
+ res.end('Route Not Found in Adminizer');
72
+ }
73
+ });
74
+ };
75
+ }
61
76
  /**
62
77
  * Vite middleware
63
78
  * @protected
@@ -42,7 +42,7 @@ function resolveType(type) {
42
42
  }
43
43
  /** SequelizeModel — реализация модели, совместимая с AbstractModel */
44
44
  function convertCriteriaToSequelize(criteria) {
45
- console.log("waterline criteria", criteria);
45
+ console.debug("waterline criteria", criteria);
46
46
  const result = {};
47
47
  for (const key in criteria) {
48
48
  const value = criteria[key];
@@ -80,7 +80,7 @@ function convertCriteriaToSequelize(criteria) {
80
80
  return result;
81
81
  }
82
82
  function convertWaterlineCriteriaToSequelizeOptions(criteria) {
83
- console.log("WATERLINE CRITERIA", criteria);
83
+ console.debug("WATERLINE CRITERIA", criteria);
84
84
  const { where = {}, skip, limit, sort } = criteria;
85
85
  const result = {
86
86
  where: convertCriteriaToSequelize(where),
@@ -48,7 +48,6 @@ export class WaterlineModel extends AbstractModel {
48
48
  query = query.limit(options.limit);
49
49
  }
50
50
  let result = await query;
51
- console.log(result, "result");
52
51
  return result;
53
52
  }
54
53
  async _updateOne(criteria, data) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "adminizer",
3
3
  "type": "module",
4
- "version": "4.1.0-build.3",
4
+ "version": "4.1.0-build.5",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1",
@@ -44,6 +44,7 @@
44
44
  "sharp": "^0.33.5",
45
45
  "typeorm": "^0.3.20",
46
46
  "uuid": "^11.0.5",
47
+ "waterline": "^0.15.2",
47
48
  "winston": "^3.17.0"
48
49
  },
49
50
  "devDependencies": {
@@ -117,7 +118,6 @@
117
118
  "vite": "^6.1.0",
118
119
  "vite-plugin-externals": "^0.6.2",
119
120
  "vite-plugin-full-reload": "^1.2.0",
120
- "waterline": "^0.15.2",
121
121
  "sqlite3": "^5.1.7",
122
122
  "sequelize": "^6.37.5",
123
123
  "sequelize-typescript": "^2.1.6"