frappe / gantt

Open Source Javascript Gantt
https://frappe.io/gantt
MIT License
4.67k stars 1.04k forks source link

Mistake of one day when resizing a task #73

Closed Adioud closed 5 months ago

Adioud commented 6 years ago

Hi, First I would like to thank you for this library, simple and with beautifull.

Using it I just noticed this small issue: resizing a task there is one day mistake between the task as I draw graphycally, and the end date given by the "on_date_change" event. For instance if I draw the task until de 1st january, the "on_date_change" will give task.end YYYY-01-02.

It would be a good thing if you can fix it in a next version, Thank you one more time, Adrien

netchampfaris commented 6 years ago

@Adioud Hey, I am working on this very issue. Will keep you updated.

netchampfaris commented 6 years ago

This should be fixed now. Try replicating on the latest build.

Adioud commented 6 years ago

Hi, Thank you for having taken my issue in account! Unfortunatelly I just tried with the new build but I get lot of errors: when mouse enter the gantt or when I try to change a task: frappe-gantt.js:1546 Uncaught TypeError: Cannot read property '$bar' of undefined frappe-gantt.js:1588 Uncaught TypeError: Cannot read property 'group' of undefined

Previously I get error because the container now has to be a "div" element and not an "svg" element but I have adapted my html.

It's very hard to use the plugin if the sample/documentation is not up to date :( Do I miss another parameter to change with the new build?

Thank for your advice! Adrien

Adioud commented 6 years ago

Hi, Well, the errors were caused by issues on my side (I used integer task id), I didn't notice it before, So, I have cleaned this and it seems that I still have a gap of one day one the start date. Then end date is OK.

sbaiti commented 6 years ago

Hi , Are fixed this bug , @Adioud

Adioud commented 6 years ago

Hello,

As I said on the 1th jun I still have an error on the start date. I see that sbaiti opened another issue for that: @netchampfaris you can close one of this two issues.

Thank,

Anurag810 commented 5 years ago

@netchampfaris Have fixed this

cdoug88 commented 4 years ago

Not sure if this is the same issue or not but... I was having an issue where if I resized the task, the start date was actually off by one day and was saving that way to my DB. It was moving the start date backwards by one day. As a temporary fix until I can figure out how to fix it permanently, I have added the follow javascript:

on_date_change: function(id, start, end) {
    function convert(str) {
        var date = new Date(str),
            mnth = ("0" + (date.getMonth() + 1)).slice(-2),
            day = ("0" + date.getDate()).slice(-2);
        return [date.getFullYear(), mnth, day].join("-");
    }
    var newEnd = convert(end);
    var newStartDate = start.setDate(start.getDate() + 1); // this is adding that day back
    var newStart = convert(newStartDate); // converting the date format to 2020-04-12 for db
    var newId = id.id;

    $.ajax({
        type: "post",
        url: "_partials/update_date",
        data: {
            id: newId,
            newstart: newStart,
            newend: newEnd
        },
    });
}

Hopefully this helps someone

jlxcolo commented 3 years ago

I found out the hard way that id can't be an int, which is kind of crazy... but this thread saved me. BIGINT in postgress gets auto quoted - which resolves the issue.

safwansamsudeen commented 5 months ago

It can now - fixed in #393.