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

Creating event causing the auto zoom in timeline when no start date set to the scheduler #8979

Closed marciogurka closed 4 months ago

marciogurka commented 5 months ago

Forum post

"Since scheduler 5.6.7 the Scheduler Pro zooms into a week where the first event is created. This was not the case in 5.6.6. This new behavior is not documented in 5.6.7 change log, is this expected? How can I prevent it?

GIF and code attached 5_6_7_autozoom.gif"

package.zip

Running the project (both backend and frontend at the same time) and creating a new event from zero will trigger the behavior that is presented in the GIF.

Regarding this case, if you set a start date for the scheduler, like this

<bryntum-scheduler-pro ref="scheduler" v-bind="schedulerConfig" :listeners="bryntumListeners" :stripe-feature="true"
        :dependencies-feature="false" :startDate="'2024-04-07'"></bryntum-scheduler-pro>

The behavior won't happen, it only occurs when there are no events created, and no start date set to the scheduler.

marciogurka commented 5 months ago

Pure JS test case (needs to run with the backend):

export class MyEventModel extends EventModel {
    static get fields() {
        return [
            { name : 'modifiedAt', type : 'date', defaultValue : new Date() }
        ];
    }

    getModifiedAt() {
        return this.get('modifiedAt');
    }

    setModifiedAt(value) {
        this.set('modifiedAt', value);
    }
}

const scheduler = new SchedulerPro({
    appendTo : 'container',
    columns  : [
        { text : 'Name', field : 'name', width : 130 }
    ],
    eventStore : {
        autoLoad          : true,
        autoCommit        : true,
        readUrl           : 'http://localhost:5031/bryntum/event',
        createUrl         : 'http://localhost:5031/bryntum/event',
        updateUrl         : 'http://localhost:5031/bryntum/event',
        deleteUrl         : 'http://localhost:5031/bryntum/event',
        useRestfulMethods : true,
        singleAssignment  : true,
        //writeAllFields: true,
        modelClass        : MyEventModel
    },
    resourceStore : {
        autoLoad : true,
        readUrl  : 'http://localhost:5031/bryntum/resource'
    },
    listeners : {
        beforeEventEdit : (data) => {
            console.log(`createEvent`, data);
            const er = data.eventRecord;
            er.isCreating = false;
            er.set({ name : 'Created' });
            return false;
        }
    }
});