Skip to content

Commit

Permalink
fix: modify to pass the calendar ID (originCalendarId) of the schedul…
Browse files Browse the repository at this point in the history
…e before the change to find the schedule in the schedule collection.(If you don't use the default popup UI, cid doesn't exist.)
  • Loading branch information
jungeun-cho committed Nov 1, 2019
1 parent 07da5c1 commit c2405b7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
3 changes: 2 additions & 1 deletion examples/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
console.log('beforeUpdateSchedule', e);
e.schedule.start = e.start;
e.schedule.end = e.end;
cal.updateSchedule(e.schedule.id, e.schedule.calendarId, e.schedule);
cal.updateSchedule(e.schedule.id, e.originCalendarId, e.schedule);
refreshScheduleVisibility();
},
'beforeDeleteSchedule': function(e) {
console.log('beforeDeleteSchedule', e);
Expand Down
11 changes: 6 additions & 5 deletions src/js/controller/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,16 @@ Base.prototype.updateSchedule = function(schedule, options) {
var end = options.end || schedule.end;

options = options || {};
if (!util.isUndefined(options.isAllDay)) {
schedule.set('isAllDay', options.isAllDay);
}

if (options.category && options.category === 'allday') {
schedule.set('isAllDay', true);
options.isAllDay = true;
}

if (!util.isUndefined(options.isAllDay)) {
schedule.set('isAllDay', options.isAllDay);
}

if (options.calendarId !== schedule.calendarId) {
if (options.calendarId && options.calendarId !== schedule.calendarId) {
schedule.set('calendarId', options.calendarId);
}

Expand Down
17 changes: 12 additions & 5 deletions src/js/factory/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -780,15 +780,20 @@ Calendar.prototype.getSchedule = function(scheduleId, calendarId) {
/**
* Update the schedule
* @param {string} scheduleId - ID of a schedule to update
* @param {string} calendarId - The calendarId of the schedule to update
* @param {string} calendarId - The calendarId of the schedule before change
* @param {Schedule} scheduleData - The {@link Schedule} data to update
* @param {boolean} [silent=false] - No auto render after creation when set true
* @example
*
* // When you use a drag and drop to move a schedule
* // Or when using the default popup UI
* calendar.on('beforeUpdateSchedule', function(event) {
* var schedule = event.schedule;
* var startTime = event.start;
* var endTime = event.end;
* calendar.updateSchedule(schedule.id, schedule.calendarId, {
* var originCalendarId = event.originCalendarId;
*
* calendar.updateSchedule(schedule.id, originCalendarId, {
* start: startTime,
* end: endTime
* });
Expand All @@ -798,12 +803,14 @@ Calendar.prototype.updateSchedule = function(scheduleId, calendarId, scheduleDat
var ctrl = this._controller,
ownSchedules = ctrl.schedules,
schedule = ownSchedules.single(function(model) {
return model.__fe_id === (scheduleData.__fe_id || scheduleData._feId);
return model.id === scheduleId && model.calendarId === calendarId;
});
var hasChangedCalendar = schedule && schedule.calendarId !== calendarId;
var hasChangedCalendar = schedule &&
scheduleData.calendarId &&
schedule.calendarId !== scheduleData.calendarId;

scheduleData = hasChangedCalendar ?
this._setScheduleColor(calendarId, scheduleData) :
this._setScheduleColor(scheduleData.calendarId, scheduleData) :
scheduleData;

if (schedule) {
Expand Down
4 changes: 2 additions & 2 deletions src/js/view/popup/scheduleCreationPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,12 @@ ScheduleCreationPopup.prototype._onClickSaveSchedule = function(target) {
isAllDay: isAllDay,
state: state.innerText,
triggerEventName: 'click',
id: this._schedule.id,
_feId: this._schedule.__fe_id
id: this._schedule.id
},
start: start,
end: end,
calendar: this._selectedCal,
originCalendarId: this._schedule.calendarId,
triggerEventName: 'click'
});
} else {
Expand Down

0 comments on commit c2405b7

Please sign in to comment.