devextreme
Version:
JavaScript/TypeScript Component Suite for Responsive Web Development
88 lines (87 loc) • 3.27 kB
JavaScript
/**
* DevExtreme (esm/__internal/scheduler/scheduler_options_base_widget.js)
* Version: 25.2.5
* Build date: Fri Feb 20 2026
*
* Copyright (c) 2012 - 2026 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
import Widget from "../../ui/widget/ui.widget";
import {
extend
} from "../core/utils/m_extend";
import timeZoneUtils from "./m_utils_time_zone";
import {
DEFAULT_SCHEDULER_INTEGRATION_OPTIONS,
DEFAULT_SCHEDULER_INTERNAL_OPTIONS,
DEFAULT_SCHEDULER_OPTIONS,
DEFAULT_SCHEDULER_OPTIONS_RULES
} from "./utils/options/constants";
import {
getCurrentView,
getViewOption,
getViews
} from "./utils/options/utils";
import {
SchedulerOptionsValidator,
SchedulerOptionsValidatorErrorsHandler
} from "./utils/options_validator/index";
export class SchedulerOptionsBaseWidget extends Widget {
constructor() {
super(...arguments);
this.views = []
}
_init() {
super._init();
this.optionsValidator = new SchedulerOptionsValidator;
this.optionsValidatorErrorHandler = new SchedulerOptionsValidatorErrorsHandler
}
_getDefaultOptions() {
const options = super._getDefaultOptions();
return extend(true, options, Object.assign({}, DEFAULT_SCHEDULER_OPTIONS, DEFAULT_SCHEDULER_INTERNAL_OPTIONS, DEFAULT_SCHEDULER_INTEGRATION_OPTIONS))
}
_defaultOptionsRules() {
const rules = super._defaultOptionsRules();
return rules.concat(DEFAULT_SCHEDULER_OPTIONS_RULES)
}
updateViews() {
const views = this.option("views") ?? [];
this.views = getViews(views);
this.currentView = getCurrentView(this.option("currentView") ?? "", views)
}
_initMarkup() {
super._initMarkup();
this.updateViews();
this.validateOptions()
}
schedulerOptionChanged(args) {
switch (args.name) {
case "currentView":
case "views":
this.updateViews()
}
this.validateOptions()
}
validateOptions() {
const currentViewOptions = Object.assign({}, this.option(), {
startDayHour: this.getViewOption("startDayHour"),
endDayHour: this.getViewOption("endDayHour"),
offset: this.getViewOption("offset"),
cellDuration: this.getViewOption("cellDuration")
});
const validationResult = this.optionsValidator.validate(currentViewOptions);
this.optionsValidatorErrorHandler.handleValidationResult(validationResult)
}
getTimeZone() {
return (this.option("timeZone") || timeZoneUtils.getMachineTimezoneName()) ?? "Etc/UTC"
}
getViewOption(optionName) {
var _this$currentView;
const viewOptionValue = null === (_this$currentView = this.currentView) || void 0 === _this$currentView ? void 0 : _this$currentView[optionName];
const optionValue = viewOptionValue ?? this.option(optionName);
return getViewOption(optionName, optionValue)
}
hasAgendaView() {
return this.views.some((view => "agenda" === view.type || "agenda" === view.name))
}
}