nhn / tui.calendar

šŸžšŸ“…A JavaScript calendar that has everything you need.
http://ui.toast.com/tui-calendar
MIT License
12.04k stars 1.3k forks source link

Edit of All day Schedule Events, using default date editor/picker, produces wrong end date #905

Closed knightwing-network closed 3 years ago

knightwing-network commented 3 years ago

Edited and corrected version

Describe the bug

  1. Create an all-day event of any number of days.
  2. Now click on it and then click on Edit (using the default popups)
  3. Edit to be a different end date, with end date > start date
  4. The erroneous result is that the end date is one less than it should be.

Note that if you click Update without changing anything, the end date is correct.

To Reproduce

Steps to reproduce the behavior:

  1. Month View, default popups

    this.calendar = new Calendar('#calendar', {
      defaultView: 'month',
      taskView: true,
      useCreationPopup: true,
      useDetailPopup: true,
      template: {
        monthDayname: function (dayname) {
          return '<span class="calendar-week-dayname-name">' + dayname.label + '</span>';
        }
      }
    });
  2. Click on a date and add an all-day event of 1 day in length: Event Created

  3. Now click on the event so that the detail popup appears: Event details

  4. Click Edit and in new pop up make an event of exactly two days (end = start + 1 day): Event Editing

  5. Click UPDATE and result has the end date = start date Event Result

Expected behavior

It should create an event of two days.

Screenshots

See above

Desktop (please complete the following information):

Additional context

Add any other context about the problem here.

knightwing-network commented 3 years ago

I think the problem can be fixed by handling the returned end date differently in the _onClickSaveSchedule method when we are in this._isEditMode , ie modify form.end inside the if (this._isEditMode) block:

ScheduleCreationPopup.prototype._onClickSaveSchedule = function(target) {
    var className = config.classname('popup-save');
    var cssPrefix = config.cssPrefix;
    var title;
    var startDate;
    var endDate;
    var rangeDate;
    var form;
    var isAllDay;

    if (!domutil.hasClass(target, className) && !domutil.closest(target, '.' + className)) {
        return false;
    }

    title = domutil.get(cssPrefix + 'schedule-title');

    startDate = new TZDate(this.rangePicker.getStartDate());
    endDate = new TZDate(this.rangePicker.getEndDate());

    if (!this._validateForm(title, startDate, endDate)) {
        if (!title.value) {
            title.focus();
        }

        return false;
    }

    isAllDay = !!domutil.get(cssPrefix + 'schedule-allday').checked;
    rangeDate = this._getRangeDate(startDate, endDate, isAllDay);

    form = {
        calendarId: this._selectedCal ? this._selectedCal.id : null,
        title: title,
        location: domutil.get(cssPrefix + 'schedule-location'),
        start: rangeDate.start,
        end: rangeDate.end,
        isAllDay: isAllDay,
        state: domutil.get(cssPrefix + 'schedule-state').innerText,
        isPrivate: !domutil.hasClass(domutil.get(cssPrefix + 'schedule-private'), config.classname('public'))
    };

    if (this._isEditMode) {
        form.end = [modify end here];
        this._onClickUpdateSchedule(form);
    } else {
        this._onClickCreateSchedule(form);
    }

    this.hide();

    return true;
};

I cloned the repo, but I am getting an error when I run npm install

adhrinae commented 3 years ago

@knightwing-network Can you check this example? There might be a chance you pass the wrong arguments to the updateSchedule method. It's not ideal, but it needs calendarId as a second argument.

https://stackblitz.com/edit/tui-calendar-playground-ew9tmr?file=index.js

and What kind of error appears when you try to run npm install? I'm not a Windows user, so It may be a specific issue to Windows + Node(or npm) environment.

knightwing-network commented 3 years ago

Thanks for such a quick response.

I checked on the stackblitz example and the bug is there too.

Here is my npm install issue. Full log attached as well.


$ git clone https://github.com/nhn/tui.calendar.git tui.calendar
Cloning into 'tui.calendar'...
remote: Enumerating objects: 29232, done.
remote: Counting objects: 100% (2920/2920), done.
remote: Compressing objects: 100% (1244/1244), done.
remote: Total 29232 (delta 1617), reused 2354 (delta 1349), pack-reused 26312
Receiving objects: 100% (29232/29232), 55.65 MiB | 24.33 MiB/s, done.
Resolving deltas: 100% (18486/18486), done.

$ cd  tui.calendar

$ npm install
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'karma-cli@1.0.1',
npm WARN EBADENGINE   required: { node: '0.10 || 0.12 || 4 || 5 || 6' },
npm WARN EBADENGINE   current: { node: 'v14.17.4', npm: '7.24.1' }
npm WARN EBADENGINE }
npm WARN deprecated ini@1.3.5: Please update to ini >=1.3.6 to avoid a prototype pollution issue
npm WARN deprecated eslint-loader@2.2.1: This loader has been deprecated. Please use eslint-webpack-plugin
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated circular-json@0.3.3: CircularJSON is in maintenance only, flatted is its successor.
npm WARN deprecated debug@4.1.1: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
npm WARN deprecated debug@4.1.1: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
npm WARN deprecated debug@4.1.1: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
npm WARN deprecated debug@4.1.1: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.0: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated intl-messageformat-parser@6.1.0: We've written a new parser that's 6x faster and is backwards compatible. Please use @formatjs/icu-messageformat-parser
npm WARN tarball tarball data for tui-release-notes@git+ssh://git@github.com/nhn/toast-ui.release-notes.git#8556b1734a587646e7f9193b6246afcf3a101d53 (sha512-uEXY1YezkKNKfd44ZUvhblV1EnTzOgqJUBqf8ZQ3etxoq8Tgt/nndI9zoV0AOgAkX3UP2mSG0/XjtxLJBzCQBg==) seems to be corrupted. Trying again.
npm WARN tarball tarball data for tui-release-notes@git+ssh://git@github.com/nhn/toast-ui.release-notes.git#8556b1734a587646e7f9193b6246afcf3a101d53 (sha512-uEXY1YezkKNKfd44ZUvhblV1EnTzOgqJUBqf8ZQ3etxoq8Tgt/nndI9zoV0AOgAkX3UP2mSG0/XjtxLJBzCQBg==) seems to be corrupted. Trying again.
npm WARN deprecated core-js@2.6.12: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
npm ERR! code EINTEGRITY
npm ERR! sha512-uEXY1YezkKNKfd44ZUvhblV1EnTzOgqJUBqf8ZQ3etxoq8Tgt/nndI9zoV0AOgAkX3UP2mSG0/XjtxLJBzCQBg== integrity checksum failed when using sha512: wanted sha512-uEXY1YezkKNKfd44ZUvhblV1EnTzOgqJUBqf8ZQ3etxoq8Tgt/nndI9zoV0AOgAkX3UP2mSG0/XjtxLJBzCQBg== but got sha512-HiEAWZmqunAwvhZeqJqwoxN4FZERoC+j5EXn+skpTNvL8X2T6On+RndtJjpHh2HQkqA7ew3jvuRSR3YWsQOoQg==. (9079 bytes)

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\rs2015\AppData\Local\npm-cache\_logs\2021-10-01T15_13_01_212Z-debug.log
``
[2021-10-01T15_13_01_212Z-debug.log](https://github.com/nhn/tui.calendar/files/7268260/2021-10-01T15_13_01_212Z-debug.log)
`
knightwing-network commented 3 years ago

I fixed the above error by clearing my npm cach, removing

Now I get a permission error:

npm ERR! C:\Program Files\Git\mingw64\bin\git.EXE ls-remote -h -t ssh://git@github.com/nhn/toast-ui.release-notes.git
npm ERR!
npm ERR! git@github.com: Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
npm ERR!
npm ERR! exited with error code: 128

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\rs2015\AppData\Roaming\npm-cache\_logs\2021-10-01T15_57_58_795Z-debug.log
adhrinae commented 3 years ago

@knightwing-network

Really? I couldn't reproduce the bug when I try to follow your steps. And about the npm error, you need to add your SSH key to your github account to access packages which are directly linked to github. Please refer to this document and try again.

ron2015schmitt commented 3 years ago

Today it was much more difficult to get it to occur, but the following broke it. I was able to reproduce this 4 times in a row. I reloaded the page before each trial.

  1. create all day task on Sunday Oct 10 bug1

  2. Result is correct: bug2

  3. Edit: change start to Oct 27 and end Oct 28. bug3

  4. Result is incorrect: one day event on Oct 27 bug4

adhrinae commented 3 years ago

@ron2015schmitt I confirmed the reproducing steps. I'll fix it soon.

ron2015schmitt commented 3 years ago

Thank you

adhrinae commented 3 years ago

@knightwing-network @ron2015schmitt Please try version 1.15.0 to get things right :)

knightwing-network commented 3 years ago

I tried and it works now. I was not able to cause the bug. Thanks.