forest-express-mongoose icon indicating copy to clipboard operation
forest-express-mongoose copied to clipboard

Forest Admin UI incorrectly display nested field

Open thongxuan opened this issue 2 years ago • 2 comments

Expected behavior

There should be a way to manually tell FA that some models are has-many-embeded. The Forest Admin UI display sub document as embeded.

Actual behavior

The Forest Admin UI is also incorrectly display the value.

Screenshot 2023-07-12 at 14 26 44

Failure Logs

import { getModelForClass, prop } from '@typegoose/typegoose';

class Meta {
  @prop()
  meta?: string;
}

class Model1 {
  @prop()
  field1?: Meta;

  @prop()
  field2?: number;
}

class Model2 {
  @prop()
  field3?: string;
}

export class Holy {
  @prop({ _id: true, type: Model1 })
  public first?: Model1[];

  @prop({ _id: true, type: Model2 })
  public second?: Model2[];
}

export const HolyModel = getModelForClass(Holy);

export default HolyModel;

.forestadmin-schema.json

{
    "name": "Holy",
    "nameOld": "holies",
    "icon": null,
    "integration": null,
    "isReadOnly": false,
    "isSearchable": true,
    "isVirtual": false,
    "onlyForRelationships": false,
    "paginationType": "page",
    "fields": [{
      "field": "_id",
      "type": "String",
      "defaultValue": null,
      "enums": null,
      "integration": null,
      "isFilterable": true,
      "isPrimaryKey": true,
      "isReadOnly": false,
      "isRequired": false,
      "isSortable": true,
      "isVirtual": false,
      "reference": null,
      "inverseOf": null,
      "validations": []
    }, {
      "field": "first",
      "type": [{
        "fields": [{
          "field": "field1",
          "type": {
            "fields": [{
              "field": "meta",
              "type": "String"
            }]
          }
        }, {
          "field": "field2",
          "type": "Number"
        }, {
          "field": "_id",
          "type": "String",
          "isPrimaryKey": true
        }]
      }],
      "defaultValue": null,
      "enums": null,
      "integration": null,
      "isFilterable": true,
      "isPrimaryKey": false,
      "isReadOnly": false,
      "isRequired": false,
      "isSortable": true,
      "isVirtual": false,
      "reference": null,
      "inverseOf": null,
      "validations": []
    }, {
      "field": "second",
      "type": [{
        "fields": [{
          "field": "field3",
          "type": "String"
        }, {
          "field": "_id",
          "type": "String",
          "isPrimaryKey": true
        }]
      }],
      "defaultValue": null,
      "enums": null,
      "integration": null,
      "isFilterable": true,
      "isPrimaryKey": false,
      "isReadOnly": false,
      "isRequired": false,
      "isSortable": true,
      "isVirtual": false,
      "reference": null,
      "inverseOf": null,
      "validations": []
    }],
    "segments": [],
    "actions": []
  }
  • Package Version: 9.3.2
  • Express Version:
  • Mongoose Version: 7.0.3
  • MongoDB Version: 5.2.0

thongxuan avatar Jul 12 '23 07:07 thongxuan

fyi, I tried using 'fieldsToFlatten' but it's not working.

thongxuan avatar Jul 12 '23 07:07 thongxuan

@Thenkei anyone please? Isn't this a commercial project?

thongxuan avatar Jul 17 '23 02:07 thongxuan