@cwellt_software/cwellt-reactjs-lib 1.5.1 → 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/dist/content/fonts/roboto-mono/LICENSE +93 -93
  2. package/dist/content/fonts/roboto-mono/RobotoMono.css +43 -43
  3. package/dist/index.cjs.js +12 -1390
  4. package/dist/index.css +2 -2
  5. package/dist/index.d.ts +17 -216
  6. package/dist/index.es.js +14 -1387
  7. package/dist/src/components/control/input/color/CwInputColor.d.ts +2 -0
  8. package/dist/src/components/control/input/color/CwInputColor.d.ts.map +1 -1
  9. package/dist/src/components/control/input/digit/CwDigit.d.ts +6 -0
  10. package/dist/src/components/control/input/digit/CwDigit.d.ts.map +1 -1
  11. package/dist/src/index.d.ts +0 -8
  12. package/dist/src/index.d.ts.map +1 -1
  13. package/package.json +3 -3
  14. package/dist/content/fonts/roboto/LICENSE.txt +0 -202
  15. package/dist/content/fonts/roboto/Roboto-Black.ttf +0 -0
  16. package/dist/content/fonts/roboto/Roboto-BlackItalic.ttf +0 -0
  17. package/dist/content/fonts/roboto/Roboto-Bold.ttf +0 -0
  18. package/dist/content/fonts/roboto/Roboto-BoldItalic.ttf +0 -0
  19. package/dist/content/fonts/roboto/Roboto-Italic.ttf +0 -0
  20. package/dist/content/fonts/roboto/Roboto-Light.ttf +0 -0
  21. package/dist/content/fonts/roboto/Roboto-LightItalic.ttf +0 -0
  22. package/dist/content/fonts/roboto/Roboto-Medium.ttf +0 -0
  23. package/dist/content/fonts/roboto/Roboto-MediumItalic.ttf +0 -0
  24. package/dist/content/fonts/roboto/Roboto-Regular.ttf +0 -0
  25. package/dist/content/fonts/roboto/Roboto-Thin.ttf +0 -0
  26. package/dist/content/fonts/roboto/Roboto-ThinItalic.ttf +0 -0
  27. package/dist/content/fonts/roboto/RobotoFontFamily.css +0 -109
  28. package/dist/content/fonts/roboto-flex/README.md +0 -24
  29. package/dist/content/fonts/roboto-flex/files/roboto-flex-latin-ext-grad-normal.woff2 +0 -0
  30. package/dist/content/fonts/roboto-flex/files/roboto-flex-latin-ext-opsz-normal.woff2 +0 -0
  31. package/dist/content/fonts/roboto-flex/files/roboto-flex-latin-ext-slnt-normal.woff2 +0 -0
  32. package/dist/content/fonts/roboto-flex/files/roboto-flex-latin-ext-standard-normal.woff2 +0 -0
  33. package/dist/content/fonts/roboto-flex/files/roboto-flex-latin-ext-wdth-normal.woff2 +0 -0
  34. package/dist/content/fonts/roboto-flex/files/roboto-flex-latin-ext-wght-normal.woff2 +0 -0
  35. package/dist/content/fonts/roboto-flex/files/roboto-flex-latin-ext-xopq-normal.woff2 +0 -0
  36. package/dist/content/fonts/roboto-flex/files/roboto-flex-latin-ext-xtra-normal.woff2 +0 -0
  37. package/dist/content/fonts/roboto-flex/files/roboto-flex-latin-ext-yopq-normal.woff2 +0 -0
  38. package/dist/content/fonts/roboto-flex/files/roboto-flex-latin-ext-ytas-normal.woff2 +0 -0
  39. package/dist/content/fonts/roboto-flex/files/roboto-flex-latin-ext-ytde-normal.woff2 +0 -0
  40. package/dist/content/fonts/roboto-flex/files/roboto-flex-latin-ext-ytfi-normal.woff2 +0 -0
  41. package/dist/content/fonts/roboto-flex/files/roboto-flex-latin-ext-ytlc-normal.woff2 +0 -0
  42. package/dist/content/fonts/roboto-flex/files/roboto-flex-latin-ext-ytuc-normal.woff2 +0 -0
  43. package/dist/content/fonts/roboto-flex/files/roboto-flex-latin-grad-normal.woff2 +0 -0
  44. package/dist/content/fonts/roboto-flex/files/roboto-flex-latin-opsz-normal.woff2 +0 -0
  45. package/dist/content/fonts/roboto-flex/files/roboto-flex-latin-slnt-normal.woff2 +0 -0
  46. package/dist/content/fonts/roboto-flex/files/roboto-flex-latin-standard-normal.woff2 +0 -0
  47. package/dist/content/fonts/roboto-flex/files/roboto-flex-latin-wdth-normal.woff2 +0 -0
  48. package/dist/content/fonts/roboto-flex/files/roboto-flex-latin-wght-normal.woff2 +0 -0
  49. package/dist/content/fonts/roboto-flex/files/roboto-flex-latin-xopq-normal.woff2 +0 -0
  50. package/dist/content/fonts/roboto-flex/files/roboto-flex-latin-xtra-normal.woff2 +0 -0
  51. package/dist/content/fonts/roboto-flex/files/roboto-flex-latin-yopq-normal.woff2 +0 -0
  52. package/dist/content/fonts/roboto-flex/files/roboto-flex-latin-ytas-normal.woff2 +0 -0
  53. package/dist/content/fonts/roboto-flex/files/roboto-flex-latin-ytde-normal.woff2 +0 -0
  54. package/dist/content/fonts/roboto-flex/files/roboto-flex-latin-ytfi-normal.woff2 +0 -0
  55. package/dist/content/fonts/roboto-flex/files/roboto-flex-latin-ytlc-normal.woff2 +0 -0
  56. package/dist/content/fonts/roboto-flex/files/roboto-flex-latin-ytuc-normal.woff2 +0 -0
  57. package/dist/content/fonts/roboto-flex/grad.css +0 -19
  58. package/dist/content/fonts/roboto-flex/index.css +0 -19
  59. package/dist/content/fonts/roboto-flex/metadata.json +0 -33
  60. package/dist/content/fonts/roboto-flex/opsz.css +0 -19
  61. package/dist/content/fonts/roboto-flex/slnt.css +0 -19
  62. package/dist/content/fonts/roboto-flex/standard.css +0 -21
  63. package/dist/content/fonts/roboto-flex/unicode.json +0 -4
  64. package/dist/content/fonts/roboto-flex/wdth.css +0 -21
  65. package/dist/content/fonts/roboto-flex/wght.css +0 -20
  66. package/dist/content/fonts/roboto-flex/xopq.css +0 -20
  67. package/dist/content/fonts/roboto-flex/xtra.css +0 -19
  68. package/dist/content/fonts/roboto-flex/yopq.css +0 -19
  69. package/dist/content/fonts/roboto-flex/ytas.css +0 -19
  70. package/dist/content/fonts/roboto-flex/ytde.css +0 -20
  71. package/dist/content/fonts/roboto-flex/ytfi.css +0 -20
  72. package/dist/content/fonts/roboto-flex/ytlc.css +0 -19
  73. package/dist/content/fonts/roboto-flex/ytuc.css +0 -20
  74. package/dist/content/icons/new-cw-icons/NewCwIcons.html +0 -415
package/dist/index.es.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import * as React from 'react';
3
- import React__default, { useState, useRef, useEffect, useCallback, useLayoutEffect, createContext, useContext, cloneElement, useMemo, forwardRef, useImperativeHandle, useId, createElement, memo, Fragment as Fragment$1, Component } from 'react';
3
+ import React__default, { useState, useRef, useEffect, useCallback, useLayoutEffect, createContext, useContext, cloneElement, useMemo, forwardRef, useId, useImperativeHandle, createElement, memo } from 'react';
4
4
  import { createPortal } from 'react-dom';
5
5
  import { createRoot } from 'react-dom/client';
6
6
  import Draggable from 'react-draggable';
