UNPKG

devextreme

Version:

HTML5 JavaScript Component Suite for Responsive Web Development

141 lines (138 loc) 5.9 kB
/** * DevExtreme (cjs/ui/scheduler/appointments/dataProvider/appointmentDataProvider.js) * Version: 21.2.4 * Build date: Mon Dec 06 2021 * * Copyright (c) 2012 - 2021 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ "use strict"; exports.AppointmentDataProvider = void 0; var _appointmentDataSource = require("./appointmentDataSource"); var _appointmentFilter = require("./appointmentFilter"); var _appointmentAdapter = require("../../appointmentAdapter"); function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) { descriptor.writable = true } Object.defineProperty(target, descriptor.key, descriptor) } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) { _defineProperties(Constructor.prototype, protoProps) } if (staticProps) { _defineProperties(Constructor, staticProps) } return Constructor } var FilterStrategies = { virtual: "virtual", standard: "standard" }; var AppointmentDataProvider = function() { function AppointmentDataProvider(options) { this.options = options; this.dataSource = this.options.dataSource; this.dataAccessors = this.options.dataAccessors; this.timeZoneCalculator = this.options.timeZoneCalculator; this.appointmentDataSource = new _appointmentDataSource.AppointmentDataSource(this.dataSource); this.initFilterStrategy() } var _proto = AppointmentDataProvider.prototype; _proto.getFilterStrategy = function() { if (!this.filterStrategy || this.filterStrategy.strategyName !== this.filterStrategyName) { this.initFilterStrategy() } return this.filterStrategy }; _proto.initFilterStrategy = function() { var filterOptions = { resources: this.options.resources, dataSource: this.dataSource, dataAccessors: this.dataAccessors, startDayHour: this.options.startDayHour, endDayHour: this.options.endDayHour, appointmentDuration: this.options.appointmentDuration, showAllDayPanel: this.options.showAllDayPanel, timeZoneCalculator: this.options.timeZoneCalculator, loadedResources: this.options.getLoadedResources, supportAllDayRow: this.options.getSupportAllDayRow, viewType: this.options.getViewType, viewDirection: this.options.getViewDirection, dateRange: this.options.getDateRange, groupCount: this.options.getGroupCount, viewDataProvider: this.options.getViewDataProvider }; this.filterStrategy = this.filterStrategyName === FilterStrategies.virtual ? new _appointmentFilter.AppointmentFilterVirtualStrategy(filterOptions) : new _appointmentFilter.AppointmentFilterBaseStrategy(filterOptions) }; _proto.setDataSource = function(dataSource) { this.dataSource = dataSource; this.initFilterStrategy(); this.appointmentDataSource.setDataSource(this.dataSource) }; _proto.updateDataAccessors = function(dataAccessors) { this.dataAccessors = dataAccessors; this.initFilterStrategy() }; _proto.filter = function() { return this.getFilterStrategy().filter() }; _proto.filterByDate = function(min, max, remoteFiltering, dateSerializationFormat) { this.getFilterStrategy().filterByDate(min, max, remoteFiltering, dateSerializationFormat) }; _proto.hasAllDayAppointments = function(rawAppointments) { var _this = this; var adapters = rawAppointments.map((function(item) { return (0, _appointmentAdapter.createAppointmentAdapter)(item, _this.dataAccessors, _this.timeZoneCalculator) })); return this.getFilterStrategy().hasAllDayAppointments(adapters) }; _proto.filterLoadedAppointments = function(filterOption, preparedItems) { return this.getFilterStrategy().filterLoadedAppointments(filterOption, preparedItems) }; _proto.calculateAppointmentEndDate = function(isAllDay, startDate) { return this.getFilterStrategy().calculateAppointmentEndDate(isAllDay, startDate) }; _proto.cleanState = function() { this.appointmentDataSource.cleanState() }; _proto.getUpdatedAppointment = function() { return this.appointmentDataSource._updatedAppointment }; _proto.getUpdatedAppointmentKeys = function() { return this.appointmentDataSource._updatedAppointmentKeys }; _proto.add = function(rawAppointment) { return this.appointmentDataSource.add(rawAppointment) }; _proto.update = function(target, rawAppointment) { return this.appointmentDataSource.update(target, rawAppointment) }; _proto.remove = function(rawAppointment) { return this.appointmentDataSource.remove(rawAppointment) }; _createClass(AppointmentDataProvider, [{ key: "filterMaker", get: function() { return this.getFilterStrategy().filterMaker } }, { key: "keyName", get: function() { return this.appointmentDataSource.keyName } }, { key: "filterStrategyName", get: function() { return this.options.getIsVirtualScrolling() ? FilterStrategies.virtual : FilterStrategies.standard } }]); return AppointmentDataProvider }(); exports.AppointmentDataProvider = AppointmentDataProvider;