@devexpress/dx-scheduler-core
Advanced tools
Comparing version 2.0.3 to 2.0.4
/** | ||
* Bundle of @devexpress/dx-scheduler-core | ||
* Generated: 2019-08-16 | ||
* Version: 2.0.3 | ||
* Generated: 2019-09-02 | ||
* Version: 2.0.4 | ||
* License: https://js.devexpress.com/Licensing | ||
@@ -9,3 +9,3 @@ */ | ||
import moment from 'moment'; | ||
import { RRule, RRuleSet } from 'rrule'; | ||
import { RRule, RRuleSet, rrulestr } from 'rrule'; | ||
@@ -100,2 +100,7 @@ /*! ***************************************************************************** | ||
}; | ||
var RECURRENCE_EDIT_SCOPE = { | ||
ALL: 'all', | ||
CURRENT_AND_FOLLOWING: 'currentAndFollowing', | ||
CURRENT: 'current', | ||
}; | ||
@@ -309,10 +314,9 @@ var computed = function (getters, viewName, baseComputed, defaultValue) { | ||
}; | ||
var filterByViewBoundaries = function (appointment, leftBound, rightBound, excludedDays, keepAllDay) { | ||
if (!appointment.rRule) { | ||
return viewPredicate(appointment, leftBound, rightBound, excludedDays, keepAllDay) | ||
? [appointment] | ||
: []; | ||
} | ||
var expandRecurrenceAppointment = function (appointment, leftBound, rightBound) { | ||
var rightBoundUTC = new Date(getUTCDate(rightBound)); | ||
var leftBoundUTC = new Date(getUTCDate(leftBound)); | ||
var appointmentStartDate = moment(appointment.start).toDate(); | ||
var options = __assign({}, RRule.parseString(appointment.rRule), { dtstart: new Date(getUTCDate(appointmentStartDate)) }); | ||
var correctedOptions = options.until | ||
? __assign({}, options, { until: new Date(getUTCDate(options.until)) }) : options; | ||
var rruleSet = new RRuleSet(); | ||
@@ -325,8 +329,7 @@ if (appointment.exDate) { | ||
} | ||
rruleSet.rrule(new RRule(options)); | ||
rruleSet.rrule(new RRule(correctedOptions)); | ||
// According to https://github.com/jakubroztocil/rrule#important-use-utc-dates | ||
// we have to format the dates we get from RRuleSet to get local dates | ||
var datesInBoundaries = rruleSet.between(leftBound, rightBound).map(function (date) { | ||
return moment.utc(date).format('YYYY-MM-DD HH:mm'); | ||
}); | ||
var datesInBoundaries = rruleSet.between(leftBoundUTC, rightBoundUTC, true) | ||
.map(function (date) { return moment.utc(date).format('YYYY-MM-DD HH:mm'); }); | ||
if (datesInBoundaries.length === 0) | ||
@@ -336,4 +339,11 @@ return []; | ||
.diff(appointment.start, 'minutes'); | ||
return datesInBoundaries.map(function (startDate, index) { return (__assign({}, appointment, { dataItem: __assign({}, appointment.dataItem, { startDate: moment(startDate).toDate(), endDate: moment(startDate).add(appointmentDuration, 'minutes').toDate() }), start: moment(startDate), end: moment(startDate).add(appointmentDuration, 'minutes') })); }); | ||
return datesInBoundaries.map(function (startDate, index) { return (__assign({}, appointment, { dataItem: __assign({}, appointment.dataItem, { startDate: moment(startDate).toDate(), endDate: moment(startDate).add(appointmentDuration, 'minutes').toDate(), parentData: appointment.dataItem }), start: moment(startDate), end: moment(startDate).add(appointmentDuration, 'minutes') })); }); | ||
}; | ||
var filterByViewBoundaries = function (appointment, leftBound, rightBound, excludedDays, removeAllDay) { | ||
var appointments = [appointment]; | ||
if (appointment.rRule) { | ||
appointments = expandRecurrenceAppointment(appointment, leftBound, rightBound); | ||
} | ||
return appointments.filter(function (appt) { return viewPredicate(appt, leftBound, rightBound, excludedDays, removeAllDay); }); | ||
}; | ||
var getUTCDate = function (date) { | ||
@@ -816,6 +826,3 @@ return Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes()); | ||
var cancelAddedAppointment = function () { return ({}); }; | ||
var startEditAppointment = function (prevEditingAppointmentId, _a) { | ||
var appointmentId = _a.appointmentId; | ||
return appointmentId; | ||
}; | ||
var startEditAppointment = function (prevEditingAppointment, appointmentData) { return appointmentData; }; | ||
var stopEditAppointment = function () { return undefined; }; | ||
@@ -833,2 +840,166 @@ var changeAppointment = function (appointment, _a) { | ||
var mergeNewChanges = function (appointmentData, changes) { | ||
var appointment = __assign({}, appointmentData); | ||
delete appointment.id; | ||
delete appointment.rRule; | ||
delete appointment.exDate; | ||
delete appointment.parentData; | ||
return __assign({}, appointment, changes); | ||
}; | ||
var reduceExDate = function (prevExDate, boundDate) { | ||
if (prevExDate.length > 0) { | ||
return prevExDate.split(',').reduce(function (acc, date) { | ||
var momentDate = moment.utc(date); | ||
if (momentDate.isBefore(boundDate)) { | ||
return __spread(acc, [date]); | ||
} | ||
return acc; | ||
}, []).join(','); | ||
} | ||
return undefined; | ||
}; | ||
var configureExDate = function (exDate, date) { | ||
var currentExDate = moment.utc(date).format('YYYYMMDDTHHmmss') + "Z"; | ||
return exDate | ||
? exDate + "," + currentExDate | ||
: currentExDate; | ||
}; | ||
var configureDateSequence = function (rRule, exDate, options) { | ||
var rruleSet = new RRuleSet(); | ||
if (exDate) { | ||
rruleSet = rrulestr("EXDATE:" + exDate, { forceset: true }); | ||
} | ||
rruleSet.rrule(new RRule(__assign({}, RRule.parseString(rRule), options))); | ||
return rruleSet.all(); | ||
}; | ||
var configureICalendarRules = function (rRule, options) { | ||
var rruleSet = new RRuleSet(); | ||
rruleSet.rrule(new RRule(__assign({}, RRule.parseString(rRule), options))); | ||
return rruleSet.valueOf(); | ||
}; | ||
var deleteCurrent = function (appointmentData) { | ||
var _a; | ||
var currentSequence = configureDateSequence(appointmentData.rRule, appointmentData.exDate, { dtstart: moment.utc(appointmentData.parentData.startDate).toDate() }); | ||
if (currentSequence.length === 1) { | ||
return deleteAll(appointmentData); | ||
} | ||
var nextExDate = configureExDate(appointmentData.exDate, appointmentData.startDate); | ||
return { changed: (_a = {}, _a[appointmentData.id] = { exDate: nextExDate }, _a) }; | ||
}; | ||
var deleteAll = function (appointmentData) { | ||
return { deleted: appointmentData.id }; | ||
}; | ||
var deletedCurrentAndFollowing = function (appointmentData) { | ||
var _a; | ||
var rRule = appointmentData.rRule, startDate = appointmentData.startDate, parentData = appointmentData.parentData, _b = appointmentData.exDate, prevExDate = _b === void 0 ? '' : _b, id = appointmentData.id; | ||
var initialSequence = configureDateSequence(rRule, prevExDate, { | ||
dtstart: moment.utc(parentData.startDate).toDate(), | ||
}); | ||
if (initialSequence.length === 1) { | ||
return deleteAll(appointmentData); | ||
} | ||
var currentChildIndex = initialSequence | ||
.findIndex(function (date) { return moment(date).isSame(startDate); }); | ||
var changedRules = configureICalendarRules(rRule, { | ||
dtstart: moment.utc(parentData.startDate).toDate(), | ||
until: moment.utc(initialSequence[currentChildIndex]).toDate(), | ||
count: null, | ||
}); | ||
var nextExDate = reduceExDate(prevExDate, startDate); | ||
return { | ||
changed: (_a = {}, | ||
_a[id] = __assign({ rRule: changedRules[1].slice(6) }, nextExDate && prevExDate !== nextExDate ? { exDate: nextExDate } : {}), | ||
_a), | ||
}; | ||
}; | ||
var editAll = function (changes, appointmentData) { | ||
var _a, _b; | ||
var rRule = appointmentData.rRule, id = appointmentData.id; | ||
var initialRule = new RRule(RRule.parseString(rRule)); | ||
if (moment.utc(changes.startDate).isAfter(initialRule.options.until)) { | ||
return { | ||
changed: (_a = {}, | ||
_a[id] = __assign({}, changes, { rRule: 'FREQ=DAILY;COUNT=1', exDate: '' }), | ||
_a), | ||
}; | ||
} | ||
return { changed: (_b = {}, _b[appointmentData.id] = changes, _b) }; | ||
}; | ||
var editCurrent = function (changes, appointmentData) { | ||
var _a; | ||
return ({ | ||
changed: (_a = {}, | ||
_a[appointmentData.id] = { | ||
exDate: configureExDate(appointmentData.exDate, appointmentData.startDate), | ||
}, | ||
_a), | ||
added: mergeNewChanges(appointmentData, changes), | ||
}); | ||
}; | ||
var editCurrentAndFollowing = function (changes, appointmentData) { | ||
var _a, _b; | ||
var rRule = appointmentData.rRule, startDate = appointmentData.startDate, parentData = appointmentData.parentData, _c = appointmentData.exDate, prevExDate = _c === void 0 ? '' : _c, id = appointmentData.id; | ||
var initialRule = new RRule(RRule.parseString(rRule)); | ||
if (moment.utc(changes.startDate).isAfter(initialRule.options.until)) { | ||
return { | ||
changed: (_a = {}, | ||
_a[id] = __assign({}, changes, { rRule: 'FREQ=DAILY;COUNT=1', exDate: '' }), | ||
_a), | ||
}; | ||
} | ||
var initialSequence = configureDateSequence(rRule, prevExDate, { | ||
dtstart: moment.utc(parentData.startDate).toDate(), | ||
}); | ||
var currentChildIndex = initialSequence | ||
.findIndex(function (date) { return moment(date).isSame(startDate); }); | ||
if (currentChildIndex === 0) { | ||
return editAll(changes, appointmentData); | ||
} | ||
var changedRules = configureICalendarRules(rRule, { | ||
dtstart: moment.utc(parentData.startDate).toDate(), | ||
until: moment.utc(initialSequence[currentChildIndex - 1]).toDate(), | ||
count: null, | ||
}); | ||
var addedRules = configureICalendarRules(rRule, { | ||
dtstart: moment.utc(startDate).toDate(), | ||
count: initialSequence.length - currentChildIndex, | ||
}); | ||
var nextExDate = reduceExDate(prevExDate, startDate); | ||
return { | ||
changed: (_b = {}, | ||
_b[id] = __assign({ rRule: changedRules[1].slice(6) }, nextExDate && prevExDate !== nextExDate ? { exDate: nextExDate } : {}), | ||
_b), | ||
added: __assign({ rRule: addedRules[1].slice(6) }, mergeNewChanges(appointmentData, changes)), | ||
}; | ||
}; | ||
var preCommitChanges = function (changes, appointmentData, editType) { | ||
if (changes === null) { | ||
switch (editType) { | ||
case RECURRENCE_EDIT_SCOPE.ALL: { | ||
return deleteAll(appointmentData); | ||
} | ||
case RECURRENCE_EDIT_SCOPE.CURRENT: { | ||
return deleteCurrent(appointmentData); | ||
} | ||
case RECURRENCE_EDIT_SCOPE.CURRENT_AND_FOLLOWING: { | ||
return deletedCurrentAndFollowing(appointmentData); | ||
} | ||
} | ||
} | ||
else { | ||
switch (editType) { | ||
case RECURRENCE_EDIT_SCOPE.ALL: { | ||
return editAll(changes, appointmentData); | ||
} | ||
case RECURRENCE_EDIT_SCOPE.CURRENT: { | ||
return editCurrent(changes, appointmentData); | ||
} | ||
case RECURRENCE_EDIT_SCOPE.CURRENT_AND_FOLLOWING: { | ||
return editCurrentAndFollowing(changes, appointmentData); | ||
} | ||
} | ||
} | ||
return {}; | ||
}; | ||
var clamp = function (value, min, max) { return Math.max(Math.min(value, max), min); }; | ||
@@ -893,2 +1064,10 @@ var calculateInsideOffset = function (targetType, insidePart, cellDurationMinutes) { return targetType === VERTICAL_TYPE | ||
var timeBoundariesByDrag = function (payload, targetData, targetType, cellDurationMinutes, insidePart, offsetTimeTopBase) { | ||
if (targetType === HORIZONTAL_TYPE | ||
&& intervalDuration(payload, SECONDS) < intervalDuration(targetData, SECONDS)) { | ||
return { | ||
appointmentStartTime: targetData.startDate, | ||
appointmentEndTime: targetData.endDate, | ||
offsetTimeTop: 0, | ||
}; | ||
} | ||
var offsetTimeTop; | ||
@@ -933,7 +1112,8 @@ var appointmentStartTime; | ||
var calculateDraftAppointments = function (allDayIndex, draftAppointments, startViewDate, endViewDate, excludedDays, viewCellsData, getAllDayCellsElementRects, targetType, cellDurationMinutes, getTableCellElementRects) { | ||
if (allDayIndex !== -1 | ||
|| (getAllDayCellsElementRects.getCellRects.length | ||
&& intervalDuration(draftAppointments[0].dataItem, HOURS) > 23)) { | ||
if (allDayIndex !== -1 || (targetType === VERTICAL_TYPE | ||
&& getAllDayCellsElementRects.getCellRects.length | ||
&& intervalDuration(draftAppointments[0].dataItem, HOURS) > 23)) { | ||
var allDayDrafts = draftAppointments.map(function (draftAppt) { return (__assign({}, draftAppt, { allDay: true })); }); | ||
return { | ||
allDayDraftAppointments: allDayRects(draftAppointments, startViewDate, endViewDate, excludedDays, viewCellsData, getAllDayCellsElementRects), | ||
allDayDraftAppointments: allDayRects(allDayDrafts, startViewDate, endViewDate, excludedDays, viewCellsData, getAllDayCellsElementRects), | ||
timeTableDraftAppointments: [], | ||
@@ -954,3 +1134,3 @@ }; | ||
export { AUTO_HEIGHT, CANCEL_COMMAND_BUTTON, CLOSE_COMMAND_BUTTON, COMMIT_COMMAND_BUTTON, DAY_LONG_MONTH_LONG_YEAR_OPTIONS, DAY_OPTIONS, DAY_SHORT_MONTH_LONG_YEAR_OPTIONS, DAY_SHORT_MONTH_OPTIONS, DAY_SHORT_MONTH_SHORT_YEAR_OPTIONS, DELETE_COMMAND_BUTTON, HORIZONTAL_TYPE, HOURS, HOUR_MINUTE_OPTIONS, MINUTES, MONTH_YEAR_OPTIONS, OPEN_COMMAND_BUTTON, POSITION_END, POSITION_START, RESIZE_BOTTOM, RESIZE_TOP, SCROLL_OFFSET, SCROLL_SPEED_PX, SECONDS, SHORT_MONTH_LONG_YEAR_OPTIONS, SHORT_MONTH_OPTIONS, SHORT_MONTH_SHORT_YEAR_OPTIONS, VERTICAL_TYPE, WEEK_DAY_OPTIONS, addAppointment, adjustAppointments, allDayCells, allDayPredicate, allDayRects, appointments, autoScroll, availableViews, calculateAllDayDateIntervals, calculateAppointmentTimeBoundaries, calculateDraftAppointments, calculateFirstDateOfWeek, calculateInsidePart, calculateMonthDateIntervals, calculateRectByDateIntervals, calculateWeekDateIntervals, callActionIfExists, cancelAddedAppointment, cancelChanges, cellData, cellIndex, cellType, changeAppointment, changeCurrentDate, changedAppointmentById, computed, dayBoundaryPredicate, dayScale, endViewDate, filterByViewBoundaries, findOverlappedAppointments, formatDateTimeGetter, getAllDayCellIndexByDate, getAppointmentStyle, getCellByDate, getHorizontalRectByDates, getMonthCellIndexByDate, getVerticalRectByDates, getViewType, horizontalTimeTableRects, intervalDuration, isAllDayCell, monthCellsData, reduceAppointmentByDayBounds, setAppointmentData, setAppointmentMeta, setCurrentViewName, sliceAppointmentByDay, sliceAppointmentByWeek, sliceAppointmentsByBoundaries, sortAppointments, startEditAppointment, startViewDate, stopEditAppointment, timeBoundariesByDrag, timeBoundariesByResize, timeScale, toPercentage, unwrapGroups, verticalTimeTableRects, viewBoundText, viewCellsData, viewPredicate }; | ||
export { AUTO_HEIGHT, CANCEL_COMMAND_BUTTON, CLOSE_COMMAND_BUTTON, COMMIT_COMMAND_BUTTON, DAY_LONG_MONTH_LONG_YEAR_OPTIONS, DAY_OPTIONS, DAY_SHORT_MONTH_LONG_YEAR_OPTIONS, DAY_SHORT_MONTH_OPTIONS, DAY_SHORT_MONTH_SHORT_YEAR_OPTIONS, DELETE_COMMAND_BUTTON, HORIZONTAL_TYPE, HOURS, HOUR_MINUTE_OPTIONS, MINUTES, MONTH_YEAR_OPTIONS, OPEN_COMMAND_BUTTON, POSITION_END, POSITION_START, RECURRENCE_EDIT_SCOPE, RESIZE_BOTTOM, RESIZE_TOP, SCROLL_OFFSET, SCROLL_SPEED_PX, SECONDS, SHORT_MONTH_LONG_YEAR_OPTIONS, SHORT_MONTH_OPTIONS, SHORT_MONTH_SHORT_YEAR_OPTIONS, VERTICAL_TYPE, WEEK_DAY_OPTIONS, addAppointment, adjustAppointments, allDayCells, allDayPredicate, allDayRects, appointments, autoScroll, availableViews, calculateAllDayDateIntervals, calculateAppointmentTimeBoundaries, calculateDraftAppointments, calculateFirstDateOfWeek, calculateInsidePart, calculateMonthDateIntervals, calculateRectByDateIntervals, calculateWeekDateIntervals, callActionIfExists, cancelAddedAppointment, cancelChanges, cellData, cellIndex, cellType, changeAppointment, changeCurrentDate, changedAppointmentById, computed, dayBoundaryPredicate, dayScale, deleteAll, deleteCurrent, deletedCurrentAndFollowing, editAll, editCurrent, editCurrentAndFollowing, endViewDate, filterByViewBoundaries, findOverlappedAppointments, formatDateTimeGetter, getAllDayCellIndexByDate, getAppointmentStyle, getCellByDate, getHorizontalRectByDates, getMonthCellIndexByDate, getVerticalRectByDates, getViewType, horizontalTimeTableRects, intervalDuration, isAllDayCell, monthCellsData, preCommitChanges, reduceAppointmentByDayBounds, setAppointmentData, setAppointmentMeta, setCurrentViewName, sliceAppointmentByDay, sliceAppointmentByWeek, sliceAppointmentsByBoundaries, sortAppointments, startEditAppointment, startViewDate, stopEditAppointment, timeBoundariesByDrag, timeBoundariesByResize, timeScale, toPercentage, unwrapGroups, verticalTimeTableRects, viewBoundText, viewCellsData, viewPredicate }; | ||
//# sourceMappingURL=dx-scheduler-core.es.js.map |
/** | ||
* Bundle of @devexpress/dx-scheduler-core | ||
* Generated: 2019-08-16 | ||
* Version: 2.0.3 | ||
* Generated: 2019-09-02 | ||
* Version: 2.0.4 | ||
* License: https://js.devexpress.com/Licensing | ||
@@ -106,2 +106,7 @@ */ | ||
}; | ||
var RECURRENCE_EDIT_SCOPE = { | ||
ALL: 'all', | ||
CURRENT_AND_FOLLOWING: 'currentAndFollowing', | ||
CURRENT: 'current', | ||
}; | ||
@@ -315,10 +320,9 @@ var computed = function (getters, viewName, baseComputed, defaultValue) { | ||
}; | ||
var filterByViewBoundaries = function (appointment, leftBound, rightBound, excludedDays, keepAllDay) { | ||
if (!appointment.rRule) { | ||
return viewPredicate(appointment, leftBound, rightBound, excludedDays, keepAllDay) | ||
? [appointment] | ||
: []; | ||
} | ||
var expandRecurrenceAppointment = function (appointment, leftBound, rightBound) { | ||
var rightBoundUTC = new Date(getUTCDate(rightBound)); | ||
var leftBoundUTC = new Date(getUTCDate(leftBound)); | ||
var appointmentStartDate = moment(appointment.start).toDate(); | ||
var options = __assign({}, rrule.RRule.parseString(appointment.rRule), { dtstart: new Date(getUTCDate(appointmentStartDate)) }); | ||
var correctedOptions = options.until | ||
? __assign({}, options, { until: new Date(getUTCDate(options.until)) }) : options; | ||
var rruleSet = new rrule.RRuleSet(); | ||
@@ -331,8 +335,7 @@ if (appointment.exDate) { | ||
} | ||
rruleSet.rrule(new rrule.RRule(options)); | ||
rruleSet.rrule(new rrule.RRule(correctedOptions)); | ||
// According to https://github.com/jakubroztocil/rrule#important-use-utc-dates | ||
// we have to format the dates we get from RRuleSet to get local dates | ||
var datesInBoundaries = rruleSet.between(leftBound, rightBound).map(function (date) { | ||
return moment.utc(date).format('YYYY-MM-DD HH:mm'); | ||
}); | ||
var datesInBoundaries = rruleSet.between(leftBoundUTC, rightBoundUTC, true) | ||
.map(function (date) { return moment.utc(date).format('YYYY-MM-DD HH:mm'); }); | ||
if (datesInBoundaries.length === 0) | ||
@@ -342,4 +345,11 @@ return []; | ||
.diff(appointment.start, 'minutes'); | ||
return datesInBoundaries.map(function (startDate, index) { return (__assign({}, appointment, { dataItem: __assign({}, appointment.dataItem, { startDate: moment(startDate).toDate(), endDate: moment(startDate).add(appointmentDuration, 'minutes').toDate() }), start: moment(startDate), end: moment(startDate).add(appointmentDuration, 'minutes') })); }); | ||
return datesInBoundaries.map(function (startDate, index) { return (__assign({}, appointment, { dataItem: __assign({}, appointment.dataItem, { startDate: moment(startDate).toDate(), endDate: moment(startDate).add(appointmentDuration, 'minutes').toDate(), parentData: appointment.dataItem }), start: moment(startDate), end: moment(startDate).add(appointmentDuration, 'minutes') })); }); | ||
}; | ||
var filterByViewBoundaries = function (appointment, leftBound, rightBound, excludedDays, removeAllDay) { | ||
var appointments = [appointment]; | ||
if (appointment.rRule) { | ||
appointments = expandRecurrenceAppointment(appointment, leftBound, rightBound); | ||
} | ||
return appointments.filter(function (appt) { return viewPredicate(appt, leftBound, rightBound, excludedDays, removeAllDay); }); | ||
}; | ||
var getUTCDate = function (date) { | ||
@@ -822,6 +832,3 @@ return Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes()); | ||
var cancelAddedAppointment = function () { return ({}); }; | ||
var startEditAppointment = function (prevEditingAppointmentId, _a) { | ||
var appointmentId = _a.appointmentId; | ||
return appointmentId; | ||
}; | ||
var startEditAppointment = function (prevEditingAppointment, appointmentData) { return appointmentData; }; | ||
var stopEditAppointment = function () { return undefined; }; | ||
@@ -839,2 +846,166 @@ var changeAppointment = function (appointment, _a) { | ||
var mergeNewChanges = function (appointmentData, changes) { | ||
var appointment = __assign({}, appointmentData); | ||
delete appointment.id; | ||
delete appointment.rRule; | ||
delete appointment.exDate; | ||
delete appointment.parentData; | ||
return __assign({}, appointment, changes); | ||
}; | ||
var reduceExDate = function (prevExDate, boundDate) { | ||
if (prevExDate.length > 0) { | ||
return prevExDate.split(',').reduce(function (acc, date) { | ||
var momentDate = moment.utc(date); | ||
if (momentDate.isBefore(boundDate)) { | ||
return __spread(acc, [date]); | ||
} | ||
return acc; | ||
}, []).join(','); | ||
} | ||
return undefined; | ||
}; | ||
var configureExDate = function (exDate, date) { | ||
var currentExDate = moment.utc(date).format('YYYYMMDDTHHmmss') + "Z"; | ||
return exDate | ||
? exDate + "," + currentExDate | ||
: currentExDate; | ||
}; | ||
var configureDateSequence = function (rRule, exDate, options) { | ||
var rruleSet = new rrule.RRuleSet(); | ||
if (exDate) { | ||
rruleSet = rrule.rrulestr("EXDATE:" + exDate, { forceset: true }); | ||
} | ||
rruleSet.rrule(new rrule.RRule(__assign({}, rrule.RRule.parseString(rRule), options))); | ||
return rruleSet.all(); | ||
}; | ||
var configureICalendarRules = function (rRule, options) { | ||
var rruleSet = new rrule.RRuleSet(); | ||
rruleSet.rrule(new rrule.RRule(__assign({}, rrule.RRule.parseString(rRule), options))); | ||
return rruleSet.valueOf(); | ||
}; | ||
var deleteCurrent = function (appointmentData) { | ||
var _a; | ||
var currentSequence = configureDateSequence(appointmentData.rRule, appointmentData.exDate, { dtstart: moment.utc(appointmentData.parentData.startDate).toDate() }); | ||
if (currentSequence.length === 1) { | ||
return deleteAll(appointmentData); | ||
} | ||
var nextExDate = configureExDate(appointmentData.exDate, appointmentData.startDate); | ||
return { changed: (_a = {}, _a[appointmentData.id] = { exDate: nextExDate }, _a) }; | ||
}; | ||
var deleteAll = function (appointmentData) { | ||
return { deleted: appointmentData.id }; | ||
}; | ||
var deletedCurrentAndFollowing = function (appointmentData) { | ||
var _a; | ||
var rRule = appointmentData.rRule, startDate = appointmentData.startDate, parentData = appointmentData.parentData, _b = appointmentData.exDate, prevExDate = _b === void 0 ? '' : _b, id = appointmentData.id; | ||
var initialSequence = configureDateSequence(rRule, prevExDate, { | ||
dtstart: moment.utc(parentData.startDate).toDate(), | ||
}); | ||
if (initialSequence.length === 1) { | ||
return deleteAll(appointmentData); | ||
} | ||
var currentChildIndex = initialSequence | ||
.findIndex(function (date) { return moment(date).isSame(startDate); }); | ||
var changedRules = configureICalendarRules(rRule, { | ||
dtstart: moment.utc(parentData.startDate).toDate(), | ||
until: moment.utc(initialSequence[currentChildIndex]).toDate(), | ||
count: null, | ||
}); | ||
var nextExDate = reduceExDate(prevExDate, startDate); | ||
return { | ||
changed: (_a = {}, | ||
_a[id] = __assign({ rRule: changedRules[1].slice(6) }, nextExDate && prevExDate !== nextExDate ? { exDate: nextExDate } : {}), | ||
_a), | ||
}; | ||
}; | ||
var editAll = function (changes, appointmentData) { | ||
var _a, _b; | ||
var rRule = appointmentData.rRule, id = appointmentData.id; | ||
var initialRule = new rrule.RRule(rrule.RRule.parseString(rRule)); | ||
if (moment.utc(changes.startDate).isAfter(initialRule.options.until)) { | ||
return { | ||
changed: (_a = {}, | ||
_a[id] = __assign({}, changes, { rRule: 'FREQ=DAILY;COUNT=1', exDate: '' }), | ||
_a), | ||
}; | ||
} | ||
return { changed: (_b = {}, _b[appointmentData.id] = changes, _b) }; | ||
}; | ||
var editCurrent = function (changes, appointmentData) { | ||
var _a; | ||
return ({ | ||
changed: (_a = {}, | ||
_a[appointmentData.id] = { | ||
exDate: configureExDate(appointmentData.exDate, appointmentData.startDate), | ||
}, | ||
_a), | ||
added: mergeNewChanges(appointmentData, changes), | ||
}); | ||
}; | ||
var editCurrentAndFollowing = function (changes, appointmentData) { | ||
var _a, _b; | ||
var rRule = appointmentData.rRule, startDate = appointmentData.startDate, parentData = appointmentData.parentData, _c = appointmentData.exDate, prevExDate = _c === void 0 ? '' : _c, id = appointmentData.id; | ||
var initialRule = new rrule.RRule(rrule.RRule.parseString(rRule)); | ||
if (moment.utc(changes.startDate).isAfter(initialRule.options.until)) { | ||
return { | ||
changed: (_a = {}, | ||
_a[id] = __assign({}, changes, { rRule: 'FREQ=DAILY;COUNT=1', exDate: '' }), | ||
_a), | ||
}; | ||
} | ||
var initialSequence = configureDateSequence(rRule, prevExDate, { | ||
dtstart: moment.utc(parentData.startDate).toDate(), | ||
}); | ||
var currentChildIndex = initialSequence | ||
.findIndex(function (date) { return moment(date).isSame(startDate); }); | ||
if (currentChildIndex === 0) { | ||
return editAll(changes, appointmentData); | ||
} | ||
var changedRules = configureICalendarRules(rRule, { | ||
dtstart: moment.utc(parentData.startDate).toDate(), | ||
until: moment.utc(initialSequence[currentChildIndex - 1]).toDate(), | ||
count: null, | ||
}); | ||
var addedRules = configureICalendarRules(rRule, { | ||
dtstart: moment.utc(startDate).toDate(), | ||
count: initialSequence.length - currentChildIndex, | ||
}); | ||
var nextExDate = reduceExDate(prevExDate, startDate); | ||
return { | ||
changed: (_b = {}, | ||
_b[id] = __assign({ rRule: changedRules[1].slice(6) }, nextExDate && prevExDate !== nextExDate ? { exDate: nextExDate } : {}), | ||
_b), | ||
added: __assign({ rRule: addedRules[1].slice(6) }, mergeNewChanges(appointmentData, changes)), | ||
}; | ||
}; | ||
var preCommitChanges = function (changes, appointmentData, editType) { | ||
if (changes === null) { | ||
switch (editType) { | ||
case RECURRENCE_EDIT_SCOPE.ALL: { | ||
return deleteAll(appointmentData); | ||
} | ||
case RECURRENCE_EDIT_SCOPE.CURRENT: { | ||
return deleteCurrent(appointmentData); | ||
} | ||
case RECURRENCE_EDIT_SCOPE.CURRENT_AND_FOLLOWING: { | ||
return deletedCurrentAndFollowing(appointmentData); | ||
} | ||
} | ||
} | ||
else { | ||
switch (editType) { | ||
case RECURRENCE_EDIT_SCOPE.ALL: { | ||
return editAll(changes, appointmentData); | ||
} | ||
case RECURRENCE_EDIT_SCOPE.CURRENT: { | ||
return editCurrent(changes, appointmentData); | ||
} | ||
case RECURRENCE_EDIT_SCOPE.CURRENT_AND_FOLLOWING: { | ||
return editCurrentAndFollowing(changes, appointmentData); | ||
} | ||
} | ||
} | ||
return {}; | ||
}; | ||
var clamp = function (value, min, max) { return Math.max(Math.min(value, max), min); }; | ||
@@ -899,2 +1070,10 @@ var calculateInsideOffset = function (targetType, insidePart, cellDurationMinutes) { return targetType === VERTICAL_TYPE | ||
var timeBoundariesByDrag = function (payload, targetData, targetType, cellDurationMinutes, insidePart, offsetTimeTopBase) { | ||
if (targetType === HORIZONTAL_TYPE | ||
&& intervalDuration(payload, SECONDS) < intervalDuration(targetData, SECONDS)) { | ||
return { | ||
appointmentStartTime: targetData.startDate, | ||
appointmentEndTime: targetData.endDate, | ||
offsetTimeTop: 0, | ||
}; | ||
} | ||
var offsetTimeTop; | ||
@@ -939,7 +1118,8 @@ var appointmentStartTime; | ||
var calculateDraftAppointments = function (allDayIndex, draftAppointments, startViewDate, endViewDate, excludedDays, viewCellsData, getAllDayCellsElementRects, targetType, cellDurationMinutes, getTableCellElementRects) { | ||
if (allDayIndex !== -1 | ||
|| (getAllDayCellsElementRects.getCellRects.length | ||
&& intervalDuration(draftAppointments[0].dataItem, HOURS) > 23)) { | ||
if (allDayIndex !== -1 || (targetType === VERTICAL_TYPE | ||
&& getAllDayCellsElementRects.getCellRects.length | ||
&& intervalDuration(draftAppointments[0].dataItem, HOURS) > 23)) { | ||
var allDayDrafts = draftAppointments.map(function (draftAppt) { return (__assign({}, draftAppt, { allDay: true })); }); | ||
return { | ||
allDayDraftAppointments: allDayRects(draftAppointments, startViewDate, endViewDate, excludedDays, viewCellsData, getAllDayCellsElementRects), | ||
allDayDraftAppointments: allDayRects(allDayDrafts, startViewDate, endViewDate, excludedDays, viewCellsData, getAllDayCellsElementRects), | ||
timeTableDraftAppointments: [], | ||
@@ -978,2 +1158,3 @@ }; | ||
exports.POSITION_START = POSITION_START; | ||
exports.RECURRENCE_EDIT_SCOPE = RECURRENCE_EDIT_SCOPE; | ||
exports.RESIZE_BOTTOM = RESIZE_BOTTOM; | ||
@@ -1017,2 +1198,8 @@ exports.RESIZE_TOP = RESIZE_TOP; | ||
exports.dayScale = dayScale; | ||
exports.deleteAll = deleteAll; | ||
exports.deleteCurrent = deleteCurrent; | ||
exports.deletedCurrentAndFollowing = deletedCurrentAndFollowing; | ||
exports.editAll = editAll; | ||
exports.editCurrent = editCurrent; | ||
exports.editCurrentAndFollowing = editCurrentAndFollowing; | ||
exports.endViewDate = endViewDate; | ||
@@ -1033,2 +1220,3 @@ exports.filterByViewBoundaries = filterByViewBoundaries; | ||
exports.monthCellsData = monthCellsData; | ||
exports.preCommitChanges = preCommitChanges; | ||
exports.reduceAppointmentByDayBounds = reduceAppointmentByDayBounds; | ||
@@ -1035,0 +1223,0 @@ exports.setAppointmentData = setAppointmentData; |
{ | ||
"name": "@devexpress/dx-scheduler-core", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"description": "Core library for the DevExtreme Reactive Scheduler component", | ||
@@ -44,21 +44,21 @@ "author": { | ||
"@babel/preset-env": "^7.5.5", | ||
"@devexpress/dx-core": "2.0.3", | ||
"@devexpress/dx-core": "2.0.4", | ||
"babel-core": "^7.0.0-bridge.0", | ||
"babel-jest": "^24.8.0", | ||
"babel-jest": "^24.9.0", | ||
"core-js": "^3.2.1", | ||
"eslint": "^6.1.0", | ||
"eslint-config-airbnb-base": "^13.2.0", | ||
"eslint": "6.1.0", | ||
"eslint-config-airbnb-base": "13.2.0", | ||
"eslint-plugin-filenames": "^1.3.2", | ||
"eslint-plugin-import": "^2.18.2", | ||
"eslint-plugin-jest": "^22.15.1", | ||
"jest": "^24.8.0", | ||
"rollup": "^1.19.4", | ||
"eslint-plugin-jest": "^22.15.2", | ||
"jest": "^24.9.0", | ||
"rollup": "^1.20.3", | ||
"rollup-plugin-babel": "^4.3.3", | ||
"rollup-plugin-license": "^0.12.0", | ||
"rollup-plugin-license": "^0.12.1", | ||
"rollup-plugin-replace": "^2.2.0", | ||
"rollup-plugin-typescript2": "^0.22.1", | ||
"typescript": "^3.5.3" | ||
"rollup-plugin-typescript2": "^0.24.0", | ||
"typescript": "3.5.3" | ||
}, | ||
"peerDependencies": { | ||
"@devexpress/dx-core": "2.0.3" | ||
"@devexpress/dx-core": "2.0.4" | ||
}, | ||
@@ -69,3 +69,3 @@ "dependencies": { | ||
}, | ||
"gitHead": "1790d3c1f2654a09c2fddba300d26bd713512301" | ||
"gitHead": "7faeea645c9df41556a06e7a47e3e8662fc7228e" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
333445
2298