Our pure JavaScript Scheduler component


Post by SIM-LTD »

Hi,

We have an issue with the time resolution (object) that is not updated accordingly when changing Preset view.

You can run a test in the online Confi Demo (https://www.bryntum.com/examples/scheduler/configuration/)
Once in it just add these code line where the Widget Combo is registered (look at the screenshot)
onChange : ({ value }) => {
 ........
 console.log('Preset selected..', scheduler.timeResolution.increment, scheduler.timeResolution.unit);
        }
The issue is the preset "Days" has a wrong Time Resolution is, after a zoom level update.

At first the time resolution of the "Days" preset is :
  • scheduler.timeResolution.increment = 1
    scheduler.timeResolution.unit = day
which is (for us) good.

Then when you play around with either the Zoom In/Out and then switching with other preset and you come back to the Preset "Days" then the Time resolution is wrong :
  • scheduler.timeResolution.increment = 1
    scheduler.timeResolution.unit = hour
No matter if you select another preset and come back to "Days" the resolution remains always (1/hour) instead of being (1 / day)

Our issue is we using both "scheduler.timeResolution.increment" and "scheduler.timeResolution.unit" to find the EndDate when Dropping an Item into the Scheduler :
dateStarts = me.schedule.getDateFromCoordinate(DomHelper.getTranslateX(context.element), 'round', false);
dateEnds   = DateHelper.add(dateStarts, me.schedule.timeResolution.increment, me.schedule.timeResolution.unit)
Has you can understand, sometime when we have "Days" preset the timeResolution is set with (1/Day) and when Zoom level has changed and coming back to "Days" preset the timeResolution is set with (1/hour); that cause some trouble when it comes to creating a task that is supposed to be 1 day duration and not 1 hour.
Attachments
Capture d’écran 2019-10-15 à 19.59.48.png
Capture d’écran 2019-10-15 à 19.59.48.png (238.28 KiB) Viewed 1830 times
Capture d’écran 2019-10-15 à 20.00.11.png
Capture d’écran 2019-10-15 à 20.00.11.png (237.5 KiB) Viewed 1830 times

Post by Maxim Gorkovsky »

Hello.
I can see the problem, yes. We are refactoring zooming feature now and in the future versions this problem shouldn't be reproducible. See related ticket: https://app.assembla.com/spaces/bryntum/tickets/9325-make-a-store-of-presetmanager-to-handle-view-presets-and-zooming/details

As a workaround please try this override:
class PresetOverride {
    static get target() {
        return {
            class : ViewPreset
        };
    }
    
    clone() {
        return new ViewPreset(ObjectHelper.clone(this.config));
    }
}
Override.apply(PresetOverride);
Apply it somewhere globally, before you instantiate scheduler.

Post by SIM-LTD »

Hi

Thank you, we'll see how to implement this workaround, and let you know

Post by SIM-LTD »

Hi

Sorry to tell you but the issue is still there in the last release 2.3.0
Moreover, the workaround proposed is not efficient.

As the unit is wrong, could you tell us how to change the "unit" inside the timeResolution property, on a fly (programmatically)
This, could be a workaround; but we cannot figure out how to update (override) that unit, after the ZoomIn / ZoomOut.
We tried
scheduler.timeResolution = { unit: 'day', increment:1}
, but this got no effect...

Thank you

Post by sergey.maltsev »

Hi!

Predefined presets have timeResolution settings so you should be able to check this with them.

You could try this code also in this Demo
https://www.bryntum.com/examples/scheduler/configuration/
[
    { unit : 'minute', increment : 30 },
    { unit : 'hour', increment : 2 },
    { unit : 'day', increment : 1 }
].map(timeResolution => {
    const myPreset = Object.assign(PresetManager.getPreset('dayNightShift').config, { timeResolution });
    const preset = `custom${timeResolution.increment}${timeResolution.unit}`;
    PresetManager.registerPreset(preset, myPreset);
    presets.add({ name : `Custom preset : ${timeResolution.increment} ${timeResolution.unit}`, preset });
});
And check the output when switching between created custom presets. It should should be like
Preset selected.. 30 minute
Preset selected.. 2 hour
Preset selected.. 1 day

Post by SIM-LTD »

Hi,

I'm afraid you did not understand the issue.

Just to make it short and clear (do not want to repeat all scenery posted Oct 16 (see above)

Test this case :

1) Got to this online demo https://www.bryntum.com/examples/scheduler/configuration/
2) Select the preset "Day"
3) Adjust any task to be ONE FULL DAY (StartDate: 12AM / EndDate:12AM)
4) Then drag it: You'll see the time resolution is "1 day" (OK)
5) Select the preset "Week" and the go back and select the preset "Day" : You'll see the time resolution is "1 day" (OK)
You can double click onto the Scheduler in order to create a new task; the new added task is one Day (FULL DAY 12AM-12AM)
6) NOW (issue) Click ZoomOut then Click ZoomIn, so as to get back to "Day" preset.
Then, Drag the Task: You'll see the timeResolution is "1 hour" (WHY???)
You can double click onto the Scheduler in order to create a new task; the new added task is having the time....

When the preset is Day, the time-resolution is "Day"; the issue is once clicking in ZoomOut / ZoomIn, and the preset is getting back to ""Day" the time Resolution is "hour" instead of being "Day" as it was suppoed to be as the preset is "Day"?

So when we Drag any task on the scheduler, with the preset "Day' instead of having Time -Resolution Day, we have the time-resolution "hour"
which is an issue because the user can drop the task not at 12AM-12AM but 01AM-01AM or whatever. (which is 2 day) and not anymore 1 day.

Hence as this is an issue, we just wanted to know if you can fix it or if you have a workaround.
We thought that we could force (update) the time-resolution, when the preset is "Day" after having clicked on ZoomOut then ZoomIn,
But the code below does not change the TimeResilution at all, on the fly :
scheduler.timeResolution = { unit: 'day', increment:1}

Any suggestion?

Post Reply