devextreme
Version:
JavaScript/TypeScript Component Suite for Responsive Web Development
103 lines (101 loc) • 4.16 kB
JavaScript
/**
* DevExtreme (cjs/__internal/scheduler/appointment_popup/utils.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/
*/
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getStartDateCommonConfig = exports.createFormIconTemplate = exports.RecurrenceRule = void 0;
var _renderer = _interopRequireDefault(require("../../../core/renderer"));
var _date = _interopRequireDefault(require("../../../core/utils/date"));
var _type = require("../../../core/utils/type");
var _base = require("../recurrence/base");
var _days_from_by_day_rule = require("../recurrence/days_from_by_day_rule");
function _interopRequireDefault(e) {
return e && e.__esModule ? e : {
default: e
}
}
const createFormIconTemplate = iconName => {
if (0 === iconName.length) {
return () => (0, _renderer.default)("<div>").addClass("dx-scheduler-form-icon-sized-gap")
}
return () => (0, _renderer.default)("<i>").addClass("dx-icon").addClass(`dx-icon-${iconName}`)
};
exports.createFormIconTemplate = createFormIconTemplate;
const getStartDateCommonConfig = firstDayOfWeek => ({
colSpan: 1,
itemType: "simple",
editorType: "dxDateBox",
validationRules: [{
type: "required"
}],
editorOptions: {
type: "date",
useMaskBehavior: true,
calendarOptions: {
firstDayOfWeek: firstDayOfWeek,
showTodayButton: true
}
}
});
exports.getStartDateCommonConfig = getStartDateCommonConfig;
class RecurrenceRule {
constructor(rule, startDate) {
var _recurrenceRule$freq, _this$startDate;
this.startDate = null;
this.frequency = null;
const recurrenceRule = (0, _base.parseRecurrenceRule)(rule);
const todayEnd = _date.default.setToDayEnd(new Date);
this.startDate = startDate;
this.frequency = (null === (_recurrenceRule$freq = recurrenceRule.freq) || void 0 === _recurrenceRule$freq ? void 0 : _recurrenceRule$freq.toLowerCase()) ?? null;
this.interval = recurrenceRule.interval ?? 1;
this.until = recurrenceRule.until ?? todayEnd;
this.count = recurrenceRule.count ?? 1;
this.byDay = (0, _days_from_by_day_rule.daysFromByDayRule)(recurrenceRule);
this.byMonthDay = recurrenceRule.bymonthday ? Number(recurrenceRule.bymonthday) : (null === startDate || void 0 === startDate ? void 0 : startDate.getDate()) ?? 1;
this.byMonth = recurrenceRule.bymonth ? Number(recurrenceRule.bymonth) : ((null === (_this$startDate = this.startDate) || void 0 === _this$startDate ? void 0 : _this$startDate.getMonth()) ?? 0) + 1;
this.repeatEnd = "never";
if ((0, _type.isDefined)(recurrenceRule.count)) {
this.repeatEnd = "count"
} else if ((0, _type.isDefined)(recurrenceRule.until)) {
this.repeatEnd = "until"
}
}
toString() {
if (!this.frequency) {
return
}
const rule = {
freq: this.frequency,
interval: this.interval
};
if ("until" === this.repeatEnd && this.until) {
rule.until = this.until
} else if ("count" === this.repeatEnd && this.count) {
rule.count = this.count
}
switch (this.frequency) {
case "weekly":
rule.byday = this.byDay.join(",");
break;
case "monthly":
if (this.byMonthDay) {
rule.bymonthday = String(this.byMonthDay)
}
break;
case "yearly":
if (this.byMonthDay && this.byMonth) {
rule.bymonthday = String(this.byMonthDay);
rule.bymonth = String(this.byMonth)
}
}
return (0, _base.getRecurrenceString)(rule)
}
}
exports.RecurrenceRule = RecurrenceRule;