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

Relational fields are broken in advanced settings and cannot be updated #9182

Closed
3 tasks done
Oreilles opened this issue Oct 27, 2021 · 4 comments · Fixed by #9324
Closed
3 tasks done

Relational fields are broken in advanced settings and cannot be updated #9182

Oreilles opened this issue Oct 27, 2021 · 4 comments · Fixed by #9324
Assignees
Labels
Milestone

Comments

@Oreilles
Copy link
Contributor

Oreilles commented Oct 27, 2021

Preflight Checklist

Describe the Bug

When creating a relational field on a collection, we can edit the display template in the new field flow - but when we try to change it again from the data-model route (with the drawer), the display template indicates "Please select a collection" (even though the relation is already configured).

EDIT: The relation is actually misconfigured is the whole field drawer, and it happens the moment you open it. If you open the advanced setting of a relational field, close the drawer, go to the collection owning that field and try to set its value, the app will crash with

Uncaught (in promise) TypeError: _ctx.relatedCollection is null
    _sfc_render select-dropdown-m2o.vue:72
    renderComponentRoot runtime-core.esm-bundler.js:444
    componentUpdateFn runtime-core.esm-bundler.js:4211
    run reactivity.esm-bundler.js:160
    setupRenderEffect runtime-core.esm-bundler.js:4337
    mountComponent runtime-core.esm-bundler.js:4120
    processComponent runtime-core.esm-bundler.js:4078
    patch runtime-core.esm-bundler.js:3673
    mountChildren runtime-core.esm-bundler.js:3869
select-dropdown-m2o.vue:72:4

To Reproduce

  • Create a relational field
  • Go to that field data-model settings and try to change the display template

Errors Shown

Capture d’écran 2021-10-27 à 09 58 41

Other example:

Capture d’écran 2021-10-27 à 09 58 41

What version of Directus are you using?

rc.99

What version of Node.js are you using?

16

What database are you using?

MySQL

What browser are you using?

Firefox

What operating system are you using?

macOS

How are you deploying Directus?

local

@Oreilles
Copy link
Contributor Author

Here is what the relations object looks like when passed to the list-m2m interface options:

{
  "m2o": {
    "meta": {
      "one_field": null,
      "sort_field": null,
      "one_deselect_action": "nullify"
    },
    "schema": {
      "on_delete": "SET NULL"
    }
  },
  "o2m": {
    "related_collection": "foo",
    "schema": {
      "table": "foo_baz",
      "column": "foo_id",
      "foreign_key_table": "foo",
      "foreign_key_column": "id",
      "foreign_key_schema": "public",
      "constraint_name": "foo_baz_foo_id_foreign",
      "on_update": "NO ACTION",
      "on_delete": "SET NULL"
    },
    "meta": {
      "id": 15,
      "many_collection": "foo_baz",
      "many_field": "foo_id",
      "one_collection": "foo",
      "one_field": "baz",
      "one_collection_field": null,
      "one_allowed_collections": null,
      "sort_field": null,
      "one_deselect_action": "nullify"
    }
  }
}

Here's what it looks like when passed to the files interface options:

{
  "m2o": {
    "collection": "foo_files_1",
    "field": "directus_files_id",
    "related_collection": "directus_files",
    "meta": {
      "one_field": null,
      "sort_field": null,
      "one_deselect_action": "nullify",
      "junction_field": "foo_id"
    },
    "schema": {
      "on_delete": "SET NULL"
    }
  },
  "o2m": {
    "collection": "foo_files_1",
    "field": "foo_id",
    "related_collection": "foo",
    "schema": {
      "table": "foo_files",
      "column": "foo_id",
      "foreign_key_table": "foo",
      "foreign_key_column": "id",
      "foreign_key_schema": "public",
      "constraint_name": "foo_files_foo_id_foreign",
      "on_update": "NO ACTION",
      "on_delete": "SET NULL"
    },
    "meta": {
      "id": 7,
      "many_collection": "foo_files",
      "many_field": "foo_id",
      "one_collection": "foo",
      "one_field": "files",
      "one_collection_field": null,
      "one_allowed_collections": null,
      "junction_field": "directus_files_id",
      "sort_field": null,
      "one_deselect_action": "nullify"
    }
  }
}

In list-m2m options, relations.m2o.related_collection is not defined. In files options, it is. 🤔

@Oreilles Oreilles changed the title Collection prop is undefined in relational fields interface options Relations are misconfigured in advanced field settings drawer Oct 27, 2021
@Oreilles Oreilles changed the title Relations are misconfigured in advanced field settings drawer Opening the advanced field settings drawer break relations Oct 27, 2021
@rijkvanzanten
Copy link
Member

@Oreilles Looks like o2m and m2o might be flipped 🤔

@Oreilles
Copy link
Contributor Author

Have there been changes in the new field flow commits that could have done that ? 🤔

@rijkvanzanten
Copy link
Member

Oh yes absolutely. This split between o2m and m2o wasn't there before at all 🙂

@Oreilles Oreilles changed the title Opening the advanced field settings drawer break relations Relational fields are broken in advanced settings and cannot be updated Oct 30, 2021
@rijkvanzanten rijkvanzanten added this to the v9.0.0-rc.101 milestone Nov 1, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants