Our pure JavaScript Scheduler component


Post by Riki4321 »

Hi there,

a bug found in the Tasks demo.
Some parent resources can contain no children, and in this case they are rendered as a "child" resource.

Steps to reproduce:

1. Go to the Tasks example https://www.bryntum.com/examples/scheduler/tasks/
2. In Chrome console, add a new record to resourceStore with empty "clients" property:
newRecord = {
    "id"      : 100,
    "name"    : "TEST",
    "title"   : "TEST",
    "expanded": true,
    "clients" : []
}
scheduler.resourceStore.add(newRecord);
Actual result: "TEST" resource is presented as a child resource

3. Add another record which has children metadata:
newRecord = {
    "id"      : 200,
    "name"    : "TEST2",
    "title"   : "TEST2",
    "expanded": true,
    "clients" : [{"id": 2001, "name": "child of TEST2", "color": "teal"}]
}

scheduler.resourceStore.add(newRecord);
Actual result: "TEST2" added correctly - all good.

4. Add a new event to the "TEST2" resource
5. Try to collapse/expand the new "TEST2" resource

Actual result: child resources for TEST2 are not shown.
Expected result: child resources are shown after the parent resource is expanded.

6. After "#5" is acknowledged, try to collapse/expand any of the initial parent resources.

Actual result: child resources for TEST2 become visible.


I can share a screencast in case #5-6 are not reproduced by the team.

Tasks demo 2019-07-12 12-38-35.png
Tasks demo 2019-07-12 12-38-35.png (239.85 KiB) Viewed 2387 times

Post by mats »

You should use appendChild, but it still looks broken to me. Ticket opened: https://app.assembla.com/spaces/bryntum/tickets/8923-child-nodes-not-shown-for-newly-added-resource-in-a-tree/details#
store.rootNode.appendChild(record);

Post by Riki4321 »

mats wrote: Sat Jul 13, 2019 11:31 am You should use appendChild, but it still looks broken to me. Ticket opened: https://app.assembla.com/spaces/bryntum/tickets/8923-child-nodes-not-shown-for-newly-added-resource-in-a-tree/details#
store.rootNode.appendChild(record);
I believe the problem is with how the tree is parsed and the detection of parent/leaf node.

It seems that "children" (Model.childrenField) property of the rootNode is not correctly processed while parsing the data source.

For example, I was able to get children for the 1st node from the example data source, but got "undefined" for the node added by me via console
scheduler.resourceStore.getById(1)['children']
>> (3) [_0x47cbc5, _0x47cbc5, _0x47cbc5]
scheduler.resourceStore.getById(100)['children']
>> undefined
Also, when you try to do a bit hack and set "children" to empty array, and then collapse/expand any of existing root nodes, the "TEST" node will be converted from leaf to parent.
scheduler.resourceStore.getById(100)['children'] = []
The screencast with all the described above can be found here: https://monosnap.com/file/3q1HRvLDBeM59rYAISvVgZs0sQENcT


I also tried to configure convertEmptyParentToLeaf property of the ResourceModel but had no luck
https://bryntum.com/docs/scheduler/#Common/data/Model#property-convertEmptyParentToLeaf-static

Post by Animal »

Seems to all work as expected.

Step 1:
test2 = scheduler.resourceStore.rootNode.appendChild({
    "id"      : 200,
    "name"    : "TEST2",
    "title"   : "TEST2",
    "expanded": true,
    "clients" : [{"id": 2001, "name": "child of TEST2", "color": "teal"}]
});
You get a new resource called TEST2 with a child.

Now you want to append another child to that resource, so
test2c2 = test2.appendChild({
    "name"    : "2nd child of TEST2",
    "title"   : "2nd child of TEST2"
});
And there it is, all working.
Screenshot 2019-07-22 at 14.11.01.png
Screenshot 2019-07-22 at 14.11.01.png (31.97 KiB) Viewed 2340 times
Am I missing a step?

Post by Riki4321 »

Animal wrote: Mon Jul 22, 2019 2:11 pm Am I missing a step?
Yes, please try to add a child to rootNode with empty "clients" property, it will be rendered as a "child" row.
test2 = scheduler.resourceStore.rootNode.appendChild({
    "id"      : 200,
    "name"    : "TEST2",
    "title"   : "TEST2",
    "expanded": true,
    "clients" : []
});

Tasks demo 2019-07-23 11-34-33.png
Tasks demo 2019-07-23 11-34-33.png (259.56 KiB) Viewed 2334 times

Post by Riki4321 »

mats wrote: Sat Jul 13, 2019 11:31 am You should use appendChild, but it still looks broken to me. Ticket opened: https://app.assembla.com/spaces/bryntum/tickets/8923-child-nodes-not-shown-for-newly-added-resource-in-a-tree/details#
store.rootNode.appendChild(record);
The bug is marked as fixed in 2.2.1 but it is not.
Steps #1 - #4 are reproduced on the same Tasks demo page.

Steps #5-6 fixed though.

Post by mats »

If you mean that a record with empty 'children' property is rendered as a leaf, this is by design. You can control this behavior with the https://www.bryntum.com/docs/scheduler/#Common/data/Model#property-convertEmptyParentToLeaf-static flag of your own Model class.

Post by Riki4321 »

mats wrote: Sun Jul 28, 2019 8:51 am If you mean that a record with empty 'children' property is rendered as a leaf, this is by design. You can control this behavior with the https://www.bryntum.com/docs/scheduler/#Common/data/Model#property-convertEmptyParentToLeaf-static flag of your own Model class.
Tried to set this property to false but had no luck.

In my code, I added the following line which was not working.
    bryntum.scheduler.ResourceModel.childrenField = 'projects'
    bryntum.scheduler.ResourceModel.convertEmptyParentToLeaf = false
In the "Tasks" example, I tried to set the following setting from Chrome console, and add a node afterward, and also no success.
scheduler.resourceStore.modelClass.convertEmptyParentToLeaf = false

Please suggest if I set the property correct or no.

Thanks.

Post by pmiklashevich »

Pavlo Miklashevych
Sr. Frontend Developer


Post by Riki4321 »

pmiklashevich wrote: Mon Jul 29, 2019 12:31 pm That's a bug in our sources. Thanks for the report! Ticket here: https://app.assembla.com/spaces/bryntum/tickets/8973-convertemptyparenttoleaf-flag-doesn--39-t-work/details
Thanks!
Waiting for the fix.

Post Reply