bryntum / support

An issues-only repository for the Bryntum project management component suite which includes powerful Grid, Scheduler, Calendar, Kanban Task Board and Gantt chart components all built in pure JS / CSS / TypeScript
https://www.bryntum.com
54 stars 6 forks source link

applyChangeset leaves orphaned records when filters are applied #10345

Open marciogurka opened 1 day ago

marciogurka commented 1 day ago

Forum post

"We are seeing an expected result in the resourceStore after removing resources with applyChangeset: if resources are currently not displayed due to filters in effect, applyChangeset causes their isRemoved flag to be true and their store reference to be null, but they remain in the resourceStore.allRecords collection. Is this a bug?

To reproduce, open the source editor on the Scheduler "Tree" example: https://bryntum.com/products/scheduler/examples/tree/

then add a toolbar with this content:

    tbar : [
    {
        text : 'Set Filter',
        onClick() {
            scheduler.project.resourceStore.filter({
                id: 'test', filterBy: (x) => (x.name == 'Terminal B')
            });
        }
    },
    {
        text : 'Remove Terminal A',
        onClick() {
            const terminalA = scheduler.project.resourceStore.allRecords.find(
                (x) => (x.name == 'Terminal A')
            );
            scheduler.project.resourceStore.applyChangeset({
                removed: [ {id: terminalA.id} ]
            });
            console.log('changes', scheduler.project.resourceStore.changes);
            console.log('isRemoved', scheduler.project.resourceStore.allRecords.filter((x) => x.isRemoved))
        }
    },
    {
        text : 'Remove Filter',
        onClick() {
            console.log('before remove filter', scheduler.project.resourceStore.allRecords.filter((x) => x.isRemoved))
            scheduler.project.resourceStore.removeFilter('test');
            console.log('after remove filter', scheduler.project.resourceStore.allRecords.filter((x) => x.isRemoved))
        }
    }    
]
"

Then open the developer tools console and proceed by clicking the new toolbar buttons in order: [Set Filter] then [Remove Terminal A] and note the console output for "isRemoved".