ANovokmet / svelte-gantt

:calendar: Interactive JavaScript Gantt chart/resource booking component
https://anovokmet.github.io/svelte-gantt/
MIT License
529 stars 107 forks source link

Drag and Drop Issue #45

Closed nitish-darji closed 1 year ago

nitish-darji commented 2 years ago

Hello

I'm working on Angular@12 and svelte-gantt@4.0.1-beta

I face one issue when drag and drop new task, when week view selected and drop new task at last week day then new task not plot exact drop time (position) instead plot few hours early.

also plot working fine starting week days, when you drop new task incremental day then it plot few hours ago and increase plot hours.

please check below example

https://stackblitz.com/edit/angular-ivy-sm719e

Thanks in advance

ANovokmet commented 2 years ago

I face one issue when drag and drop new task, when week view selected and drop new task at last week day then new task not plot exact drop time (position) instead plot few hours early.

I can verify there is a bug here, thanks for reporting.

also plot working fine starting week days, when you drop new task incremental day then it plot few hours ago and increase plot hours.

Can you elaborate more? What do you mean by incremental day and plot here? Increase plot hours? Does the gantt date range get changed?

nitish-darji commented 2 years ago

thanks @ANovokmet for quick reply

when week view selected and you drop new task week first day (SUN) then it looks drop and plot time all most same when drop new task week second day (Mon) then drop and plot time differ, when drop new task next day and continue the time different between drop and plot increase.

Thanks

ANovokmet commented 2 years ago

This should be fixed with version 4.0.2-beta now on npm

nitish-darji commented 2 years ago

thanks @ANovokmet

I'm working on Angular@12 and upgrade svelte-gantt@4.0.2-beta

one issue generated when build angular project then below error occur

image

node_modules/svelte-gantt/types/modules/table/tableHeader.ts file need to replace import from "src/core/row" with "../../core/row"

thanks again @ANovokmet

nitish-darji commented 2 years ago

Also, when upgrade svelte-gantt@4.0.2-beta version, there is one issue found as below

when day or week view selected at that time hour header not start with 0

image

before upgrade svelte-gantt@4.0.2-beta version it's look as below image image

look into into example https://anovokmet.github.io/svelte-gantt/tree

image

Thanks

ANovokmet commented 2 years ago

Also, when upgrade svelte-gantt@4.0.2-beta version, there is one issue found as below

when day or week view selected at that time hour header not start with 0

image

before upgrade svelte-gantt@4.0.2-beta version it's look as below image image

look into into example https://anovokmet.github.io/svelte-gantt/tree

image

Thanks

Thanks for noticing the issue. I'll try to fix it.

ANovokmet commented 2 years ago

Issues fixed in 4.0.3-beta. Thanks.

nitish-darji commented 2 years ago

Thanks @ANovokmet

after upgrade svelte-gantt@4.0.3-beta version

Drag and Drop Issue Resolve Build Issue Resolve But below issue not resolve

when day or week view selected at that time hour header not start with 0

image

before upgrade svelte-gantt@4.0.3-beta version it's look as below image image

look into into example https://anovokmet.github.io/svelte-gantt/tree

image

only header hours display wrong, it show based on time zone. I use moment. dateAdapter: new MomentSvelteGanttDateAdapter(moment),

Thanks again @ANovokmet

ANovokmet commented 2 years ago

Which time zone are you in?

nitish-darji commented 2 years ago

IST (India Standard Time)

ANovokmet commented 2 years ago

Thanks, there are some issues with timezones since dropping moment. Will have to take them into account when calculating the hours.

nitish-darji commented 2 years ago

Hello @ANovokmet

Any update regarding time zones issue,

Thanks

ANovokmet commented 2 years ago

@nitish-darji sorry, working on it now

kevinleto-informaticon commented 1 year ago

I've experienced this issue on the new versions v4.0.7-beta/v4.0.9-beta. Is there any update? Thanks in advance!

labs20 commented 1 year ago

Please, having the same issue here. Any workarouds?

V-Py commented 1 year ago

Can you describe your problem in details ? And which timezone ? Thanks

labs20 commented 1 year ago

Hi. Thanks for your attention.

Timezone -3 (pt-BR)

In the example below, I've dragged a task that was set on the gant beggining at 2022-10-17 and ending at 2022-10-19.

I have:

                    columnUnit: 'day',
                    columnOffset: 1,
                    magnetUnit: 'day',
                    magnetOffset: 1,
                   ...

So at the gantt, the task seems to start at 00:00hs of 2022-10-17 until 23:59 of 2022-10-19.

But as I drag it one day back, to 2022-10-16, this is what I got:

this.gantt.api.tasks.on.changed(async ([ev]) => {

                // ev.task.model=> from: 1665964800000, to: 1666224000000
                // Cast do date:
                //  new Date(ev.task.model.from).toISOString()    => '2022-10-17T00:00:00.000Z'
                //  new Date(ev.task.model.from).toDateString()  => 'Sun Oct 16 2022' (timestamp here is '21:00:00 GMT-0300'
                // I've lost the timezone here

                // And look whats happening with model.to
                // Cast do date:
                //  new Date(ev.task.model.to).toISOString()    => '2022-10-20T00:00:00.000Z'
                //  new Date(ev.task.model.from).toDateString()  => 'Wed Oct 19 2022' (timestamp here is '21:00:00 GMT-0300'

                if (ev) {
                    let i = new Date(ev.task.model.from)
                        , f =new Date(ev.task.model.to)
                    ;

                    // Have to force things here
                    i.setHours(0, 0, 0);
                    f.setHours(23, 23, 59);
                    f.setDate(f.getDate() - 1);

                    this.data_to_server = {
                        id      : ev.task.model.id,
                        inicio  : i.toISOString(),
                        fim     : f.toISOString(),
                        to_id   : ev.sourceRow.model.id !== ev.targetRow.model.id ? ev.targetRow.model.id : undefined
                    };

                    this.touched = true;
                    this.force_event = true;
                    await this.checkCompEvents();
                    this.rodou_comp_event = false;
                }
            });

Hope the details help.

labs20 commented 1 year ago

My gantt config:

this.gantt = new SvelteGantt({
                target: this.$refs.gantt.$el,
                props: {
                    dateAdapter: new MomentSvelteGanttDateAdapter(moment),
                    from: this.inicio,
                    to: this.final,

                    rows: rows,
                    tasks: tasks,
                    dependences: dependences,
                    timeRanges: ranges,

                    reflectOnParentRows: false,
                    reflectOnChildRows: false,

                    highlightWeekends: false,

                    zoomLevels: [],

                    columnUnit: 'day',
                    columnOffset: 1,

                    magnetUnit: 'day',
                    magnetOffset: 1,

                    rowHeight: 28,
                    rowPadding: 2,

                    fitWidth: true,
                    minWidth: 2000,

                    tableWidth: this.header_width,
                    tableHeaders: headers,
                    headers: [{ unit: 'day', format: 'MMMM YYYY', offset: 7 }, { unit: 'day', format: ' DD ddd' }],

                    ganttTableModules: [SvelteGanttTable],
                    ganttBodyModules: [SvelteGanttDependencies]
                }
            });
ANovokmet commented 1 year ago

@labs20 Thank you, seems the tasks are rounded to the UTC date, instead of the local one. I am using your exact configuration, and when droppings tasks they last from 02:00-02:00 instead of 00:00-00:00. I issued a fix when using moment. It will need fixing for when using the default adapter, possibly leveraging Date.prototype.getTimezoneOffset.