Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forest Admin UI incorrectly display nested field #1044

Open
thongxuan opened this issue Jul 12, 2023 · 2 comments
Open

Forest Admin UI incorrectly display nested field #1044

thongxuan opened this issue Jul 12, 2023 · 2 comments

Comments

@thongxuan
Copy link

thongxuan commented Jul 12, 2023

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
Copy link
Author

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

@thongxuan
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant