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

getTreeFromFlatData prevent children to be overriden in trav function #810

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pinkbunny1
Copy link

@pinkbunny1 pinkbunny1 commented Oct 7, 2020

getTreeFromFlatData() the children property when the root parent has children where one of them can be subParent. for example where folder has many reports and subFolder which has its own reports.

When flat list item parentId refers to id of another item in the flat list but it also has children property and value of its own, it should be added to the children list instead of overriding it.

When running this data with getTreeFromFlatData(), you can see that object with id 7, its children is replaced with id 8 which has parentId as 7. But it should be that the children of id 7 should have its original children value intact and add the object id 8 into its children's list.

[
   {
      "children": [
         {
            "id": 2,
            "name": "Active pr-locs",
            "folderId": 4
         },
         {
            "id": 11,
            "name": "MRP,CO-MRP,K-TP not in assortment",
            "folderId": 4
         }
      ],
      "id": 4,
      "parentId": 0
   },
   {
      "children": [
         {
            "id": 17,
            "name": "search criteria",
            "folderId": 6
         },
         {
            "id": 19,
            "name": "dashboard2 drill2d and view",
            "folderId": 6
         },
      ],
      "id": 6,
      "parentId": 0
   },
   {
      "children": [
         {
            "id": 35,
            "name": "New view",
            "folderId": 7
         },
         {
            "id": 39,
            "name": "New view",
            "folderId": 7
         }
      ],
      "id": 7,
      "parentId": 0
   },
   {
      "children": [
         {
            "id": 38,
            "name": "New view",
            "folderId": 8
         }
      ],
      "id": 8,
      "parentId": 7
   }
]

@nahuelleiva
Copy link

Hi, @pinkbunny1
Is this related to the sorting not being correctly rendered using the getTreeFromFlatData function?
I have the issue where moving nodes at the same level are not correctly sorted after you refreshed the browser, take this as an example, you have the following tree:

-- parent
    |__ children_1
    |__ children_2

and let's say you move children_2 from its position, like this:

-- parent
    |__ children_2
    |__ children_1

after moving the node, I'm able to update the node in the DB, but once I refresh the browser the tree is reverted back as it originally was, like this:

-- parent
    |__ children_1
    |__ children_2

To load the tree I'm using the getTreeFromFlatData to transform the DB data into tree data.
I cannot get this working. Doesn't matter what I do, the sorting is never saved in the database.

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

Successfully merging this pull request may close these issues.

None yet

2 participants