@@ -3233,8 +3233,14 @@ function CwInput(CwInputProps) {
3233
3233
  * ```
3234
3234
  */
3235
3235
  function CwDigit(props) {
3236
- const { alignProps, buttonProps, iconProps, labelProps, ...inputProps } = props;
3237
- return (jsx("div", { className: "cw-input-text", children: jsxs(CwAlign, { ...alignProps, itemProp: inputProps.required === true ? "required" : "", children: [labelProps && (jsxs(CwLabel, { ...labelProps, children: [iconProps && jsx(CwIcon, { ...iconProps }), labelProps.text] })), jsx("input", { type: "number", ...inputProps }), buttonProps && jsx(CwButton, { ...buttonProps })] }) }));
3236
+ const { alignProps, buttonProps, iconProps, labelProps, feedback, ...inputProps } = props;
3237
+ const feedbackMessages = feedback
3238
+ ? Array.isArray(feedback) ? feedback : [feedback]
3239
+ : [];
3240
+ const feedbackId = useId();
3241
+ const feedbackIds = feedbackMessages.map((_, index) => `${feedbackId}-${index}`);
3242
+ const describedBy = [inputProps["aria-describedby"], ...feedbackIds].filter(Boolean).join(" ") || undefined;
3243
+ return (jsxs("div", { className: "cw-input-text", children: [jsxs(CwAlign, { ...alignProps, itemProp: inputProps.required === true ? "required" : "", children: [labelProps && (jsxs(CwLabel, { ...labelProps, children: [iconProps && jsx(CwIcon, { ...iconProps }), labelProps.text] })), jsx("input", { type: "number", ...inputProps, "aria-describedby": describedBy }), buttonProps && jsx(CwButton, { ...buttonProps })] }), feedbackMessages.map((feedbackItem, index) => (jsx("p", { id: feedbackIds[index], className: "cw-input-info", "data-color": feedbackItem.type, "aria-live": "polite", children: feedbackItem.message }, index)))] }));
3238
3244
  }
3239
3245
 
3240
3246
  var styles$j = {"colorPreview":"cw-color-picker-module__colorPreview__ylJcD","hueBar":"cw-color-picker-module__hueBar__bFhyC","hueBarSlider":"cw-color-picker-module__hueBarSlider__D53IV","colorPickerInteractiveArea":"cw-color-picker-module__colorPickerInteractiveArea__KZFR1","colorArea":"cw-color-picker-module__colorArea__xgpSE","colorAreaOverlay":"cw-color-picker-module__colorAreaOverlay__pmgOc","hueBackground":"cw-color-picker-module__hueBackground__Mks78","whiteGradient":"cw-color-picker-module__whiteGradient__Bt-fU","blackGradient":"cw-color-picker-module__blackGradient__VnEKJ","colorAreaCursor":"cw-color-picker-module__colorAreaCursor__lotg3"};
@@ -3448,7 +3454,7 @@ const CwColorPicker = ({ initialColor, onChange, previewText = "Color preview" }
3448
3454
 
3449
3455
  var styles$i = {"container":"cw-input-color-module__container__x7gpk","selectColor":"cw-input-color-module__selectColor__DTo3V","disabled":"cw-input-color-module__disabled__O1fK5","readOnly":"cw-input-color-module__readOnly__HL-Bz","colorDropdown":"cw-input-color-module__colorDropdown__pX2bc"};
3450
3456
 
3451
- const CwInputColor = ({ value, onChange, previewText = "Color preview", disabled = false, readOnly = false, width = '4rem', height = '2rem', labelProps, layoutProps, }) => {
3457
+ const CwInputColor = ({ value, onChange, previewText = "Color preview", disabled = false, readOnly = false, width = '4rem', height = '2rem', labelProps, layoutProps, className, style, }) => {
3452
3458
  const [isOpen, setIsOpen] = useState(false);
3453
3459
  const containerRef = useRef(null);
3454
3460
  const dropdownRef = useRef(null);
@@ -3579,7 +3585,7 @@ const CwInputColor = ({ value, onChange, previewText = "Color preview", disabled
3579
3585
  break;
3580
3586
  }
3581
3587
  };
3582
- return (jsxs("div", { className: `cw-input-color ${styles$i.container}`, "data-direction": layoutProps?.direction ?? "row", "data-align": layoutProps?.align, children: [labelProps && (jsx(CwLabel, { ...labelProps })), jsx("div", { ref: containerRef, onClick: handleToggle, className: `${styles$i.selectColor} ${disabled ? styles$i.disabled : ''} ${readOnly ? styles$i.readOnly : ''}`, style: {
3588
+ return (jsxs("div", { className: `cw-input-color ${styles$i.container}${className ? ` ${className}` : ''}`, style: style, "data-direction": layoutProps?.direction ?? "row", "data-align": layoutProps?.align, children: [labelProps && (jsx(CwLabel, { ...labelProps })), jsx("div", { ref: containerRef, onClick: handleToggle, className: `${styles$i.selectColor} ${disabled ? styles$i.disabled : ''} ${readOnly ? styles$i.readOnly : ''}`, style: {
3583
3589
  width,
3584
3590
  height,
3585
3591
  backgroundColor: value,
@@ -8653,1066 +8659,6 @@ function CwDateRangePickerTemporal({ value, onChange, minDate, maxDate, disabled
8653
8659
  } })] }), jsx("div", { role: "alert", "aria-live": "polite", className: rangeStyles.rangeError, children: rangeErrorMessage })] }))] })] }) }));
8654
8660
  }
8655
8661
 
8656
- const ResourcesTitleList = ({ resources, canBePinned, includesPinned, onCrewPinning, onClickResourceContextMenu, ResourceTitleComponent, }) => {
8657
- const onClickContextMenu = useCallback((key, resource) => {
8658
- if (onClickResourceContextMenu) {
8659
- onClickResourceContextMenu(key, resource);
8660
- }
8661
- }, []);
8662
- return (jsx("td", { className: "resourceArea", style: { width: "100px" }, children: resources.map((r, _i) => (jsxs("div", { className: "resource CwelltFunctionDescription", style: { height: r.maxTop }, children: [(canBePinned || includesPinned) && (jsx(PinButton, { canBePinned: canBePinned, resource: r, onCrewPinning: onCrewPinning })), jsx(ResourceTitleComponent, { resource: r, handleOnClickResourceContextMenu: onClickContextMenu })] }, r.id.toString()))) }));
8663
- };
8664
- const PinButton = ({ canBePinned, resource, onCrewPinning }) => {
8665
- const buttonProps = canBePinned
8666
- ? {
8667
- id: "cbl_pinL",
8668
- onClick: () => onCrewPinning(resource, ""),
8669
- children: jsx("span", { className: "cwi-pin", style: { visibility: "visible" } }),
8670
- }
8671
- : {
8672
- id: "cbl_pinLess45deg",
8673
- onClick: () => onCrewPinning(resource, "remove"),
8674
- children: jsx("span", { className: "cwi-pinned cwi-pin", style: { visibility: "visible" } }),
8675
- };
8676
- return jsx("button", { className: "cw-button-icon cw-icon-pin", ...buttonProps });
8677
- };
8678
-
8679
- const addMinutesToDateFromPx = (originalDate, leftPx, minutesPerPx) => {
8680
- const minutes = leftPx / minutesPerPx;
8681
- const datePlusMinutes = new Date(originalDate.getTime() + minutes * 60000);
8682
- return datePlusMinutes;
8683
- };
8684
-
8685
- const doubleClickOnResource = (props, resource) => {
8686
- if (props.scheduler_handleDblClickOnResourceInScheduler) {
8687
- props.scheduler_handleDblClickOnResourceInScheduler(resource);
8688
- }
8689
- };
8690
-
8691
- let CblDragAndDrop$1 = class CblDragAndDrop {
8692
- fromId;
8693
- toId;
8694
- data;
8695
- droppedOnDate;
8696
- resizeFromStart;
8697
- resizeFromEnd;
8698
- isCtrlKey;
8699
- constructor(fromId, toId, data, droppedOnDate = null, resizeFromStart = null, resizeFromEnd = null, isCtrlKey = null) {
8700
- this.fromId = fromId;
8701
- this.toId = toId;
8702
- this.data = data;
8703
- this.droppedOnDate = droppedOnDate;
8704
- this.resizeFromStart = resizeFromStart;
8705
- this.resizeFromEnd = resizeFromEnd;
8706
- this.isCtrlKey = isCtrlKey;
8707
- }
8708
- };
8709
-
8710
- const BIRTHDATE = 15;
8711
- const NOT_WORKING = 16;
8712
- const REST_TIME = 10;
8713
- const MAX_FLIGHT_DUTY_PERIOD = 11;
8714
- const DUTY_REGULATION = 20;
8715
- const unHandleableEvents = [REST_TIME, MAX_FLIGHT_DUTY_PERIOD, NOT_WORKING, DUTY_REGULATION];
8716
- const getEventStyle = (event, reslTime) => {
8717
- const baseStyle = {
8718
- left: event.leftPx,
8719
- width: event.width,
8720
- top: event.top,
8721
- overflow: "hidden",
8722
- zIndex: event.isFullHeight ? 4 : 5,
8723
- };
8724
- if (event.data.eventType === BIRTHDATE) {
8725
- return {
8726
- ...baseStyle,
8727
- height: event.isFullHeight ? "100%" : "auto",
8728
- marginTop: event.isFullHeight ? -1 * event.top : 0,
8729
- pointerEvents: "none",
8730
- borderBottom: "solid 1px rgba(0, 0, 0, 0.4)",
8731
- backgroundColor: event.data.category.color || "orange",
8732
- display: "flex",
8733
- opacity: 0.3,
8734
- alignItems: "flex-end",
8735
- };
8736
- }
8737
- if ([REST_TIME, MAX_FLIGHT_DUTY_PERIOD, DUTY_REGULATION].includes(event.data.eventType)) {
8738
- return {
8739
- ...baseStyle,
8740
- zIndex: event.isFullHeight ? 4 : 6,
8741
- marginTop: event.isFullHeight ? -1 * event.top : 0,
8742
- borderRadius: "0px",
8743
- backgroundColor: event.data.category.color || "grey",
8744
- opacity: 0.3,
8745
- borderBottom: event.data.eventType === DUTY_REGULATION ? "solid 1px rgba(0, 0, 0, 0.4)" : "",
8746
- };
8747
- }
8748
- return {
8749
- ...baseStyle,
8750
- height: event.isFullHeight ? "100%" : "auto",
8751
- marginTop: event.isFullHeight ? -1 * event.top : 0,
8752
- borderRadius: reslTime <= 0.99 ? "3px" : "5px",
8753
- minWidth: reslTime <= 1.5 ? "5px" : "",
8754
- maxWidth: reslTime <= 1.5 ? "25px" : "",
8755
- };
8756
- };
8757
- const EventRender = ({ event, schedulerProps }) => {
8758
- const dateStart = new Date(event.data.start);
8759
- const dateEnd = new Date(event.data.end);
8760
- const reslTime = (dateEnd.getTime() - dateStart.getTime()) / 3600000;
8761
- const eventStyle = getEventStyle(event, reslTime);
8762
- const onClickEvent = (e) => {
8763
- if (!unHandleableEvents.includes(event.data.eventType)) {
8764
- e.stopPropagation();
8765
- const props = schedulerProps;
8766
- props.scheduler_handleCblEventClick.call(props.parent, event, schedulerProps.id);
8767
- }
8768
- };
8769
- const onRightClickEvent = (e) => {
8770
- if (!unHandleableEvents.includes(event.data.eventType)) {
8771
- e.stopPropagation();
8772
- const props = schedulerProps;
8773
- if (props.scheduler_handleCblEventClickRight) {
8774
- props.scheduler_handleCblEventClickRight.call(props.parent, event, schedulerProps.id);
8775
- }
8776
- }
8777
- };
8778
- const safeHandleDragStart = (e, isLeft, isRight) => {
8779
- if (!unHandleableEvents.includes(event.data.eventType)) {
8780
- handleDragStart(e, isLeft, isRight);
8781
- }
8782
- };
8783
- const handleDragStart = (e, isResizeFromStart, isResizeFromEnd) => {
8784
- if (!unHandleableEvents.includes(event.data.eventType)) {
8785
- [].forEach.call(document.querySelectorAll(".ant-tooltip"), function (el) {
8786
- el.style.visibility = "hidden";
8787
- });
8788
- // We don't know in which case is necessary
8789
- if (e.target !== e.currentTarget) {
8790
- // e.preventDefault();
8791
- return;
8792
- }
8793
- const isResize = isResizeFromStart || isResizeFromEnd;
8794
- const isAllowed = !event.isReadOnly && (isResize ? event.isResizable : event.isDraggable);
8795
- if (!isAllowed) {
8796
- e.preventDefault();
8797
- return;
8798
- }
8799
- const cblDragNDrop = new CblDragAndDrop$1(schedulerProps.id, null, [event], null, isResizeFromStart, isResizeFromEnd);
8800
- if (!isResize) {
8801
- e.dataTransfer.dropEffect = e.ctrlKey ? "copy" : "link";
8802
- }
8803
- e.dataTransfer.setData("data", JSON.stringify(cblDragNDrop));
8804
- }
8805
- };
8806
- const handleDoubleClick = (e) => {
8807
- if (!unHandleableEvents.includes(event.data.eventType)) {
8808
- e.preventDefault();
8809
- e.stopPropagation();
8810
- const props = schedulerProps;
8811
- props.scheduler_handleCblEventDoubleClick.call(props.parent, event, schedulerProps.id);
8812
- }
8813
- };
8814
- const onClickContextMenu = (e) => {
8815
- if (!unHandleableEvents.includes(event.data.eventType)) {
8816
- const props = schedulerProps;
8817
- if (props.scheduler_handleOnClickEventContextMenu) {
8818
- props.scheduler_handleOnClickEventContextMenu(e, event);
8819
- }
8820
- }
8821
- };
8822
- const renderBirthdayEvent = () => (jsxs("div", { className: `fc-timeline-event cwellt_timeline_event cwellt_event_bday ${event.selected ? "cblEventSelected" : ""}`, style: eventStyle, children: [jsx("span", { className: "cwi-icons cwi-birthday", style: { visibility: "visible" } }), event.data.subject && jsx("span", { style: { lineHeight: "1em" }, children: event.data.subject })] }, event.id));
8823
- const renderRegularEvent = () => (jsxs("div", { draggable: ![10, 11, 16, 20, 21].includes(event.data.eventType), className: "fc-timeline-event cwellt_timeline_event " +
8824
- (event.selected === true ? "cblEventSelected " : "") +
8825
- (event.data.eventType === REST_TIME ||
8826
- event.data.eventType === MAX_FLIGHT_DUTY_PERIOD ||
8827
- event.data.eventType === DUTY_REGULATION
8828
- ? " cwellt_event_bhnd_appt "
8829
- : " "), style: eventStyle, onClick: onClickEvent, onContextMenu: onRightClickEvent, onDragStart: (e) => safeHandleDragStart(e, false, false), onDoubleClick: handleDoubleClick, children: [schedulerProps.scheduler_handleCblEventResize &&
8830
- !event.isReadOnly &&
8831
- !unHandleableEvents.includes(event.data.eventType) && (jsx("span", { draggable: true, onDragStart: (e) => handleDragStart(e, true, false), style: {
8832
- position: "absolute",
8833
- cursor: "e-resize",
8834
- zIndex: 10,
8835
- left: "0",
8836
- border: "solid 1px rgba(46,49,49,0.5)",
8837
- }, children: "\u200B" })), jsx(schedulerProps.cblEventComp, { cblEvent: event, handleOnClickEventContextMenu: onClickContextMenu }, event.id), schedulerProps.scheduler_handleCblEventResize &&
8838
- !event.isReadOnly &&
8839
- !unHandleableEvents.includes(event.data.eventType) && (jsx("span", { draggable: true, onDragStart: (e) => handleDragStart(e, false, true), style: {
8840
- position: "absolute",
8841
- right: "0",
8842
- cursor: "e-resize",
8843
- zIndex: 10,
8844
- border: "solid 1px rgba(46,49,49,0.5)",
8845
- marginTop: "-25px",
8846
- }, children: "\u200B" }))] }, event.id));
8847
- const render = event.data.eventType === BIRTHDATE ? renderBirthdayEvent() : renderRegularEvent();
8848
- return render;
8849
- };
8850
-
8851
- const onDropEventToResource = (props, cblDragNDrop, resource) => {
8852
- props.scheduler_handleOnDropCblEventsOnResource.call(props.parent, cblDragNDrop, resource);
8853
- };
8854
-
8855
- const isAllowedToMove = (data, resData, cblDragNDrop) => {
8856
- if (data?.eventType !== 1) {
8857
- return true;
8858
- }
8859
- const allowedMoves = [
8860
- { from: "acftsScheduler", to: "flightsPairingsScheduler" },
8861
- { from: "flightsScheduler", to: "crewAssignmentsScheduler" },
8862
- { from: "opstoolScheduler", to: "opstoolScheduler" },
8863
- { from: "opstoolScheduler", to: "opstoolSchedulerVirtual" },
8864
- { from: "opstoolSchedulerVirtual", to: "opstoolScheduler" },
8865
- { from: "opstoolSchedulerVirtual", to: "opstoolSchedulerVirtual" },
8866
- { from: "vacationsScheduler", to: "vacationsScheduler" }
8867
- ];
8868
- const crewControllAllowedMove = allowedMoves.some(move => move.from === cblDragNDrop.fromId && move.to === cblDragNDrop.toId);
8869
- if (crewControllAllowedMove) {
8870
- return true;
8871
- }
8872
- return data.Crew !== resData.Crewmember_Id;
8873
- };
8874
-
8875
- const OnDrop = ({ e, resource, id, contentArea, state, schedulerProps }) => {
8876
- e.dataTransfer.dropEffect = "move";
8877
- const cblDragNDrop = JSON.parse(e.dataTransfer.getData("data"));
8878
- if (!cblDragNDrop.data || !cblDragNDrop.data[0]) {
8879
- return;
8880
- }
8881
- cblDragNDrop.toId = id;
8882
- const obj = cblDragNDrop.data[0];
8883
- cblDragNDrop.isCtrlKey = e.ctrlKey;
8884
- const isResizeEvent = cblDragNDrop.resizeFromStart === true || cblDragNDrop.resizeFromEnd === true;
8885
- if (isResizeEvent) {
8886
- // Resize
8887
- if (obj.data === undefined || obj.data.eventType === 1) {
8888
- return;
8889
- }
8890
- const _eventX = e.clientX;
8891
- const _caLeft = contentArea?.getBoundingClientRect()?.left ?? 0;
8892
- const leftPos = _eventX - _caLeft;
8893
- let droppedDate = addMinutesToDateFromPx(schedulerProps.startDate, leftPos, state.minutePx);
8894
- if (cblDragNDrop.resizeFromEnd === true) {
8895
- const eventStart = new Date(Date.parse(obj.start));
8896
- droppedDate = droppedDate < eventStart ? eventStart : droppedDate;
8897
- }
8898
- if (cblDragNDrop.resizeFromStart === true) {
8899
- const eventEnd = new Date(Date.parse(obj.end));
8900
- // 3 hours before is the minimun size in the backend
8901
- eventEnd.setHours(eventEnd.getHours() - 3);
8902
- droppedDate = droppedDate > eventEnd ? eventEnd : droppedDate;
8903
- }
8904
- cblDragNDrop.droppedOnDate = droppedDate;
8905
- schedulerProps.scheduler_handleCblEventResize?.call(schedulerProps.parent, cblDragNDrop);
8906
- return;
8907
- }
8908
- // Drag & Drop
8909
- if (!isAllowedToMove(obj.data, resource.data, cblDragNDrop)) {
8910
- return;
8911
- }
8912
- const d = e.clientX - (contentArea?.getBoundingClientRect()?.left ?? 0);
8913
- const date = new Date(schedulerProps.startDate.getTime() + (d / state.minutePx) * 60000);
8914
- cblDragNDrop.droppedOnDate = date;
8915
- onDropEventToResource(schedulerProps, cblDragNDrop, resource);
8916
- };
8917
-
8918
- const onDragOver = (e) => {
8919
- if (e.ctrlKey === true) {
8920
- e.dataTransfer.dropEffect = "copy";
8921
- }
8922
- else {
8923
- e.dataTransfer.dropEffect = "link";
8924
- }
8925
- e.preventDefault();
8926
- };
8927
-
8928
- const arePropsEqual = (prevProps, nextProps) => {
8929
- return prevProps.res.events === nextProps.res.events && prevProps.isInViewport === nextProps.isInViewport;
8930
- };
8931
- const ResourceRender = memo(({ res, schedulerProps, contentArea, state }) => {
8932
- return (jsx("div", { style: {
8933
- backgroundColor: "#F9F8F8",
8934
- height: res.maxTop,
8935
- width: "100%",
8936
- position: "relative",
8937
- borderBottom: "1px solid rgb(255,255,255)",
8938
- }, onDragOver: (e) => onDragOver(e), onDrop: (e) => {
8939
- OnDrop({
8940
- e,
8941
- resource: res,
8942
- id: schedulerProps.id,
8943
- contentArea,
8944
- state,
8945
- schedulerProps,
8946
- });
8947
- }, className: "cwellt_divRow_schContent", children: res.events.map((evnt) => (jsx(EventRender, { event: evnt, schedulerProps: schedulerProps }, evnt.id))) }, res.id));
8948
- }, arePropsEqual);
8949
-
8950
- const ResourceListRender = ({ resources, schedulerProps, state, contentArea,
8951
- // onClickContextMenu,
8952
- crewAssignmentSchedulerContextMenu, }) => {
8953
- return (jsx(Fragment$1, { children: resources.map((r, _i) => (jsx(CwAnchoredMenu, { placement: "bottom", onContextMenu: (e) => {
8954
- // Dirty temporal solution to remove ANT design, this can be killed when this scheduler is deprecated
8955
- const leftPos = e.currentTarget.getBoundingClientRect().left -
8956
- (contentArea?.getBoundingClientRect()?.left ?? 0) -
8957
- window.scrollX;
8958
- const calculatedDatetime = addMinutesToDateFromPx(schedulerProps.startDate, leftPos, state.minutePx);
8959
- r.__contextMenuDatetime = calculatedDatetime;
8960
- }, options: crewAssignmentSchedulerContextMenu?.map(m => ({
8961
- key: m.key,
8962
- label: (jsxs(Fragment, { children: [jsx("span", { className: m.icon, style: { color: m.color } }), jsx("span", { children: m.text })] }))
8963
- })) ?? [], onSelect: (key) => {
8964
- const datetime = r.__contextMenuDatetime ?? new Date();
8965
- if (schedulerProps.scheduler_handleOnClickContextMenuResource) {
8966
- schedulerProps.scheduler_handleOnClickContextMenuResource(datetime, r, key, schedulerProps.id);
8967
- }
8968
- }, children: jsx("span", { onDoubleClick: () => doubleClickOnResource(schedulerProps, r), id: schedulerProps.id + "_" + r.id, children: jsx(ResourceRender, { res: r, schedulerProps: schedulerProps, contentArea: contentArea, state: state, isInViewport: r.isInViewport }, r.id) }) }, r.id))) }));
8969
- };
8970
-
8971
- const TimeLine$1 = ({ id, toolTipTitle, marginLeft, color = "rgba(255,0,0,.6)", pixels = 2, height = "100%", zIndex = 1, }) => {
8972
- return (jsx(CwTooltipNew, { content: toolTipTitle, position: "top", children: jsx("div", { id: id, style: {
8973
- borderLeft: `${pixels}px solid ${color}`,
8974
- marginLeft: marginLeft,
8975
- width: "0px",
8976
- height: height,
8977
- position: "absolute",
8978
- zIndex: zIndex,
8979
- } }) }));
8980
- };
8981
-
8982
- const SchedulerContentArea = ({ now, showTimeline, timeLineLeftPx, timeSeparatorLeftPx, resources, scheduler, contextMenuContents, onEmptyClick, setContentArea, onClickContextMenu, }) => {
8983
- return (jsxs("td", { className: "contentArea", style: { width: "100%", overflow: "hidden", position: "relative" }, ref: (reference) => {
8984
- if (reference) {
8985
- setContentArea(reference);
8986
- }
8987
- }, children: [showTimeline && (jsx(TimeLine$1, { id: scheduler.props.id + "_timeline", marginLeft: timeLineLeftPx, zIndex: 8, toolTipTitle: Temporal.PlainTime.from({
8988
- hour: now.getHours(),
8989
- minute: now.getMinutes(),
8990
- }).toString({ smallestUnit: "minute" }) })), timeSeparatorLeftPx.map((pixels) => {
8991
- return jsx(TimeLine$1, { marginLeft: pixels, color: "rgba(255,255,255,0.7)" });
8992
- }), jsx("span", { onClick: () => {
8993
- if (onEmptyClick) {
8994
- onEmptyClick(scheduler.props.id);
8995
- }
8996
- }, children: jsx(ResourceListRender, { resources: resources, state: scheduler.state, schedulerProps: scheduler.props, contentArea: scheduler.contentArea, onClickContextMenu: onClickContextMenu, crewAssignmentSchedulerContextMenu: contextMenuContents }) })] }));
8997
- };
8998
-
8999
- const daysBetweenTwoDates = (date1, date2) => {
9000
- const diff = Math.abs(date1.getTime() - date2.getTime());
9001
- let diffDays = 0;
9002
- const startOffset = Math.abs(date1.getTimezoneOffset());
9003
- const endOffset = Math.abs(date2.getTimezoneOffset());
9004
- // Summer: +1 -> +2, true
9005
- // Winter: +2 -> -1, false
9006
- if (startOffset > endOffset) {
9007
- diffDays = Math.floor(diff / (1000 * 3600 * 24));
9008
- }
9009
- else {
9010
- diffDays = Math.ceil(diff / (1000 * 3600 * 24));
9011
- }
9012
- return diffDays;
9013
- };
9014
-
9015
- const calculateDivisionType = (start, end) => {
9016
- const diffDays = daysBetweenTwoDates(start, end);
9017
- if (diffDays <= 15) {
9018
- return "d";
9019
- }
9020
- else if (diffDays <= 30) {
9021
- return "w";
9022
- }
9023
- else {
9024
- return "m";
9025
- }
9026
- };
9027
-
9028
- const getMonthHeaderData = (dates, maxWidth) => {
9029
- if (dates.length === 0)
9030
- return [];
9031
- const dayWidth = maxWidth / dates.length;
9032
- const ranges = getMonthRanges(dates);
9033
- return ranges.map((range) => {
9034
- return {
9035
- monthFormatted: range.start.getMonth() + 1 + "." + range.start.getFullYear(),
9036
- width: dayWidth * range.daysLong,
9037
- };
9038
- });
9039
- };
9040
- const getMonthRanges = (dates) => {
9041
- const firstDay = dates[0];
9042
- const lastDay = dates[dates.length - 1];
9043
- let currentDate = new Date(firstDay);
9044
- const ranges = [];
9045
- while (currentDate <= lastDay) {
9046
- const rangeStart = new Date(currentDate);
9047
- let rangeEnd = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 0);
9048
- if (rangeEnd >= lastDay) {
9049
- rangeEnd = lastDay;
9050
- }
9051
- ranges.push({
9052
- start: rangeStart,
9053
- daysLong: getDaysBetweenDates(rangeStart, rangeEnd),
9054
- });
9055
- currentDate = new Date(rangeEnd.getFullYear(), rangeEnd.getMonth() + 1, 1);
9056
- }
9057
- return ranges;
9058
- };
9059
- const getDaysBetweenDates = (startDate, endDate) => {
9060
- const timeDifference = endDate.getTime() - startDate.getTime();
9061
- return Math.floor(timeDifference / (1000 * 60 * 60 * 24)) + 1;
9062
- };
9063
-
9064
- const getWeekHeaderDataFromWeekRange = (weekRange, maxWidth, dateFormatter) => weekRange.map(week => {
9065
- const numberOfDaysInScheduler = weekRange
9066
- .flatMap(element => {
9067
- return element.days;
9068
- })
9069
- .reduce((el1, el2) => {
9070
- return el1 + el2;
9071
- });
9072
- return {
9073
- formattedString: getStringForWeekRange(week, dateFormatter),
9074
- width: getWidthForWeekRange(maxWidth, week.days, numberOfDaysInScheduler)
9075
- };
9076
- });
9077
- const getStringForWeekRange = (weekRange, dateFormatter) => weekRange.days == 1
9078
- ? dateFormatter(weekRange.start)
9079
- : `${dateFormatter(weekRange.start)} - ${dateFormatter(weekRange.end)}`;
9080
- const getWidthForWeekRange = (maxWidth, weekDays, monthDays) => {
9081
- const dayWidth = maxWidth / monthDays;
9082
- return dayWidth * weekDays;
9083
- };
9084
-
9085
- // stringRange: `${formatter(date)} - ${formatter(end)}`,
9086
- const listOfDatesToWeekRangeList = (dates) => {
9087
- if (dates.length === 0) {
9088
- return [];
9089
- }
9090
- const datesToReturn = [];
9091
- dates.forEach((date, index) => {
9092
- const dayOfWeek = date.getDay();
9093
- const isFirstDay = index === 0;
9094
- const isLastDay = index === dates.length - 1;
9095
- const isSunday = dayOfWeek === 0;
9096
- const isMonday = dayOfWeek === 1;
9097
- if (isFirstDay && !isSunday) {
9098
- datesToReturn.push(createWeekRange(date, 8 - dayOfWeek));
9099
- return;
9100
- }
9101
- if (isLastDay && !isSunday) {
9102
- if (!isMonday) {
9103
- datesToReturn.pop();
9104
- }
9105
- const firstOfWeek = getFirstDayOfWeek(date);
9106
- datesToReturn.push(createWeekRange(firstOfWeek, dayOfWeek));
9107
- return;
9108
- }
9109
- if (isMonday) {
9110
- datesToReturn.push(createWeekRange(date, 7));
9111
- return;
9112
- }
9113
- // this is because sunday is 0
9114
- if (isFirstDay && isSunday) {
9115
- datesToReturn.push(createWeekRange(date, 1));
9116
- return;
9117
- }
9118
- });
9119
- return datesToReturn;
9120
- };
9121
- const createWeekRange = (start, days) => {
9122
- const end = new Date(start);
9123
- end.setDate(end.getDate() + days - 1);
9124
- return {
9125
- days,
9126
- start,
9127
- end,
9128
- isShortWeek: days < 7
9129
- };
9130
- };
9131
- const getFirstDayOfWeek = (date) => {
9132
- const currentDate = new Date(date);
9133
- const dayOfWeek = currentDate.getDay();
9134
- // dayOfWeek 0 == (Sunday)
9135
- const diffToMonday = dayOfWeek === 0 ? 6 : dayOfWeek - 1;
9136
- // Set the date to the first day of the week
9137
- currentDate.setDate(currentDate.getDate() - diffToMonday);
9138
- return currentDate;
9139
- };
9140
-
9141
- const DayHeader = ({ index, text, width, headerType }) => {
9142
- const isFirstDay = index == 0;
9143
- return (jsx("td", { style: {
9144
- display: "inline-block",
9145
- fontSize: "10px",
9146
- width: width,
9147
- maxWidth: width,
9148
- }, id: headerType + index, children: jsx("span", { className: isFirstDay ? "cwelltFirstDate_desc" : "", children: text }) }));
9149
- };
9150
-
9151
- const MonthHeader = ({ index, text, width, headerType }) => {
9152
- return (jsx("td", { style: {
9153
- display: "inline-block",
9154
- fontSize: "10px",
9155
- width: width,
9156
- maxWidth: width,
9157
- }, id: headerType + index, children: jsx("span", { children: text }) }));
9158
- };
9159
-
9160
- const WeekHeader = ({ index, text, width, headerType }) => {
9161
- const isFirstDay = index == 0;
9162
- return (jsx("td", { style: {
9163
- display: "inline-block",
9164
- fontSize: "10px",
9165
- width: width,
9166
- maxWidth: width,
9167
- }, id: headerType + index, children: jsx("span", { className: isFirstDay ? "cwelltFirstDate_desc" : "", style: { whiteSpace: "nowrap" }, children: text }) }));
9168
- };
9169
-
9170
- const DaysHeader = ({ days, divisionType, maxWidth, headerType }) => {
9171
- let headerToDraw = [];
9172
- const filteredDays = days.filter((date) => {
9173
- return date.getHours() === 0;
9174
- });
9175
- const dateFormatter = (date) => {
9176
- return `${date.getDate()}.${date.getMonth() + 1}.${date.getFullYear()}`;
9177
- };
9178
- switch (divisionType) {
9179
- case "d":
9180
- {
9181
- headerToDraw = filteredDays.map((date, index) => {
9182
- return (jsx(DayHeader, { text: dateFormatter(date), index: index, width: maxWidth / filteredDays.length, headerType: headerType }, index));
9183
- });
9184
- }
9185
- break;
9186
- case "w":
9187
- {
9188
- const weekRanges = listOfDatesToWeekRangeList(filteredDays);
9189
- headerToDraw = getWeekHeaderDataFromWeekRange(weekRanges, maxWidth, dateFormatter).map((week, index) => {
9190
- return (jsx(WeekHeader, { index: index, text: week.formattedString, width: week.width, headerType: headerType }, index));
9191
- });
9192
- }
9193
- break;
9194
- case "m":
9195
- {
9196
- const monthData = getMonthHeaderData(filteredDays, maxWidth);
9197
- headerToDraw = monthData.map(({ monthFormatted, width }, index) => (jsx(MonthHeader, { index: index, text: monthFormatted, width: width, headerType: headerType }, index)));
9198
- }
9199
- break;
9200
- }
9201
- return jsx("tr", { className: "cwelltSchRowDate", children: headerToDraw });
9202
- };
9203
-
9204
- function formatHHmm(date) {
9205
- const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
9206
- const zdt = Temporal.Instant.fromEpochMilliseconds(date.getTime()).toZonedDateTimeISO(timeZone);
9207
- return `${zdt.hour.toString().padStart(2, "0")}:${zdt.minute.toString().padStart(2, "0")}`;
9208
- }
9209
- const getFormattedTimeForHeader = (calculatedDivType, calculatedDivision, timeHeader) => {
9210
- let showDate = "";
9211
- switch (calculatedDivType) {
9212
- case "d":
9213
- switch (calculatedDivision) {
9214
- case 8:
9215
- showDate =
9216
- timeHeader.getHours() === 0 ||
9217
- timeHeader.getHours() === 3 ||
9218
- timeHeader.getHours() === 6 ||
9219
- timeHeader.getHours() === 9 ||
9220
- timeHeader.getHours() === 12 ||
9221
- timeHeader.getHours() === 15 ||
9222
- timeHeader.getHours() === 18 ||
9223
- timeHeader.getHours() === 21
9224
- ? formatHHmm(timeHeader)
9225
- : "";
9226
- break;
9227
- case 3:
9228
- showDate =
9229
- timeHeader.getHours() === 0 || timeHeader.getHours() === 8 || timeHeader.getHours() === 16
9230
- ? formatHHmm(timeHeader)
9231
- : "";
9232
- break;
9233
- case 2:
9234
- showDate =
9235
- timeHeader.getHours() === 0 || timeHeader.getHours() === 12 ? formatHHmm(timeHeader) : "";
9236
- break;
9237
- }
9238
- break;
9239
- case "m":
9240
- showDate = timeHeader.getHours() === 0 ? timeHeader.getDate().toString() : "";
9241
- break;
9242
- case "w":
9243
- showDate = timeHeader.getHours() === 0 ? timeHeader.getDate().toString() : "";
9244
- break;
9245
- }
9246
- return {
9247
- text: showDate,
9248
- isWeekend: timeHeader.getDay() === 6 || timeHeader.getDay() === 0,
9249
- };
9250
- };
9251
-
9252
- const calculateDivisions = (start, end) => {
9253
- const diffDays = daysBetweenTwoDates(start, end);
9254
- if (diffDays <= 3) {
9255
- return 8;
9256
- }
9257
- else if (diffDays < 8) {
9258
- return 3;
9259
- }
9260
- else if (diffDays <= 15) {
9261
- return 2;
9262
- }
9263
- else {
9264
- return 1;
9265
- }
9266
- };
9267
-
9268
- const TimeHeader = ({ isWeekend, index, text, width, header }) => {
9269
- if (text === "") {
9270
- return;
9271
- }
9272
- const commonStyles = {
9273
- display: "flex",
9274
- alignItems: "center",
9275
- justifyContent: "left",
9276
- fontSize: "10px",
9277
- width: width,
9278
- maxWidth: width,
9279
- height: "30px",
9280
- borderLeft: "1px solid white",
9281
- background: isWeekend ? "#cbc9c9" : "",
9282
- color: "#000000d9",
9283
- fontWeight: 700,
9284
- };
9285
- return (jsx("td", { style: commonStyles, id: `${header}Time${index}`, children: jsx("span", { style: { paddingLeft: "8px" }, children: text }) }, `t${index}`));
9286
- };
9287
-
9288
- const TimeHeaderRow = ({ timeHeaders, startDate, endDate, maxWidth, header }) => {
9289
- const calculatedDivision = calculateDivisions(startDate, endDate);
9290
- const calculatedDivType = calculateDivisionType(startDate, endDate);
9291
- const formattedHeaders = timeHeaders.map((th) => {
9292
- return getFormattedTimeForHeader(calculatedDivType, calculatedDivision, th);
9293
- });
9294
- const filteredHeaders = formattedHeaders.filter((element) => element.text !== "");
9295
- return (jsx("tr", { className: "cwelltSchRowTime", style: { height: "30px" }, children: filteredHeaders.map(({ text, isWeekend }, index) => {
9296
- return (jsx(TimeHeader, { isWeekend: isWeekend, index: index, text: text, width: maxWidth / filteredHeaders.length, header: header }, index));
9297
- }) }));
9298
- };
9299
-
9300
- const SchedulerTimeLine = ({ maxPx, hoursList, startDate, endDate, pxPerHour, headerName, }) => {
9301
- return (jsx("table", { className: "content-area cwelltSchTable", style: { width: maxPx }, children: jsxs("tbody", { style: { width: "100%", borderSpacing: 0 }, className: "content-area cwelltSchTbody", children: [jsx(DaysHeader, { days: hoursList, divisionType: calculateDivisionType(startDate, endDate), maxWidth: pxPerHour * hoursList.length, headerType: headerName ?? "schedulerDateHeader" }), jsx(TimeHeaderRow, { timeHeaders: hoursList, startDate: startDate, endDate: endDate, maxWidth: pxPerHour * hoursList.length, header: headerName ?? "schedulerTimeHeader" })] }) }));
9302
- };
9303
-
9304
- const SchedulerHeader$1 = ({ timelineProps, descriptionColumn }) => {
9305
- const { maxPx, hoursList, startDate, endDate, pxPerHour, headerName } = timelineProps;
9306
- return (jsx("thead", { className: "cwellt_fc_header_scheduler", style: { position: "sticky", zIndex: 9 }, children: jsxs("tr", { className: "cwellt_fc_header_row", children: [jsxs("td", { className: "border", style: {
9307
- position: "sticky",
9308
- top: 0,
9309
- backgroundColor: "white",
9310
- width: "100px",
9311
- }, children: [jsx("div", { style: {
9312
- display: "flex",
9313
- height: "30px",
9314
- alignItems: "center",
9315
- width: "150px",
9316
- }, children: jsx("label", { children: headerName }) }), jsx("div", { style: {
9317
- display: "flex",
9318
- height: "30px",
9319
- alignItems: "center",
9320
- background: "rgba(0, 0, 0, 0.04)",
9321
- }, children: jsx("span", { children: descriptionColumn }) })] }), jsx("td", { style: {
9322
- position: "sticky",
9323
- top: 0,
9324
- zIndex: 6,
9325
- backgroundColor: "white",
9326
- }, children: jsx(SchedulerTimeLine, { maxPx: maxPx, hoursList: hoursList, pxPerHour: pxPerHour, startDate: startDate, endDate: endDate, headerName: headerName }) })] }) }));
9327
- };
9328
-
9329
- const daysBetweenTwoDatesIncludingBoth = (date1, date2) => {
9330
- const diff = Math.abs(date1.getTime() - date2.getTime());
9331
- const diffDays = diff / (1000 * 3600 * 24);
9332
- return diffDays;
9333
- };
9334
-
9335
- const getUtcToday = () => {
9336
- const now = new Date();
9337
- const userTimezoneOffset = now.getTimezoneOffset() * 60000;
9338
- const nowUtc = new Date(now.getTime() + userTimezoneOffset);
9339
- return nowUtc;
9340
- };
9341
-
9342
- const filterEvents = (events, start, end, id, module = undefined) => {
9343
- const datesCollide = (event) => event.start <= end && event.end >= start;
9344
- let eventsFiltered = events.filter(event => datesCollide(event));
9345
- if (id !== "flightWatchScheduler") {
9346
- eventsFiltered = sortByDate(eventsFiltered);
9347
- }
9348
- if (id !== "crewAssignmentsScheduler" && id !== "vacationsScheduler") {
9349
- return eventsFiltered;
9350
- }
9351
- eventsFiltered = setNotFullHeightEventsFirst(eventsFiltered);
9352
- if (module === "CrewControl") {
9353
- eventsFiltered = removeDuplicated(eventsFiltered, "Crew_Id");
9354
- }
9355
- if (module === "CrewScheduling") {
9356
- eventsFiltered = removeDuplicated(eventsFiltered, "AssignmentID");
9357
- }
9358
- if (module === "CrewSchedulingVacations") {
9359
- eventsFiltered = removeDuplicated(eventsFiltered, "ID");
9360
- }
9361
- return eventsFiltered;
9362
- };
9363
- const sortByDate = (events) => events.sort((a, b) => +new Date(a.start) - +new Date(b.start));
9364
- const removeDuplicated = (events, key) => {
9365
- return events.filter((obj, index, self) => index === self.findIndex(o => o.data[key] === obj.data[key] && o.data.subject === obj.data.subject));
9366
- };
9367
- const setNotFullHeightEventsFirst = (events) => {
9368
- const notFullHeight = [];
9369
- const isFullHeight = [];
9370
- events.forEach(element => {
9371
- element.isFullHeight ? notFullHeight.push(element) : isFullHeight.push(element);
9372
- });
9373
- return notFullHeight.concat(isFullHeight);
9374
- };
9375
-
9376
- const compareStrings = (str1, str2) => {
9377
- if (str1 > str2)
9378
- return 1;
9379
- if (str1 < str2)
9380
- return -1;
9381
- return 0;
9382
- };
9383
-
9384
- const filterResources = (module, resourceName, resources, groupByFunction, endDate, startDate, scheduleName) => {
9385
- if ((module === "CrewControl" || module === "CrewScheduling" || module === "CrewSchedulingVacations") &&
9386
- resourceName === "Employees") {
9387
- resources = resources.filter(c => (c.data.Eintritt === null || (new Date(c.data.Eintritt) <= endDate)) && (c.data.Austritt === null || (new Date(c.data.Austritt) >= startDate)));
9388
- }
9389
- if (scheduleName === "crewPinnedScheduler" || (module === "CrewControl" || module === "CrewScheduling") && resourceName === "Employees") {
9390
- const sortKey = (groupByFunction || scheduleName === "crewPinnedScheduler") ? "mainFunction" : "C3_LC";
9391
- resources = resources.sort((a, b) => compareStrings(a.data[sortKey], b.data[sortKey]));
9392
- }
9393
- return resources;
9394
- };
9395
-
9396
- const heightScheduler = (resources, visibleRows, isPinnerScheduler) => {
9397
- if (resources.length <= 0) {
9398
- return 100;
9399
- }
9400
- const realVisibleRows = visibleRows > resources.length ? resources.length : visibleRows;
9401
- const rowsHeight = resources.slice(0, realVisibleRows).map((row) => {
9402
- return row.maxTop;
9403
- });
9404
- const height = rowsHeight.reduce((sum, row) => {
9405
- return sum + row;
9406
- }, 0);
9407
- const headerHeight = isPinnerScheduler ? 0 : 60;
9408
- return height + headerHeight;
9409
- };
9410
-
9411
- const getLeftPixels = (eventStart, scheduleStart, dayPx) => {
9412
- if (scheduleStart >= eventStart)
9413
- return 0;
9414
- return daysBetweenTwoDatesIncludingBoth(scheduleStart, eventStart) * dayPx;
9415
- };
9416
- const getEventWithSize = (event, schedulerStart, dayPx) => {
9417
- const eventStartBeforeScheduleStart = event.start.getTime() < schedulerStart.getTime();
9418
- const lengthOfEvent = daysBetweenTwoDatesIncludingBoth(event.start, event.end);
9419
- const daysUntilSchedulerStart = daysBetweenTwoDatesIncludingBoth(event.start, schedulerStart);
9420
- const daysLong = eventStartBeforeScheduleStart ? lengthOfEvent - daysUntilSchedulerStart : lengthOfEvent;
9421
- // we want minimum of 8 px
9422
- const eventMinSize = 8;
9423
- const newEvent = {
9424
- ...event,
9425
- leftPx: getLeftPixels(event.start, schedulerStart, dayPx),
9426
- width: Math.max(daysLong * dayPx, eventMinSize),
9427
- };
9428
- return newEvent;
9429
- };
9430
-
9431
- const checkIfSlotAvailable = (events, event) => {
9432
- if (events.length == 0)
9433
- return true;
9434
- const collide = events.some(existent => {
9435
- return !(existent.end <= event.start || event.end <= existent.start) && !existent.isFullHeight;
9436
- });
9437
- return !collide;
9438
- };
9439
-
9440
- const getEventsInInnerRows = (res, eventHeight, dayPx, start) => {
9441
- let maxTop = 0;
9442
- const tops = [];
9443
- tops[0] = new Array();
9444
- res.events
9445
- .map((e) => {
9446
- return getEventWithSize(e, start, dayPx);
9447
- })
9448
- .forEach((event, i) => {
9449
- if (i === 0 || event.isFullHeight) {
9450
- event.top = 0;
9451
- tops[0].push(event);
9452
- }
9453
- else {
9454
- let found = false;
9455
- for (let j = 0; j < tops.length && found === false; j++) {
9456
- found = checkIfSlotAvailable(tops[j], event);
9457
- if (found === true || event.isFullHeight) {
9458
- event.top = j * eventHeight;
9459
- tops[j].push(event);
9460
- break;
9461
- }
9462
- }
9463
- if (found === false && !event.isFullHeight) {
9464
- maxTop++;
9465
- tops[maxTop] = new Array();
9466
- event.top = maxTop * eventHeight;
9467
- tops[maxTop].push(event);
9468
- }
9469
- else {
9470
- // This is for flightwatch
9471
- if (found === true && event.data.order === 2 && maxTop < 1) {
9472
- maxTop++;
9473
- tops[maxTop] = new Array();
9474
- event.top = maxTop * eventHeight;
9475
- tops[maxTop].push(event);
9476
- maxTop--;
9477
- }
9478
- }
9479
- }
9480
- });
9481
- return tops;
9482
- };
9483
-
9484
- const getTimeHeaders = (startDate, endDate) => {
9485
- const dateArray = new Array();
9486
- const currentDate = new Date(startDate);
9487
- const startOffset = Math.abs(startDate.getTimezoneOffset());
9488
- const endOffset = Math.abs(endDate.getTimezoneOffset());
9489
- // Summer: +1 -> +2, true
9490
- // Winter: +2 -> -1, false
9491
- const offsetSummerWinter = startOffset < endOffset;
9492
- if (offsetSummerWinter === true) {
9493
- while (currentDate < endDate) {
9494
- if (dateArray.length > 0) {
9495
- const lastPosition = dateArray[dateArray.length - 1];
9496
- const differenceHours = currentDate.getHours() - lastPosition.getHours();
9497
- if (differenceHours === 1 || differenceHours < 0) {
9498
- dateArray.push(new Date(currentDate));
9499
- }
9500
- else if (differenceHours > 1) {
9501
- dateArray.push(new Date(currentDate.getHours() - 1));
9502
- dateArray.push(new Date(currentDate));
9503
- }
9504
- }
9505
- else {
9506
- dateArray.push(new Date(currentDate));
9507
- }
9508
- currentDate.setHours(currentDate.getHours() + 1);
9509
- }
9510
- }
9511
- else {
9512
- while (currentDate < endDate) {
9513
- dateArray.push(new Date(currentDate));
9514
- currentDate.setHours(currentDate.getHours() + 1);
9515
- }
9516
- }
9517
- return dateArray;
9518
- };
9519
-
9520
- class CwScheduler extends Component {
9521
- contentArea;
9522
- calculateMaxPx = () => {
9523
- const mainElement = document.body;
9524
- const mainRect = mainElement.getBoundingClientRect();
9525
- return Math.floor(mainRect.width - 190);
9526
- };
9527
- constructor(props) {
9528
- super(props);
9529
- const maxPx = this.calculateMaxPx();
9530
- const timeHeaders = getTimeHeaders(props.startDate, props.endDate);
9531
- const dayPx = maxPx / Math.floor(daysBetweenTwoDates(props.startDate, props.endDate));
9532
- const hourPx = dayPx / 24;
9533
- const minutePx = dayPx / 1440;
9534
- window?.addEventListener("resize", this.handleResize);
9535
- const divisions = calculateDivisions(this.props.startDate, this.props.endDate);
9536
- const divisionsLeftPx = timeHeaders
9537
- .filter((_, index) => {
9538
- return index != 0 && index % (24 / divisions) == 0;
9539
- })
9540
- .map((date) => {
9541
- const daysDiff = daysBetweenTwoDatesIncludingBoth(date, props.startDate);
9542
- const pixels = daysDiff * 24 * hourPx;
9543
- return pixels;
9544
- });
9545
- this.state = {
9546
- maxPx: maxPx,
9547
- dayPx: dayPx,
9548
- hourPx: hourPx,
9549
- minutePx: minutePx,
9550
- timeHeaders: timeHeaders,
9551
- divisionsLeftPx: divisionsLeftPx,
9552
- eventHeight: 30,
9553
- resources: props.resources,
9554
- lineStyle: 0,
9555
- nowUtc: getUtcToday(),
9556
- division: divisions,
9557
- divisionType: "",
9558
- pinnedResources: props.pinnedResources ? props.pinnedResources : [],
9559
- selectedEvents: [],
9560
- showConsoleLogs: false, // Change to false to not show the console.log(...)
9561
- };
9562
- }
9563
- handleResize = () => {
9564
- const maxPx = this.calculateMaxPx();
9565
- const days = Math.floor(daysBetweenTwoDates(this.props.startDate, this.props.endDate));
9566
- const dayPx = maxPx / days;
9567
- const hourPx = dayPx / 24;
9568
- const updated = { ...this.state, maxPx: maxPx, hourPx: hourPx, dayPx: dayPx };
9569
- this.setState(updated);
9570
- };
9571
- objectsEqual = (o1, o2) => {
9572
- Object.keys(o1).length === Object.keys(o2).length && Object.keys(o1).every((p) => o1[p] === o2[p]);
9573
- };
9574
- objectsEqualDeep = (o1, o2) => typeof o1 === "object" && Object.keys(o1).length > 0
9575
- ? Object.keys(o1).length === Object.keys(o2).length &&
9576
- Object.keys(o1).every((p) => this.objectsEqual(o1[p], o2[p]))
9577
- : o1 === o2;
9578
- arraysEqual = (a1, a2) => a1.length === a2.length && a1.every((o, idx) => this.objectsEqualDeep(o, a2[idx]));
9579
- componentWillReceiveProps(_nextProps) {
9580
- if (this.state.showConsoleLogs) {
9581
- console.log("Schedule - componentWillReceiveProps, start: ", new Date());
9582
- console.log("Schedule - componentWillReceiveProps - has changes, start: ", new Date());
9583
- }
9584
- const dateChange = _nextProps.startDate.toISOString() !== this.props.startDate.toISOString() ||
9585
- _nextProps.endDate.toISOString() !== this.props.endDate.toISOString();
9586
- if (dateChange) {
9587
- const startDate = _nextProps.startDate;
9588
- const endDate = _nextProps.endDate;
9589
- const maxPx = this.calculateMaxPx();
9590
- const timeHeaders = getTimeHeaders(startDate, endDate);
9591
- const days = Math.floor(daysBetweenTwoDates(startDate, endDate));
9592
- const dayPx = maxPx / days;
9593
- const hourPx = dayPx / 24;
9594
- const minutePx = dayPx / 1440;
9595
- const now = getUtcToday();
9596
- const isInDateRange = now >= startDate && now <= endDate && this.contentArea !== undefined;
9597
- const lineStyle = isInDateRange ? daysBetweenTwoDatesIncludingBoth(startDate, now) * dayPx : 0;
9598
- const divisions = calculateDivisions(startDate, endDate);
9599
- const divisionsLeftPx = timeHeaders
9600
- .filter((_, index) => {
9601
- return index != 0 && index % (24 / divisions) == 0;
9602
- })
9603
- .map((date) => {
9604
- const daysDiff = daysBetweenTwoDatesIncludingBoth(date, startDate);
9605
- const pixels = daysDiff * dayPx;
9606
- return pixels;
9607
- });
9608
- this.setState({
9609
- maxPx: maxPx, // window.screen.width * 0.9,
9610
- dayPx: dayPx,
9611
- hourPx: hourPx,
9612
- minutePx: minutePx,
9613
- timeHeaders: timeHeaders,
9614
- divisionsLeftPx: divisionsLeftPx,
9615
- resources: this.getNewResources(_nextProps, dayPx),
9616
- lineStyle: lineStyle,
9617
- nowUtc: now,
9618
- division: divisions,
9619
- divisionType: "",
9620
- pinnedResources: this.props.pinnedResources ?? [],
9621
- });
9622
- if (this.state.showConsoleLogs) {
9623
- console.log("Schedule - componentWillReceiveProps - print on schedule, end: ", new Date());
9624
- console.log("Schedule - componentWillReceiveProps, end: ", new Date());
9625
- }
9626
- return;
9627
- }
9628
- const areSameEvents = this.arraysEqual(_nextProps.events, this.props.events);
9629
- const areSameRows = this.arraysEqual(_nextProps.resources, this.props.resources);
9630
- if (!areSameEvents || !areSameRows) {
9631
- const startDate = _nextProps.startDate;
9632
- const endDate = _nextProps.endDate;
9633
- const maxPx = this.calculateMaxPx();
9634
- const days = Math.floor(daysBetweenTwoDates(startDate, endDate));
9635
- const dayPx = maxPx / days;
9636
- this.setState({
9637
- resources: this.getNewResources(_nextProps, dayPx),
9638
- });
9639
- return;
9640
- }
9641
- }
9642
- getNewResources = (_nextProps, dayPx) => {
9643
- const mappedEvents = filterEvents(_nextProps.events, _nextProps.startDate, _nextProps.endDate, this.props.id, this.props.module)
9644
- .filter((event) => {
9645
- const outOfRange = event.end <= this.props.startDate || event.start >= this.props.endDate;
9646
- return !outOfRange;
9647
- });
9648
- const resources = filterResources(this.props.module, this.props.resourceName, _nextProps.resources, this.props.groupByFunction, _nextProps.endDate, _nextProps.startDate, this.props.id);
9649
- const newResources = resources
9650
- .map((resource) => {
9651
- return {
9652
- ...resource,
9653
- events: mappedEvents.filter((event) => event.resourceId === resource.id),
9654
- };
9655
- })
9656
- .map((resource) => {
9657
- const tops = getEventsInInnerRows(resource, this.state.eventHeight, dayPx, _nextProps.startDate);
9658
- const height = tops.length === 0 ? this.state.eventHeight : tops.length * this.state.eventHeight;
9659
- let flatMapEvents = [];
9660
- for (let h = 0; h < tops.length; h++) {
9661
- flatMapEvents = flatMapEvents.concat(tops[h]);
9662
- }
9663
- return {
9664
- ...resource,
9665
- maxTop: height,
9666
- events: flatMapEvents,
9667
- };
9668
- });
9669
- return newResources;
9670
- };
9671
- handleOnClickContextMenuResourceScheduler = (_clickEvent, _resource) => {
9672
- let datetime = new Date();
9673
- const _ca = this.contentArea;
9674
- if (_clickEvent.domEvent.currentTarget !== undefined) {
9675
- const leftPos = _clickEvent.domEvent.currentTarget.parentElement.getBoundingClientRect().left -
9676
- (_ca?.getBoundingClientRect()?.left ?? 0) -
9677
- window.scrollX;
9678
- datetime = addMinutesToDateFromPx(this.props.startDate, leftPos, this.state.minutePx);
9679
- }
9680
- if (this.props.scheduler_handleOnClickContextMenuResource) {
9681
- this.props.scheduler_handleOnClickContextMenuResource(datetime, _resource, _clickEvent.key, this.props.id);
9682
- }
9683
- };
9684
- handleCrewPinning = (resource, text) => {
9685
- if (this.props.scheduler_handlePinned) {
9686
- this.props.scheduler_handlePinned.call(this.props.parent, resource.id, text, this.props.id);
9687
- }
9688
- };
9689
- render() {
9690
- const isInDateRange = this.state.nowUtc >= this.props.startDate &&
9691
- this.state.nowUtc <= this.props.endDate &&
9692
- this.contentArea !== undefined;
9693
- const showTimeline = isInDateRange && this.state.lineStyle < this.state.maxPx;
9694
- const isPinnedTable = this.props.id.toLowerCase().includes("pinned");
9695
- const schedulerHeight = heightScheduler(this.state.resources, this.props.height, this.props.id === "crewAssignmentsScheduler");
9696
- return (jsx("div", { id: this.props.id, style: {
9697
- maxHeight: isPinnedTable ? "auto" : schedulerHeight,
9698
- }, className: this.state.resources.length > 0 ? "cwellt_tb_con" : "cwellt_tb_con cw_tb_con_emptyValues", children: jsxs("table", { id: "cwelltTableScheduler", children: [this.props.id !== "crewAssignmentsScheduler" && (jsx(SchedulerHeader$1, { timelineProps: {
9699
- maxPx: this.state.maxPx,
9700
- hoursList: this.state.timeHeaders,
9701
- pxPerHour: this.state.hourPx,
9702
- startDate: this.props.startDate,
9703
- endDate: this.props.endDate,
9704
- headerName: this.props.resourceName,
9705
- }, descriptionColumn: this.props.descriptionColumn })), jsx("tbody", { style: {
9706
- width: this.state.maxPx + 150,
9707
- maxHeight: isPinnedTable ? "auto" : schedulerHeight,
9708
- }, className: isPinnedTable ? "fc-body cw-fc-body-pinned" : "fc-body", children: jsxs("tr", { className: "fc_body_row", children: [jsx(ResourcesTitleList, { resources: this.state.resources, canBePinned: this.props.canBePinned ?? false, includesPinned: this.props.id.toLowerCase().includes("pinned"), onCrewPinning: this.handleCrewPinning, onClickResourceContextMenu: (_e, resource) => {
9709
- if (this.props.scheduler_handleOnClickResourceContextMenu) {
9710
- this.props.scheduler_handleOnClickResourceContextMenu(_e, resource);
9711
- }
9712
- }, ResourceTitleComponent: this.props.resourceComp }), jsx("td", { className: "dividerArea" }), jsx(SchedulerContentArea, { now: this.state.nowUtc, showTimeline: showTimeline, timeSeparatorLeftPx: this.state.divisionsLeftPx, timeLineLeftPx: this.state.lineStyle, resources: this.state.resources, contextMenuContents: this.props.resourceContextMenuContents, scheduler: this, onEmptyClick: this.props.scheduler_handleEmptyClick, setContentArea: (n) => (this.contentArea = n), onClickContextMenu: this.handleOnClickContextMenuResourceScheduler })] }) })] }) }));
9713
- }
9714
- }
9715
-
9716
8662
  function dateFromPercentage(startDate, visibleDays, percentage) {
9717
8663
  const start = Temporal.Instant.fromEpochMilliseconds(startDate.getTime());
9718
8664
  const spanMs = Math.round(visibleDays) * 24 * 60 * 60 * 1000;
@@ -9853,7 +8799,7 @@ class OnClickContextMenu {
9853
8799
  }
9854
8800
  }
9855
8801
 
9856
- var styles$3 = {"scheduler-header-divisions":"scheduler-header-module__scheduler-header-divisions__1JrNe","scheduler-timeline-now":"scheduler-header-module__scheduler-timeline-now__naREv","scheduler-timeline-label":"scheduler-header-module__scheduler-timeline-label__mLVAp","scheduler-header-title":"scheduler-header-module__scheduler-header-title__Jzy94","scheduler-dates":"scheduler-header-module__scheduler-dates__O7ePQ","current-day":"scheduler-header-module__current-day__FpHiv","scheduler-hours":"scheduler-header-module__scheduler-hours__ZDCVj"};
8802
+ var styles$3 = {"scheduler-header":"scheduler-header-module__scheduler-header__Y7SNV","scheduler-header-divisions":"scheduler-header-module__scheduler-header-divisions__1JrNe","scheduler-timeline-now":"scheduler-header-module__scheduler-timeline-now__naREv","scheduler-timeline-label":"scheduler-header-module__scheduler-timeline-label__mLVAp","scheduler-header-title":"scheduler-header-module__scheduler-header-title__Jzy94","scheduler-dates":"scheduler-header-module__scheduler-dates__O7ePQ","current-day":"scheduler-header-module__current-day__FpHiv","scheduler-hours":"scheduler-header-module__scheduler-hours__ZDCVj"};
9857
8803
 
9858
8804
  const getNow$1 = (isUtc) => {
9859
8805
  let now = new Date();
@@ -9919,7 +8865,7 @@ const HeaderTitle = ({ title, dividerText, width }) => {
9919
8865
  const SchedulerHeader = ({ content, divisions, visibleDays, selectedDate, width, onEvent, timeLinePercentage, isUtc }) => {
9920
8866
  const topWidth = (100 / visibleDays);
9921
8867
  const { title, classification } = content;
9922
- return (jsxs("div", { style: { display: "flex" }, children: [jsx(HeaderTitle, { title: title, dividerText: classification, width: width }), jsxs("div", { className: styles$3["scheduler-header-divisions"], style: { flex: 1, display: "flex", position: "relative" }, onMouseDown: (e) => {
8868
+ return (jsxs("div", { className: styles$3["scheduler-header"], children: [jsx(HeaderTitle, { title: title, dividerText: classification, width: width }), jsxs("div", { className: styles$3["scheduler-header-divisions"], style: { flex: 1, display: "flex", position: "relative" }, onMouseDown: (e) => {
9923
8869
  e.preventDefault();
9924
8870
  const clickPercentage = getPercentageFromMouseEvent(e);
9925
8871
  const date = dateFromPercentage(selectedDate, visibleDays, clickPercentage);
@@ -10787,325 +9733,6 @@ const Scheduler = (props) => {
10787
9733
  class UiEvent {
10788
9734
  }
10789
9735
 
10790
- let topsCounter = 0;
10791
- class CwSuperScheduler extends React.Component {
10792
- constructor(Props) {
10793
- super(Props);
10794
- this.state = {
10795
- topsCalculated: 0,
10796
- height: 50,
10797
- dataConfig: this.props.dataConfig ? this.props.dataConfig : undefined,
10798
- pinnedResources: []
10799
- };
10800
- }
10801
- componentDidUpdate(_previousProps, _previousState) {
10802
- if (this.props.pinnedResources !== _previousProps.pinnedResources) {
10803
- let returnedTops = 0;
10804
- let returnedHeight = 50;
10805
- let data;
10806
- if (this.props.pinnedResources) {
10807
- const pinned = [...new Set(this.props.pinnedResources)];
10808
- for (let i = 0; i < pinned.length; i++) {
10809
- data = this.returnDynamicHeight(pinned[i], returnedTops);
10810
- returnedTops = data.topsCalculated;
10811
- returnedHeight = data.height;
10812
- }
10813
- this.setState({
10814
- topsCalculated: returnedTops,
10815
- height: returnedHeight !== 50 ? 80 + returnedHeight : 50,
10816
- pinnedResources: this.props.pinnedResources
10817
- });
10818
- }
10819
- }
10820
- }
10821
- scheduler_handleCblEventClick = (cblEvent, schedulerId) => {
10822
- this.props.scheduler_handleCblEventClick(cblEvent, schedulerId);
10823
- };
10824
- scheduler_handleCblEventClickRight = (cblEvent, schedulerId) => {
10825
- if (this.props.scheduler_handleCblEventClickRight) {
10826
- this.props.scheduler_handleCblEventClickRight(cblEvent, schedulerId);
10827
- }
10828
- };
10829
- scheduler_handleCblEventDoubleClick = (cblEvent, schedulerId) => {
10830
- this.props.scheduler_handleCblEventDoubleClick(cblEvent, schedulerId);
10831
- };
10832
- scheduler_handlePinnedClickMultipleIds = (resIds, schedulerId, requestString) => {
10833
- this.props.scheduler_handlePinningOfResources(resIds, "", schedulerId, requestString);
10834
- };
10835
- scheduler_handlePinnedClick = (resId, text, schedulerId) => {
10836
- const array = new Array();
10837
- array.push(resId);
10838
- this.props.scheduler_handlePinningOfResources(array, text, schedulerId, "resources");
10839
- };
10840
- returnDynamicHeight(pinned, topsCalculated) {
10841
- let height = 100;
10842
- let maxTop = 0;
10843
- const eventHeight = 30;
10844
- const tops = new Array();
10845
- tops[0] = new Array();
10846
- const diffDates = this.props.endDate.getTime() - this.props.startDate.getTime();
10847
- const diffDays = diffDates / (1000 * 3600 * 24);
10848
- const dateToFilter = new Date(this.props.startDate.getTime());
10849
- dateToFilter.setDate(dateToFilter.getDate() + diffDays);
10850
- let events = this.props.pinnedEvents !== undefined ? this.props.pinnedEvents : new Array();
10851
- events = events
10852
- .filter(x => pinned === x.resourceId && x.start >= this.props.startDate && x.start <= dateToFilter)
10853
- .sort((a, b) => {
10854
- return +new Date(a.start) - +new Date(b.start);
10855
- });
10856
- for (let i = 0; i < events.length; i++) {
10857
- const event = events[i];
10858
- if (i === 0 || event.isFullHeight) {
10859
- tops[0].push(event);
10860
- }
10861
- else {
10862
- let found = false;
10863
- for (let j = 0; j < tops.length && found === false; j++) {
10864
- found = this.checkIfSlotAvailable(tops[j], event);
10865
- if (found === true || event.isFullHeight) {
10866
- tops[j].push(event);
10867
- }
10868
- }
10869
- if (found === false) {
10870
- maxTop++;
10871
- tops[maxTop] = new Array();
10872
- tops[maxTop].push(event);
10873
- }
10874
- }
10875
- }
10876
- for (let h = 0; h < tops.length; h++) {
10877
- if (tops.length === 0) {
10878
- height = 100;
10879
- }
10880
- else {
10881
- height = (topsCalculated + tops.length) * eventHeight;
10882
- }
10883
- }
10884
- topsCounter = topsCounter + tops.length;
10885
- return {
10886
- topsCalculated: topsCalculated + tops.length,
10887
- height: height
10888
- };
10889
- }
10890
- checkIfSlotAvailable(array, event) {
10891
- let found = false;
10892
- if (array[array.length - 1].end <= event.start || array[array.length - 1].isFullHeight) {
10893
- found = true;
10894
- }
10895
- return found;
10896
- }
10897
- handleOnClickContextMenuResource = (date, resource, key, schedulerId) => {
10898
- let url = "";
10899
- switch (key) {
10900
- case "showReserves": {
10901
- // CrewControl
10902
- if (this.props.module === "CrewControl") {
10903
- url = "/Winops/CrewControl/CrewControlReact/GetCrewIdsOfReserve";
10904
- }
10905
- // CrewScheduling
10906
- if (this.props.module === "CrewScheduling") {
10907
- url = "/Winops/CrewPlanning/CrewPlanning/GetCrewIdsOfReserve";
10908
- }
10909
- const requestOptions = {
10910
- method: "POST",
10911
- headers: { "Content-Type": "application/json" },
10912
- body: JSON.stringify({
10913
- from: this.dateUTCString(this.props.startDate),
10914
- to: this.dateUTCString(this.props.endDate),
10915
- acftCategories: [],
10916
- functions: [],
10917
- clickedDate: this.dateUTCString(date),
10918
- airportSelected: this.props.airportSelected
10919
- })
10920
- };
10921
- if (this.state.dataConfig) {
10922
- fetch(this.state.dataConfig + url, requestOptions)
10923
- .then(response => response.json())
10924
- .then(res => {
10925
- if (res.length > 0) {
10926
- this.scheduler_handlePinnedClickMultipleIds(res, schedulerId, "Reserves");
10927
- }
10928
- else {
10929
- alert("No Reserves");
10930
- }
10931
- });
10932
- }
10933
- break;
10934
- }
10935
- case "showStandbys": {
10936
- // CrewControl
10937
- if (this.props.module === "CrewControl") {
10938
- url = "/Winops/CrewControl/CrewControlReact/GetCrewIdsOfStandby";
10939
- }
10940
- // CrewScheduling
10941
- if (this.props.module === "CrewScheduling") {
10942
- url = "/Winops/CrewPlanning/CrewPlanning/GetCrewIdsOfStandby";
10943
- }
10944
- const requestOptions2 = {
10945
- method: "POST",
10946
- headers: { "Content-Type": "application/json" },
10947
- body: JSON.stringify({
10948
- from: this.dateUTCString(this.props.startDate),
10949
- to: this.dateUTCString(this.props.startDate),
10950
- acftCategories: [],
10951
- functions: [],
10952
- clickedDate: this.dateUTCString(date),
10953
- airportSelected: this.props.airportSelected
10954
- })
10955
- };
10956
- if (this.state.dataConfig) {
10957
- fetch(this.state.dataConfig + url, requestOptions2)
10958
- .then(response => response.json())
10959
- .then(res => {
10960
- if (res.length > 0) {
10961
- this.scheduler_handlePinnedClickMultipleIds(res, schedulerId, "Standbys");
10962
- }
10963
- else {
10964
- alert("No Standbys");
10965
- }
10966
- });
10967
- }
10968
- break;
10969
- }
10970
- case "showAvailables": {
10971
- // CrewControl
10972
- if (this.props.module === "CrewControl") {
10973
- url = "/Winops/CrewControl/CrewControlReact/GetCrewIdsOfAvailables";
10974
- }
10975
- // CrewScheduling
10976
- if (this.props.module === "CrewScheduling") {
10977
- url = "/Winops/CrewPlanning/CrewPlanning/GetCrewIdsOfAvailables";
10978
- }
10979
- const requestOptions3 = {
10980
- method: "POST",
10981
- headers: { "Content-Type": "application/json" },
10982
- body: JSON.stringify({
10983
- from: this.dateUTCString(this.props.startDate),
10984
- to: this.dateUTCString(this.props.startDate),
10985
- acftCategories: [],
10986
- functions: [],
10987
- clickedDate: this.dateUTCString(date),
10988
- airportSelected: this.props.airportSelected
10989
- })
10990
- };
10991
- if (this.state.dataConfig) {
10992
- fetch(this.state.dataConfig + url, requestOptions3)
10993
- .then(response => response.json())
10994
- .then(res => {
10995
- if (res.length > 0) {
10996
- this.scheduler_handlePinnedClickMultipleIds(res, schedulerId, "Availables");
10997
- }
10998
- else {
10999
- alert("No Availables");
11000
- }
11001
- });
11002
- }
11003
- break;
11004
- }
11005
- default: {
11006
- if (this.props.scheduler_handleOnClickContextMenuResource) {
11007
- this.props.scheduler_handleOnClickContextMenuResource(date, resource, key);
11008
- }
11009
- break;
11010
- }
11011
- }
11012
- };
11013
- dateUTCString(date) {
11014
- if (date instanceof Date) {
11015
- if (date.getFullYear() > 1901)
11016
- return new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes())).toISOString();
11017
- }
11018
- return date;
11019
- }
11020
- render() {
11021
- const havePinnedResources = this.state.pinnedResources?.length > 0;
11022
- const firstSchedulerResources = havePinnedResources
11023
- ? this.props.resourcesToPin.filter(x => this.state.pinnedResources.includes(x.id))
11024
- : new Array();
11025
- const secondSchedulerResources = this.props.resources.filter(x => !this.state.pinnedResources.includes(x.id));
11026
- const pinnedEvents = this.props.pinnedEvents !== undefined
11027
- ? this.props.pinnedEvents.filter(x => this.state.pinnedResources.includes(x.resourceId))
11028
- : new Array();
11029
- const notPinnedEvents = this.props.events.filter(x => !this.props.pinnedResources?.includes(x.resourceId));
11030
- return (jsxs("div", { className: "cwelltSuperScheduler_content", children: [jsx(CwScheduler, { id: "crewPinnedScheduler", events: pinnedEvents, resources: firstSchedulerResources, height: this.state.height, startDate: this.props.startDate, endDate: this.props.endDate, scheduler_handleCblEventClick: this.props.scheduler_handleCblEventClick, scheduler_handleCblEventClickRight: this.props.scheduler_handleCblEventClickRight, scheduler_handleCblEventDoubleClick: this.props.scheduler_handleCblEventDoubleClick, scheduler_handleOnDropCblEventsOnResource: this.props.scheduler_handleOnDropCblEventsOnResource, parent: this.props.parent, cblEventComp: this.props.cblEventComp, scheduler_handleOnClickEventContextMenu: this.props.scheduler_handleOnClickEventContextMenu, resourceComp: this.props.resourceComp, scheduler_handleOnClickContextMenuResource: this.props.scheduler_handleOnClickContextMenuResource, resourceContextMenuContents: this.props.resourceContextMenuContents, scheduler_handleDblClickOnResourceInScheduler: this.props.scheduler_handleDblClickOnResourceInScheduler, scheduler_handleEmptyClick: this.props.scheduler_handleEmptyClick, canBePinned: false, scheduler_handlePinned: this.scheduler_handlePinnedClick, resourceName: this.props.resourceName, descriptionColumn: this.props.descriptionColumn, scheduler_handleOnClickResourceContextMenu: this.props.scheduler_handleOnClickResourceContextMenu, groupByFunction: this.props.groupByFunction }), havePinnedResources && (jsx("div", { style: { padding: "0.5rem" }, children: jsx(CwButton, { text: "Clear", onClick: () => {
11031
- this.props.scheduler_handleClearPinnedOnParent();
11032
- } }) })), jsx(CwScheduler, { id: "crewAssignmentsScheduler", events: notPinnedEvents, resources: secondSchedulerResources, height: this.props.height, startDate: this.props.startDate, endDate: this.props.endDate, scheduler_handleCblEventClick: this.props.scheduler_handleCblEventClick, scheduler_handleCblEventClickRight: this.props.scheduler_handleCblEventClickRight, scheduler_handleCblEventDoubleClick: this.props.scheduler_handleCblEventDoubleClick, scheduler_handleOnDropCblEventsOnResource: this.props.scheduler_handleOnDropCblEventsOnResource, parent: this.props.parent, cblEventComp: this.props.cblEventComp, scheduler_handleOnClickEventContextMenu: this.props.scheduler_handleOnClickEventContextMenu, resourceComp: this.props.resourceComp, scheduler_handleOnClickContextMenuResource: this.handleOnClickContextMenuResource, resourceContextMenuContents: this.props.resourceContextMenuContents, scheduler_handleDblClickOnResourceInScheduler: this.props.scheduler_handleDblClickOnResourceInScheduler, scheduler_handleEmptyClick: this.props.scheduler_handleEmptyClick, canBePinned: true, scheduler_handlePinned: this.scheduler_handlePinnedClick, scheduler_handleCblEventResize: this.props.scheduler_handleCblEventResize, resourceName: this.props.resourceName, descriptionColumn: this.props.descriptionColumn, scheduler_handleOnClickResourceContextMenu: this.props.scheduler_handleOnClickResourceContextMenu, airportSelected: this.props.airportSelected, module: this.props.module, groupByFunction: this.props.groupByFunction })] }));
11033
- }
11034
- }
11035
- class CblDragAndDrop {
11036
- fromId;
11037
- toId;
11038
- data;
11039
- droppedOnDate;
11040
- resizeFromStart;
11041
- resizeFromEnd;
11042
- isCtrlKey;
11043
- constructor(fromId, toId, data, droppedOnDate = null, resizeFromStart = null, resizeFromEnd = null, isCtrlKey = null) {
11044
- this.fromId = fromId;
11045
- this.toId = toId;
11046
- this.data = data;
11047
- this.droppedOnDate = droppedOnDate;
11048
- this.resizeFromStart = resizeFromStart;
11049
- this.resizeFromEnd = resizeFromEnd;
11050
- this.isCtrlKey = isCtrlKey;
11051
- }
11052
- }
11053
-
11054
- const getGUID = () => {
11055
- return generateSegment(false) + generateSegment(true) + generateSegment(true) + generateSegment(false);
11056
- };
11057
- const generateSegment = (includeHyphens) => {
11058
- const p = (Math.random().toString(16) + "000000000").substring(2, 10);
11059
- return includeHyphens ? "-" + p.substring(0, 4) + "-" + p.substring(4, 8) : p;
11060
- };
11061
-
11062
- class cblEvent {
11063
- id = "";
11064
- start;
11065
- end;
11066
- resourceId;
11067
- selected = false;
11068
- top = 0;
11069
- leftPx = 0;
11070
- rightPx = 0;
11071
- width = 0;
11072
- isFullHeight = false;
11073
- isReadOnly = false;
11074
- isResizable = false;
11075
- isDraggable = false;
11076
- data = null;
11077
- constructor(start, end, resourceId, data = null, isFullHeight = false, isReadOnly = false, isResizable = false, isDraggable = false) {
11078
- this.start = start;
11079
- this.end = end;
11080
- this.resourceId = resourceId;
11081
- this.data = data;
11082
- this.isFullHeight = isFullHeight;
11083
- this.isReadOnly = isReadOnly;
11084
- this.isResizable = isResizable;
11085
- this.isDraggable = isDraggable;
11086
- this.id = getGUID();
11087
- }
11088
- }
11089
-
11090
- class Resource {
11091
- uid = "";
11092
- id;
11093
- name;
11094
- maxTop;
11095
- events = [];
11096
- isInViewport = false;
11097
- schedulerResourceDisplay;
11098
- isLoading = false;
11099
- data = null;
11100
- constructor(id, name, eventHeight, data = null, schedulerResourceDisplay = null) {
11101
- this.id = id;
11102
- this.name = name;
11103
- this.maxTop = eventHeight;
11104
- this.data = data;
11105
- this.schedulerResourceDisplay = schedulerResourceDisplay || this.name;
11106
- }
11107
- }
11108
-
11109
9736
  var styles = {"super-scheduler-row-header":"super-scheduler-module__super-scheduler-row-header__TTs4e","indicators":"super-scheduler-module__indicators__f4lIT","scheduler-crewmember-functions":"super-scheduler-module__scheduler-crewmember-functions__BS2hs"};
11110
9737
 
11111
9738
  class OnPinRow {
@@ -11588,4 +10215,4 @@ const CwFindCrewmember = ({ handleChange, placeHolder = "Search crew…", requir
11588
10215
  }, "data-direction": direction, children: [jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxs("div", { className: "cw-search-input-wrapper", ref: wrapperRef, children: [jsx("input", { ref: inputRef, type: "text", value: inputValue, onChange: handleInputChange, onKeyDown: handleKeyDown, onFocus: handleInputFocus, placeholder: isInitialLoading ? "Loading…" : placeHolder, disabled: disabled, required: required, autoComplete: "off", "aria-expanded": showDropdown, "aria-haspopup": "listbox", role: "combobox", title: tooltipText }), (isLoading || isInitialLoading) && (jsx("div", { className: "cw-search-input-loading", children: jsx(CwIcon, { iconId: "spinner" }) })), jsx("div", { className: "cw-search-input-icons", children: inputValue && !disabled && !isInitialLoading ? (jsx(CwButton, { type: "button", onClick: handleClear, "aria-label": "Clear selected crewmember", variant: "icon", icon: "close", color: "neutral" })) : (jsx(CwIcon, { iconId: "person" })) })] })] }), renderPanel(jsx("div", { ref: panelRef, className: dropdownStyles.dropdown, style: panelStyle, role: "listbox", children: jsx("ul", { children: options.map((option, index) => (jsx("li", { className: `${dropdownStyles.option}${index === highlightedIndex ? ` ${dropdownStyles.optionFocused}` : ""}`, onClick: () => handleOptionSelect(option.value), onMouseDown: (e) => e.preventDefault(), onMouseEnter: () => setHighlightedIndex(index), role: "option", "aria-selected": index === highlightedIndex, children: option.text }, option.value))) }) }))] }));
11589
10216
  };
11590
10217
 
11591
- export { CblDragAndDrop, CwAccordionContainer, CwAlign, CwAnchoredMenu, CwBtnApprove, CwBtnCancel, CwBtnDelete, CwBtnEdit, CwBtnSave, CwButton, CwButtonSplit, CwButtonSwitch, CwCard, CwCardList, CwCheck, CwCheckbox, CwCheckboxGroup, CwChip, CwColorPicker, CwConfirmationPopup, CwContextMenu, CwDatePicker, CwDatePickerTemporal, CwDateRangePicker, CwDateRangePickerTemporal, CwDateTimePicker, CwDateTimePickerCompact, CwDateTimePickerTemporal, CwDialog, CwDigit, CwDisplayMessage, CwDropdown, CwDropdownFilter, CwExpandable, CwFileUploadMultiple, CwFindAirport, CwFindCrewmember, CwGenericTooltip, CwHeadingMain, CwHeadingSecond, CwIcon, CwImageArea, CwImageGallery, CwImageZoom, CwInput, CwInputColor, CwInputDateText, CwInputDatetime, CwInputImage, CwInputNumber, CwInputPhone, CwInputText, CwKeyValueList, CwLabel, CwLoading, CwMasterDetail, CwMessage, CwMessageManager, CwMessageType, CwModal, CwModalHover, CwModalReportFunctional, CwMultiFilter, CwMultiFilterTag, CwNavMenu, CwNote, CwOption, CwPopoverButton, CwProgress, CwRadioGroup, CwReportModal, CwScheduler, CwSearchAsync, CwSearchInput, CwSelect, CwSelectList, CwSelectListItems, CwSkeleton, CwSortableList, CwSortableTable, CwSuperScheduler, CwTable, CwTableGrouped, CwTableServerSide, CwTabs, CwTagSelector, CwTextArea, CwTime, CwTimePicker, CwToggle, CwTooltipManager, CwTooltipNew, CwTreeView, CwWeekdaySelector, DefaultRowHeader, OnClearPinned, OnClickContextMenu, OnClickEvent, OnClickRowEvent, OnClickRowHeader, OnClickUtc, OnDoubleClickEvent, OnDoubleClickRowEvent, OnDragEvent, OnDropCtrlEvent, OnDropEvent, OnEndClickHeaderEvent, OnLeftDragStart, OnMultiClickEvent, OnPinRow, OnRangeClickEvent, OnRightClickEvent, OnRightClickRow, OnRightDragStart, OnStartClickHeaderEvent, OnUnpinRow, PRESET_LIBRARY_TEMPORAL, PinRowHeader, Resource, Scheduler, SchedulerEvent, SuperScheduler, TooltipConstraintContext, UiEvent, Weekdays, cblEvent, configureCwLoading, eventIsVisible, filterNavItems, filterVisibleEvents, getCwLoadingDefaults, getDefaultDivisions, getEventSizes, getPresetsByKeysTemporal, itemsToMultiFilterTags, sortNavItems, useCwMessage, useSortableList, useSortableTable, useTooltipConstraint };
10218
+ export { CwAccordionContainer, CwAlign, CwAnchoredMenu, CwBtnApprove, CwBtnCancel, CwBtnDelete, CwBtnEdit, CwBtnSave, CwButton, CwButtonSplit, CwButtonSwitch, CwCard, CwCardList, CwCheck, CwCheckbox, CwCheckboxGroup, CwChip, CwColorPicker, CwConfirmationPopup, CwContextMenu, CwDatePicker, CwDatePickerTemporal, CwDateRangePicker, CwDateRangePickerTemporal, CwDateTimePicker, CwDateTimePickerCompact, CwDateTimePickerTemporal, CwDialog, CwDigit, CwDisplayMessage, CwDropdown, CwDropdownFilter, CwExpandable, CwFileUploadMultiple, CwFindAirport, CwFindCrewmember, CwGenericTooltip, CwHeadingMain, CwHeadingSecond, CwIcon, CwImageArea, CwImageGallery, CwImageZoom, CwInput, CwInputColor, CwInputDateText, CwInputDatetime, CwInputImage, CwInputNumber, CwInputPhone, CwInputText, CwKeyValueList, CwLabel, CwLoading, CwMasterDetail, CwMessage, CwMessageManager, CwMessageType, CwModal, CwModalHover, CwModalReportFunctional, CwMultiFilter, CwMultiFilterTag, CwNavMenu, CwNote, CwOption, CwPopoverButton, CwProgress, CwRadioGroup, CwReportModal, CwSearchAsync, CwSearchInput, CwSelect, CwSelectList, CwSelectListItems, CwSkeleton, CwSortableList, CwSortableTable, CwTable, CwTableGrouped, CwTableServerSide, CwTabs, CwTagSelector, CwTextArea, CwTime, CwTimePicker, CwToggle, CwTooltipManager, CwTooltipNew, CwTreeView, CwWeekdaySelector, DefaultRowHeader, OnClearPinned, OnClickContextMenu, OnClickEvent, OnClickRowEvent, OnClickRowHeader, OnClickUtc, OnDoubleClickEvent, OnDoubleClickRowEvent, OnDragEvent, OnDropCtrlEvent, OnDropEvent, OnEndClickHeaderEvent, OnLeftDragStart, OnMultiClickEvent, OnPinRow, OnRangeClickEvent, OnRightClickEvent, OnRightClickRow, OnRightDragStart, OnStartClickHeaderEvent, OnUnpinRow, PRESET_LIBRARY_TEMPORAL, PinRowHeader, Scheduler, SchedulerEvent, SuperScheduler, TooltipConstraintContext, UiEvent, Weekdays, configureCwLoading, eventIsVisible, filterNavItems, filterVisibleEvents, getCwLoadingDefaults, getDefaultDivisions, getEventSizes, getPresetsByKeysTemporal, itemsToMultiFilterTags, sortNavItems, useCwMessage, useSortableList, useSortableTable, useTooltipConstraint };