devextreme
Version:
HTML5 JavaScript Component Suite for Responsive Web Development
71 lines (70 loc) • 3.26 kB
JavaScript
/**
* DevExtreme (esm/renovation/ui/scheduler/common.js)
* Version: 21.2.3
* Build date: Thu Oct 28 2021
*
* Copyright (c) 2012 - 2021 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
import {
utils
} from "../../../ui/scheduler/utils";
import {
TimeZoneCalculator
} from "./timeZoneCalculator/utils";
import timeZoneUtils from "../../../ui/scheduler/utils.timeZone";
import {
AppointmentFilterBaseStrategy,
AppointmentFilterVirtualStrategy
} from "../../../ui/scheduler/appointments/dataProvider/appointmentFilter";
import {
createExpressions
} from "../../../ui/scheduler/resources/utils";
export var createDataAccessors = function(props) {
var forceIsoDateParsing = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : false;
var dataAccessors = utils.dataAccessors.create({
startDate: props.startDateExpr,
endDate: props.endDateExpr,
startDateTimeZone: props.startDateTimeZoneExpr,
endDateTimeZone: props.endDateTimeZoneExpr,
allDay: props.allDayExpr,
text: props.textExpr,
description: props.descriptionExpr,
recurrenceRule: props.recurrenceRuleExpr,
recurrenceException: props.recurrenceExceptionExpr
}, null, forceIsoDateParsing, props.dateSerializationFormat);
dataAccessors.resources = createExpressions(props.resources);
return dataAccessors
};
export var createTimeZoneCalculator = currentTimeZone => new TimeZoneCalculator({
getClientOffset: date => timeZoneUtils.getClientTimezoneOffset(date),
getCommonOffset: date => timeZoneUtils.calculateTimezoneByValue(currentTimeZone, date),
getAppointmentOffset: (date, appointmentTimezone) => timeZoneUtils.calculateTimezoneByValue(appointmentTimezone, date)
});
export var filterAppointments = (appointmentsConfig, dataItems, dataAccessors, timeZoneCalculator, loadedResources, viewDataProvider) => {
if (!appointmentsConfig) {
return []
}
var filterOptions = {
resources: appointmentsConfig.resources,
startDayHour: appointmentsConfig.startDayHour,
endDayHour: appointmentsConfig.endDayHour,
appointmentDuration: appointmentsConfig.cellDurationInMinutes,
showAllDayPanel: appointmentsConfig.showAllDayPanel,
supportAllDayRow: appointmentsConfig.supportAllDayRow,
firstDayOfWeek: appointmentsConfig.firstDayOfWeek,
viewType: appointmentsConfig.viewType,
viewDirection: "vertical",
dateRange: appointmentsConfig.dateRange,
groupCount: appointmentsConfig.groupCount,
timeZoneCalculator: timeZoneCalculator,
dataSource: void 0,
dataAccessors: dataAccessors,
loadedResources: loadedResources,
viewDataProvider: viewDataProvider
};
var filterStrategy = appointmentsConfig.isVirtualScrolling ? new AppointmentFilterVirtualStrategy(filterOptions) : new AppointmentFilterBaseStrategy(filterOptions);
var preparedDataItems = filterStrategy.getPreparedDataItems(dataItems);
var filteredItems = filterStrategy.filter(preparedDataItems);
return filteredItems
};