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
53 stars 6 forks source link

RevertChanges method does not clear the changes on CrudManager #9987

Open ghulamghousdev opened 2 weeks ago

ghulamghousdev commented 2 weeks ago

Forum post

Hi team

I am unsure if this is related to my previous post.

On this example https://bryntum.com/products/scheduler/examples/backlog/ with this code, please doubleclick to create a new event Verify that a sync event happens See that there are still changes by window.bryntum.queryAll('scheduler')[0].crudManager.changes

Needless to say that this breaks quite a few things. I did not notice this behaviour on 6.0.2.

Calling scheduler.crudManager.acceptChanges() works but not scheduler.crudManager.revertChanges()

import {AjaxHelper, Scheduler} from '../../build/scheduler.module.js?479193';
import shared from '../_shared/shared.module.js?479193';

AjaxHelper.mockUrl('sync-mock-url', (url, urlParams, {queryParams}) => {
    const payload = {
        requestId: (new Date()).getTime(),
        success: true,
        type: 'sync',
    }
    if (generatedId !== null) {
        payload['events'] = {
            rows: [
                {
                    id: (new Date()).getTime(),
                    '$PhantomId': generatedId,
                    startDate: "2023-02-03",
                    duration: 5,
                    name: "New event",
                    description: "New event",
                    percentDone: 10,
                    eventColor: "indigo",
                    resourceId: "r1",
                }
            ]
        }
        generatedId = null
    }
    return {
        delay: 100,
        responseText: JSON.stringify(payload)
    }
});

let generatedId = null;

new Scheduler({
    appendTo: 'container',
    startDate: new Date(2023, 0, 29),
    endDate: new Date(2023, 1, 12),
    viewPreset: 'weekAndDayLetter',
    crudManager: {
        forceSync: true,
        autoSync: true,
        autoLoad: true,
        eventStore: {
            fields: [
                'description',
                {name: 'percentDone', type: 'number', defaultValue: 0}
            ]
        },
        resourceStore: {
            fields: [
                'city'
            ]
        },
        transport: {
            load: {
                url: 'data/data.json',
                method: 'GET',
            },
            sync: {
                url: 'sync-mock-url',
                method: 'GET',
            },
        },
    },

columns: [
    {field: 'name', text: 'Name', width: 150},
    {field: 'city', text: 'City', width: 150}
],

listeners: {
    beforeEventEdit({eventRecord}) {
        if (eventRecord.hasGeneratedId) {
            generatedId = eventRecord.id
            eventRecord.set({
                "startDate": "2023-02-03",
                "duration": 5,
                "name": "New event",
                "description": "New event",
                "percentDone": 10,
                "eventColor": "indigo",
                "resourceId": "r1",
                isCreating: false,
            })
        }
        return false;
    },
}
});

Might be related to this: https://github.com/bryntum/support/issues/9983

chuckn0rris commented 2 weeks ago

realated to /issues/9992