devextreme
Version:
HTML5 JavaScript Component Suite for Responsive Web Development
118 lines (117 loc) • 3.31 kB
JavaScript
/**
* DevExtreme (esm/ui/scheduler/modelProvider.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 {
getGroupCount
} from "./resources/utils";
import {
isObject
} from "../../core/utils/type";
import {
getCurrentView
} from "../../renovation/ui/scheduler/model/views";
var VIEW_RENDERING_CONFIG = {
day: {
renderingStrategy: "vertical"
},
week: {
renderingStrategy: "vertical"
},
workWeek: {
renderingStrategy: "vertical"
},
month: {
renderingStrategy: "horizontalMonth"
},
timelineDay: {
renderingStrategy: "horizontal"
},
timelineWeek: {
renderingStrategy: "horizontal"
},
timelineWorkWeek: {
renderingStrategy: "horizontal"
},
timelineMonth: {
renderingStrategy: "horizontalMonthLine"
},
agenda: {
renderingStrategy: "agenda"
}
};
export class ModelProvider {
constructor(model) {
this.model = model;
this.currentView = null
}
get key() {
return this.model.key
}
get loadedResources() {
return this.model.loadedResources
}
get startDayHour() {
return this.model.startDayHour
}
get endDayHour() {
return this.model.endDayHour
}
get adaptivityEnabled() {
return this.model.adaptivityEnabled
}
get rtlEnabled() {
return this.model.rtlEnabled
}
get maxAppointmentsPerCell() {
return this.getCurrentViewOption("maxAppointmentsPerCell")
}
get currentViewOptions() {
return this.currentView
}
get currentViewType() {
return isObject(this.currentView) ? this.currentView.type : this.currentView
}
get agendaDuration() {
return this.model.agendaDuration
}
get currentDate() {
return this.model.currentDate
}
get timeZone() {
return this.model.timeZone
}
get isRenovatedAppointments() {
return this.model.isRenovatedAppointments
}
supportAllDayResizing() {
return "day" !== this.currentViewType || this.currentView.intervalCount > 1
}
updateCurrentView() {
var views = this.model.views;
var currentView = this.model.currentView;
this.currentView = getCurrentView(currentView, views)
}
isGroupedByDate() {
return this.model.groupByDate && this._isHorizontalGroupedWorkSpace() && getGroupCount(this.loadedResources) > 0
}
_isHorizontalGroupedWorkSpace() {
return !!this.loadedResources.length && "horizontal" === this.model.groupOrientation
}
getCurrentViewOption(optionName) {
if (this.currentView && void 0 !== this.currentView[optionName]) {
return this.currentView[optionName]
}
return this.model[optionName]
}
getAppointmentRenderingStrategyName() {
var {
renderingStrategy: renderingStrategy
} = VIEW_RENDERING_CONFIG[this.currentViewType];
return renderingStrategy
}
}