UNPKG

big-scheduler

Version:

Big scheduler is a powerful and intuitive scheduler and resource planning solution built with React. Seamlessly integrate this modern browser-compatible component into your applications to effectively manage time, appointments, and resources. With drag-a

128 lines (115 loc) 4.39 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _react = _interopRequireDefault(require("react")); var _propTypes = _interopRequireDefault(require("prop-types")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } // import React from 'react'; // import PropTypes from 'prop-types'; // function BodyView({ schedulerData }) { // const { renderData, headers, config, behaviors } = schedulerData; // const width = schedulerData.getContentCellWidth(); // console.log('headers ',headers) // const tableRows = renderData // .filter(o => o.render) // .map(({ slotId, groupOnly, rowHeight }) => { // const rowCells = headers.map((header, index) => { // const key = `${slotId}_${header.time}`; // const style = index === headers.length - 1 ? {} : { width }; // if (header.nonWorkingTime) { // style.backgroundColor = config.nonWorkingTimeBodyBgColor; // } // if (groupOnly) { // style.backgroundColor = config.groupOnlySlotColor; // } // if (behaviors.getNonAgendaViewBodyCellBgColorFunc) { // const cellBgColor = behaviors.getNonAgendaViewBodyCellBgColorFunc(schedulerData, slotId, header); // if (cellBgColor) { // style.backgroundColor = cellBgColor; // } // } // return ( // <td key={key} style={style}> // <div /> // </td> // ); // }); // return ( // <tr key={slotId} style={{ height: rowHeight }}> // {rowCells} // </tr> // ); // }); // return <tbody>{tableRows}</tbody>; // } // BodyView.propTypes = { // schedulerData: PropTypes.object.isRequired, // }; // export default BodyView; function BodyView(_ref) { var schedulerData = _ref.schedulerData; var renderData = schedulerData.renderData, headers = schedulerData.headers, config = schedulerData.config, behaviors = schedulerData.behaviors, resources = schedulerData.resources; var width = schedulerData.getContentCellWidth(); // Utility function to get holidays for a specific resource ID var getHolidays = function getHolidays(resourceId) { var resource = resources.find(function (r) { return r.id === resourceId; }); return resource ? resource.holidays || [] : []; }; var tableRows = renderData.filter(function (o) { return o.render; }).map(function (_ref2) { var slotId = _ref2.slotId, groupOnly = _ref2.groupOnly, rowHeight = _ref2.rowHeight; var holidays = getHolidays(slotId); // Get holidays for the current resource var rowCells = headers.map(function (header, index) { var key = "".concat(slotId, "_").concat(header.time); var style = index === headers.length - 1 ? {} : { width: width }; // Apply background color based on the configuration and behaviors if (header.nonWorkingTime) { style.backgroundColor = config.nonWorkingTimeBodyBgColor; } if (groupOnly) { style.backgroundColor = config.groupOnlySlotColor; } if (behaviors.getNonAgendaViewBodyCellBgColorFunc) { var cellBgColor = behaviors.getNonAgendaViewBodyCellBgColorFunc(schedulerData, slotId, header); if (cellBgColor) { style.backgroundColor = cellBgColor; } } // Determine if the header date matches any holiday date var cellDate = header.time.slice(0, 10); var isHoliday = holidays.includes(cellDate); // const holidayIndicator = isHoliday ? <span className="weekend" title="Holiday"></span> : null; var cellClass = isHoliday ? "weekend" : ""; return /*#__PURE__*/_react["default"].createElement("td", { key: key, style: style, className: cellClass }, /*#__PURE__*/_react["default"].createElement("div", null, isHoliday)); }); return /*#__PURE__*/_react["default"].createElement("tr", { key: slotId, style: { height: rowHeight } }, rowCells); }); return /*#__PURE__*/_react["default"].createElement("tbody", null, tableRows); } BodyView.propTypes = { schedulerData: _propTypes["default"].object.isRequired }; var _default = exports["default"] = BodyView; //# sourceMappingURL=BodyView.js.map