devextreme
Version:
HTML5 JavaScript Component Suite for Responsive Web Development
238 lines (228 loc) • 9.14 kB
JavaScript
/**
* DevExtreme (cjs/__internal/scheduler/workspaces/m_work_space_month.js)
* Version: 23.2.6
* Build date: Wed May 01 2024
*
* Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _component_registrator = _interopRequireDefault(require("../../../core/component_registrator"));
var _common = require("../../../core/utils/common");
var _date = _interopRequireDefault(require("../../../core/utils/date"));
var _position = require("../../../core/utils/position");
var _window = require("../../../core/utils/window");
var _index = require("../../scheduler/r1/components/index");
var _index2 = require("../../scheduler/r1/utils/index");
var _m_constants = require("../m_constants");
var _m_utils = require("../m_utils");
var _m_work_space_indicator = _interopRequireDefault(require("./m_work_space_indicator"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
}
}
function _extends() {
_extends = Object.assign ? Object.assign.bind() : function(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key]
}
}
}
return target
};
return _extends.apply(this, arguments)
}
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, _toPropertyKey(descriptor.key), descriptor)
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) {
_defineProperties(Constructor.prototype, protoProps)
}
if (staticProps) {
_defineProperties(Constructor, staticProps)
}
Object.defineProperty(Constructor, "prototype", {
writable: false
});
return Constructor
}
function _toPropertyKey(arg) {
var key = _toPrimitive(arg, "string");
return "symbol" === typeof key ? key : String(key)
}
function _toPrimitive(input, hint) {
if ("object" !== typeof input || null === input) {
return input
}
var prim = input[Symbol.toPrimitive];
if (void 0 !== prim) {
var res = prim.call(input, hint || "default");
if ("object" !== typeof res) {
return res
}
throw new TypeError("@@toPrimitive must return a primitive value.")
}
return ("string" === hint ? String : Number)(input)
}
function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
_setPrototypeOf(subClass, superClass)
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(o, p) {
o.__proto__ = p;
return o
};
return _setPrototypeOf(o, p)
}
const MONTH_CLASS = "dx-scheduler-work-space-month";
const DATE_TABLE_CURRENT_DATE_CLASS = "dx-scheduler-date-table-current-date";
const DATE_TABLE_CELL_TEXT_CLASS = "dx-scheduler-date-table-cell-text";
const DATE_TABLE_FIRST_OF_MONTH_CLASS = "dx-scheduler-date-table-first-of-month";
const DATE_TABLE_OTHER_MONTH_DATE_CLASS = "dx-scheduler-date-table-other-month";
const toMs = _date.default.dateToMilliseconds;
let SchedulerWorkSpaceMonth = function(_SchedulerWorkSpace) {
_inheritsLoose(SchedulerWorkSpaceMonth, _SchedulerWorkSpace);
function SchedulerWorkSpaceMonth() {
return _SchedulerWorkSpace.apply(this, arguments) || this
}
var _proto = SchedulerWorkSpaceMonth.prototype;
_proto._getElementClass = function() {
return MONTH_CLASS
};
_proto._getFormat = function() {
return _index2.formatWeekday
};
_proto._getIntervalBetween = function(currentDate) {
const firstViewDate = this.getStartViewDate();
const timeZoneOffset = _date.default.getTimezonesDifference(firstViewDate, currentDate);
return currentDate.getTime() - (firstViewDate.getTime() - 36e5 * this.option("startDayHour")) - timeZoneOffset
};
_proto._getDateGenerationOptions = function() {
return _extends(_extends({}, _SchedulerWorkSpace.prototype._getDateGenerationOptions.call(this)), {
cellCountInDay: 1
})
};
_proto.getCellWidth = function() {
return this.cache.get("cellWidth", () => {
let averageWidth = 0;
const cells = this._getCells().slice(0, 7);
cells.each((index, element) => {
averageWidth += (0, _window.hasWindow)() ? (0, _position.getBoundingRect)(element).width : 0
});
return 0 === cells.length ? void 0 : averageWidth / 7
})
};
_proto._insertAllDayRowsIntoDateTable = function() {
return false
};
_proto._getCellCoordinatesByIndex = function(index) {
const rowIndex = Math.floor(index / this._getCellCount());
const columnIndex = index - this._getCellCount() * rowIndex;
return {
rowIndex: rowIndex,
columnIndex: columnIndex
}
};
_proto._needCreateCrossScrolling = function() {
return this.option("crossScrollingEnabled") || this._isVerticalGroupedWorkSpace()
};
_proto._getViewStartByOptions = function() {
return _index2.monthUtils.getViewStartByOptions(this.option("startDate"), this.option("currentDate"), this.option("intervalCount"), _date.default.getFirstMonthDate(this.option("startDate")))
};
_proto._updateIndex = function(index) {
return index
};
_proto.isIndicationAvailable = function() {
return false
};
_proto.getIntervalDuration = function() {
return toMs("day")
};
_proto.getTimePanelWidth = function() {
return 0
};
_proto.supportAllDayRow = function() {
return false
};
_proto.keepOriginalHours = function() {
return true
};
_proto.getWorkSpaceLeftOffset = function() {
return 0
};
_proto.needApplyCollectorOffset = function() {
return true
};
_proto._getHeaderDate = function() {
return this._getViewStartByOptions()
};
_proto.scrollToTime = function() {
return (0, _common.noop)()
};
_proto.renderRAllDayPanel = function() {};
_proto.renderRTimeTable = function() {};
_proto.renderRDateTable = function() {
_m_utils.utils.renovation.renderComponent(this, this._$dateTable, _index.DateTableMonthComponent, "renovatedDateTable", this._getRDateTableProps())
};
_proto._createWorkSpaceElements = function() {
if (this._isVerticalGroupedWorkSpace()) {
this._createWorkSpaceScrollableElements()
} else {
_SchedulerWorkSpace.prototype._createWorkSpaceElements.call(this)
}
};
_proto._toggleAllDayVisibility = function() {
return (0, _common.noop)()
};
_proto._changeAllDayVisibility = function() {
return (0, _common.noop)()
};
_proto._renderTimePanel = function() {
return (0, _common.noop)()
};
_proto._renderAllDayPanel = function() {
return (0, _common.noop)()
};
_proto._setMonthClassesToCell = function($cell, data) {
$cell.toggleClass(DATE_TABLE_CURRENT_DATE_CLASS, data.isCurrentDate).toggleClass(DATE_TABLE_FIRST_OF_MONTH_CLASS, data.firstDayOfMonth).toggleClass(DATE_TABLE_OTHER_MONTH_DATE_CLASS, data.otherMonth)
};
_proto._createAllDayPanelElements = function() {};
_proto._renderTableBody = function(options) {
options.getCellText = (rowIndex, columnIndex) => {
const date = this.viewDataProvider.completeViewDataMap[rowIndex][columnIndex].startDate;
return _index2.monthUtils.getCellText(date, this.option("intervalCount"))
};
options.getCellTextClass = DATE_TABLE_CELL_TEXT_CLASS;
options.setAdditionalClasses = this._setMonthClassesToCell.bind(this);
_SchedulerWorkSpace.prototype._renderTableBody.call(this, options)
};
_createClass(SchedulerWorkSpaceMonth, [{
key: "type",
get: function() {
return _m_constants.VIEWS.MONTH
}
}]);
return SchedulerWorkSpaceMonth
}(_m_work_space_indicator.default);
(0, _component_registrator.default)("dxSchedulerWorkSpaceMonth", SchedulerWorkSpaceMonth);
var _default = SchedulerWorkSpaceMonth;
exports.default = _default;