cannercms icon indicating copy to clipboard operation
cannercms copied to clipboard

Firestore relation broken parent

Open cristian-milea opened this issue 5 years ago • 0 comments

Describe the bug Implement self relation categories just like example from cms30-08-ecommerce but with Firestore

To Reproduce Steps to reproduce the behavior:

  1. use (almost) the same categories.schema.js from example
import CannerScript from 'canner-script';

export default () => (
  <array
    keyName="categories"
    ui="tree"
    title="Categories"
    description="Dealing with relationship data is annoying, but in Canner, it\'s just a few tags and properties."
    dataSource={{name: 'firestore'}}
    uiParams={{
      relationField: "parent",
      columns: [
        {
          title: "Category Name",
          dataIndex: "name"
        }
      ]}}>
    <string keyName="name" title="Category Name" required />
    <relation
      keyName="parent"
      ui="singleSelectTree"
      relation={{
        type: "toOne",
        to: "categories"
      }}
      title="Parent Category"
      uiParams={{
        disabled: (data, treeKey) => {
          return treeKey.indexOf("-") !== -1;
        },
        textCol: data => data.name,
        relationField: "parent"
      }}
    >
      <toolbar>
      </toolbar>
    </relation>
  </array>
);
  1. add 1 parent and try adding 2 children to him
  2. check firestore
  3. See error

Expected behavior Both children should be under the parent.

Screenshots Screen Shot 2019-03-29 at 02 57 01 Screen Shot 2019-03-29 at 02 56 52 Screen Shot 2019-03-29 at 02 56 41

Dependencies (please complete the following information):

  • OS: MacOS 10.14.3
  • Browser Chrome 73
  • Node Version v8.15.1
  • Canner Version 3.2.13

Additional context Relationships (especially self ones) mapping is very confusing in documentation. I honestly don't know how to make uni-directional or bi-directional, and how to do a one-to-many relationship

cristian-milea avatar Mar 29 '19 01:03 cristian-milea