@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.cjs.js CHANGED
@@ -3253,8 +3253,14 @@ function CwInput(CwInputProps) {
3253
3253
  * ```
3254
3254
  */
3255
3255
  function CwDigit(props) {
3256
- const { alignProps, buttonProps, iconProps, labelProps, ...inputProps } = props;
3257
- return (jsxRuntime.jsx("div", { className: "cw-input-text", children: jsxRuntime.jsxs(CwAlign, { ...alignProps, itemProp: inputProps.required === true ? "required" : "", children: [labelProps && (jsxRuntime.jsxs(CwLabel, { ...labelProps, children: [iconProps && jsxRuntime.jsx(CwIcon, { ...iconProps }), labelProps.text] })), jsxRuntime.jsx("input", { type: "number", ...inputProps }), buttonProps && jsxRuntime.jsx(CwButton, { ...buttonProps })] }) }));
3256
+ const { alignProps, buttonProps, iconProps, labelProps, feedback, ...inputProps } = props;
3257
+ const feedbackMessages = feedback
3258
+ ? Array.isArray(feedback) ? feedback : [feedback]
3259
+ : [];
3260
+ const feedbackId = React.useId();
3261
+ const feedbackIds = feedbackMessages.map((_, index) => `${feedbackId}-${index}`);
3262
+ const describedBy = [inputProps["aria-describedby"], ...feedbackIds].filter(Boolean).join(" ") || undefined;
3263
+ return (jsxRuntime.jsxs("div", { className: "cw-input-text", children: [jsxRuntime.jsxs(CwAlign, { ...alignProps, itemProp: inputProps.required === true ? "required" : "", children: [labelProps && (jsxRuntime.jsxs(CwLabel, { ...labelProps, children: [iconProps && jsxRuntime.jsx(CwIcon, { ...iconProps }), labelProps.text] })), jsxRuntime.jsx("input", { type: "number", ...inputProps, "aria-describedby": describedBy }), buttonProps && jsxRuntime.jsx(CwButton, { ...buttonProps })] }), feedbackMessages.map((feedbackItem, index) => (jsxRuntime.jsx("p", { id: feedbackIds[index], className: "cw-input-info", "data-color": feedbackItem.type, "aria-live": "polite", children: feedbackItem.message }, index)))] }));
3258
3264
  }
3259
3265
 
3260
3266
  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"};
@@ -3468,7 +3474,7 @@ const CwColorPicker = ({ initialColor, onChange, previewText = "Color preview" }
3468
3474
 
3469
3475
  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"};
3470
3476
 
3471
- const CwInputColor = ({ value, onChange, previewText = "Color preview", disabled = false, readOnly = false, width = '4rem', height = '2rem', labelProps, layoutProps, }) => {
3477
+ const CwInputColor = ({ value, onChange, previewText = "Color preview", disabled = false, readOnly = false, width = '4rem', height = '2rem', labelProps, layoutProps, className, style, }) => {
3472
3478
  const [isOpen, setIsOpen] = React.useState(false);
3473
3479
  const containerRef = React.useRef(null);
3474
3480
  const dropdownRef = React.useRef(null);
@@ -3599,7 +3605,7 @@ const CwInputColor = ({ value, onChange, previewText = "Color preview", disabled
3599
3605
  break;
3600
3606
  }
3601
3607
  };
3602
- return (jsxRuntime.jsxs("div", { className: `cw-input-color ${styles$i.container}`, "data-direction": layoutProps?.direction ?? "row", "data-align": layoutProps?.align, children: [labelProps && (jsxRuntime.jsx(CwLabel, { ...labelProps })), jsxRuntime.jsx("div", { ref: containerRef, onClick: handleToggle, className: `${styles$i.selectColor} ${disabled ? styles$i.disabled : ''} ${readOnly ? styles$i.readOnly : ''}`, style: {
3608
+ return (jsxRuntime.jsxs("div", { className: `cw-input-color ${styles$i.container}${className ? ` ${className}` : ''}`, style: style, "data-direction": layoutProps?.direction ?? "row", "data-align": layoutProps?.align, children: [labelProps && (jsxRuntime.jsx(CwLabel, { ...labelProps })), jsxRuntime.jsx("div", { ref: containerRef, onClick: handleToggle, className: `${styles$i.selectColor} ${disabled ? styles$i.disabled : ''} ${readOnly ? styles$i.readOnly : ''}`, style: {
3603
3609
  width,
3604
3610
  height,
3605
3611
  backgroundColor: value,
@@ -8673,1066 +8679,6 @@ function CwDateRangePickerTemporal({ value, onChange, minDate, maxDate, disabled
8673
8679
  } })] }), jsxRuntime.jsx("div", { role: "alert", "aria-live": "polite", className: rangeStyles.rangeError, children: rangeErrorMessage })] }))] })] }) }));
8674
8680
  }
8675
8681
 
8676
- const ResourcesTitleList = ({ resources, canBePinned, includesPinned, onCrewPinning, onClickResourceContextMenu, ResourceTitleComponent, }) => {
8677
- const onClickContextMenu = React.useCallback((key, resource) => {
8678
- if (onClickResourceContextMenu) {
8679
- onClickResourceContextMenu(key, resource);
8680
- }
8681
- }, []);
8682
- return (jsxRuntime.jsx("td", { className: "resourceArea", style: { width: "100px" }, children: resources.map((r, _i) => (jsxRuntime.jsxs("div", { className: "resource CwelltFunctionDescription", style: { height: r.maxTop }, children: [(canBePinned || includesPinned) && (jsxRuntime.jsx(PinButton, { canBePinned: canBePinned, resource: r, onCrewPinning: onCrewPinning })), jsxRuntime.jsx(ResourceTitleComponent, { resource: r, handleOnClickResourceContextMenu: onClickContextMenu })] }, r.id.toString()))) }));
8683
- };
8684
- const PinButton = ({ canBePinned, resource, onCrewPinning }) => {
8685
- const buttonProps = canBePinned
8686
- ? {
8687
- id: "cbl_pinL",
8688
- onClick: () => onCrewPinning(resource, ""),
8689
- children: jsxRuntime.jsx("span", { className: "cwi-pin", style: { visibility: "visible" } }),
8690
- }
8691
- : {
8692
- id: "cbl_pinLess45deg",
8693
- onClick: () => onCrewPinning(resource, "remove"),
8694
- children: jsxRuntime.jsx("span", { className: "cwi-pinned cwi-pin", style: { visibility: "visible" } }),
8695
- };
8696
- return jsxRuntime.jsx("button", { className: "cw-button-icon cw-icon-pin", ...buttonProps });
8697
- };
8698
-
8699
- const addMinutesToDateFromPx = (originalDate, leftPx, minutesPerPx) => {
8700
- const minutes = leftPx / minutesPerPx;
8701
- const datePlusMinutes = new Date(originalDate.getTime() + minutes * 60000);
8702
- return datePlusMinutes;
8703
- };
8704
-
8705
- const doubleClickOnResource = (props, resource) => {
8706
- if (props.scheduler_handleDblClickOnResourceInScheduler) {
8707
- props.scheduler_handleDblClickOnResourceInScheduler(resource);
8708
- }
8709
- };
8710
-
8711
- let CblDragAndDrop$1 = class CblDragAndDrop {
8712
- fromId;
8713
- toId;
8714
- data;
8715
- droppedOnDate;
8716
- resizeFromStart;
8717
- resizeFromEnd;
8718
- isCtrlKey;
8719
- constructor(fromId, toId, data, droppedOnDate = null, resizeFromStart = null, resizeFromEnd = null, isCtrlKey = null) {
8720
- this.fromId = fromId;
8721
- this.toId = toId;
8722
- this.data = data;
8723
- this.droppedOnDate = droppedOnDate;
8724
- this.resizeFromStart = resizeFromStart;
8725
- this.resizeFromEnd = resizeFromEnd;
8726
- this.isCtrlKey = isCtrlKey;
8727
- }
8728
- };
8729
-
8730
- const BIRTHDATE = 15;
8731
- const NOT_WORKING = 16;
8732
- const REST_TIME = 10;
8733
- const MAX_FLIGHT_DUTY_PERIOD = 11;
8734
- const DUTY_REGULATION = 20;
8735
- const unHandleableEvents = [REST_TIME, MAX_FLIGHT_DUTY_PERIOD, NOT_WORKING, DUTY_REGULATION];
8736
- const getEventStyle = (event, reslTime) => {
8737
- const baseStyle = {
8738
- left: event.leftPx,
8739
- width: event.width,
8740
- top: event.top,
8741
- overflow: "hidden",
8742
- zIndex: event.isFullHeight ? 4 : 5,
8743
- };
8744
- if (event.data.eventType === BIRTHDATE) {
8745
- return {
8746
- ...baseStyle,
8747
- height: event.isFullHeight ? "100%" : "auto",
8748
- marginTop: event.isFullHeight ? -1 * event.top : 0,
8749
- pointerEvents: "none",
8750
- borderBottom: "solid 1px rgba(0, 0, 0, 0.4)",
8751
- backgroundColor: event.data.category.color || "orange",
8752
- display: "flex",
8753
- opacity: 0.3,
8754
- alignItems: "flex-end",
8755
- };
8756
- }
8757
- if ([REST_TIME, MAX_FLIGHT_DUTY_PERIOD, DUTY_REGULATION].includes(event.data.eventType)) {
8758
- return {
8759
- ...baseStyle,
8760
- zIndex: event.isFullHeight ? 4 : 6,
8761
- marginTop: event.isFullHeight ? -1 * event.top : 0,
8762
- borderRadius: "0px",
8763
- backgroundColor: event.data.category.color || "grey",
8764
- opacity: 0.3,
8765
- borderBottom: event.data.eventType === DUTY_REGULATION ? "solid 1px rgba(0, 0, 0, 0.4)" : "",
8766
- };
8767
- }
8768
- return {
8769
- ...baseStyle,
8770
- height: event.isFullHeight ? "100%" : "auto",
8771
- marginTop: event.isFullHeight ? -1 * event.top : 0,
8772
- borderRadius: reslTime <= 0.99 ? "3px" : "5px",
8773
- minWidth: reslTime <= 1.5 ? "5px" : "",
8774
- maxWidth: reslTime <= 1.5 ? "25px" : "",
8775
- };
8776
- };
8777
- const EventRender = ({ event, schedulerProps }) => {
8778
- const dateStart = new Date(event.data.start);
8779
- const dateEnd = new Date(event.data.end);
8780
- const reslTime = (dateEnd.getTime() - dateStart.getTime()) / 3600000;
8781
- const eventStyle = getEventStyle(event, reslTime);
8782
- const onClickEvent = (e) => {
8783
- if (!unHandleableEvents.includes(event.data.eventType)) {
8784
- e.stopPropagation();
8785
- const props = schedulerProps;
8786
- props.scheduler_handleCblEventClick.call(props.parent, event, schedulerProps.id);
8787
- }
8788
- };
8789
- const onRightClickEvent = (e) => {
8790
- if (!unHandleableEvents.includes(event.data.eventType)) {
8791
- e.stopPropagation();
8792
- const props = schedulerProps;
8793
- if (props.scheduler_handleCblEventClickRight) {
8794
- props.scheduler_handleCblEventClickRight.call(props.parent, event, schedulerProps.id);
8795
- }
8796
- }
8797
- };
8798
- const safeHandleDragStart = (e, isLeft, isRight) => {
8799
- if (!unHandleableEvents.includes(event.data.eventType)) {
8800
- handleDragStart(e, isLeft, isRight);
8801
- }
8802
- };
8803
- const handleDragStart = (e, isResizeFromStart, isResizeFromEnd) => {
8804
- if (!unHandleableEvents.includes(event.data.eventType)) {
8805
- [].forEach.call(document.querySelectorAll(".ant-tooltip"), function (el) {
8806
- el.style.visibility = "hidden";
8807
- });
8808
- // We don't know in which case is necessary
8809
- if (e.target !== e.currentTarget) {
8810
- // e.preventDefault();
8811
- return;
8812
- }
8813
- const isResize = isResizeFromStart || isResizeFromEnd;
8814
- const isAllowed = !event.isReadOnly && (isResize ? event.isResizable : event.isDraggable);
8815
- if (!isAllowed) {
8816
- e.preventDefault();
8817
- return;
8818
- }
8819
- const cblDragNDrop = new CblDragAndDrop$1(schedulerProps.id, null, [event], null, isResizeFromStart, isResizeFromEnd);
8820
- if (!isResize) {
8821
- e.dataTransfer.dropEffect = e.ctrlKey ? "copy" : "link";
8822
- }
8823
- e.dataTransfer.setData("data", JSON.stringify(cblDragNDrop));
8824
- }
8825
- };
8826
- const handleDoubleClick = (e) => {
8827
- if (!unHandleableEvents.includes(event.data.eventType)) {
8828
- e.preventDefault();
8829
- e.stopPropagation();
8830
- const props = schedulerProps;
8831
- props.scheduler_handleCblEventDoubleClick.call(props.parent, event, schedulerProps.id);
8832
- }
8833
- };
8834
- const onClickContextMenu = (e) => {
8835
- if (!unHandleableEvents.includes(event.data.eventType)) {
8836
- const props = schedulerProps;
8837
- if (props.scheduler_handleOnClickEventContextMenu) {
8838
- props.scheduler_handleOnClickEventContextMenu(e, event);
8839
- }
8840
- }
8841
- };
8842
- const renderBirthdayEvent = () => (jsxRuntime.jsxs("div", { className: `fc-timeline-event cwellt_timeline_event cwellt_event_bday ${event.selected ? "cblEventSelected" : ""}`, style: eventStyle, children: [jsxRuntime.jsx("span", { className: "cwi-icons cwi-birthday", style: { visibility: "visible" } }), event.data.subject && jsxRuntime.jsx("span", { style: { lineHeight: "1em" }, children: event.data.subject })] }, event.id));
8843
- const renderRegularEvent = () => (jsxRuntime.jsxs("div", { draggable: ![10, 11, 16, 20, 21].includes(event.data.eventType), className: "fc-timeline-event cwellt_timeline_event " +
8844
- (event.selected === true ? "cblEventSelected " : "") +
8845
- (event.data.eventType === REST_TIME ||
8846
- event.data.eventType === MAX_FLIGHT_DUTY_PERIOD ||
8847
- event.data.eventType === DUTY_REGULATION
8848
- ? " cwellt_event_bhnd_appt "
8849
- : " "), style: eventStyle, onClick: onClickEvent, onContextMenu: onRightClickEvent, onDragStart: (e) => safeHandleDragStart(e, false, false), onDoubleClick: handleDoubleClick, children: [schedulerProps.scheduler_handleCblEventResize &&
8850
- !event.isReadOnly &&
8851
- !unHandleableEvents.includes(event.data.eventType) && (jsxRuntime.jsx("span", { draggable: true, onDragStart: (e) => handleDragStart(e, true, false), style: {
8852
- position: "absolute",
8853
- cursor: "e-resize",
8854
- zIndex: 10,
8855
- left: "0",
8856
- border: "solid 1px rgba(46,49,49,0.5)",
8857
- }, children: "\u200B" })), jsxRuntime.jsx(schedulerProps.cblEventComp, { cblEvent: event, handleOnClickEventContextMenu: onClickContextMenu }, event.id), schedulerProps.scheduler_handleCblEventResize &&
8858
- !event.isReadOnly &&
8859
- !unHandleableEvents.includes(event.data.eventType) && (jsxRuntime.jsx("span", { draggable: true, onDragStart: (e) => handleDragStart(e, false, true), style: {
8860
- position: "absolute",
8861
- right: "0",
8862
- cursor: "e-resize",
8863
- zIndex: 10,
8864
- border: "solid 1px rgba(46,49,49,0.5)",
8865
- marginTop: "-25px",
8866
- }, children: "\u200B" }))] }, event.id));
8867
- const render = event.data.eventType === BIRTHDATE ? renderBirthdayEvent() : renderRegularEvent();
8868
- return render;
8869
- };
8870
-
8871
- const onDropEventToResource = (props, cblDragNDrop, resource) => {
8872
- props.scheduler_handleOnDropCblEventsOnResource.call(props.parent, cblDragNDrop, resource);
8873
- };
8874
-
8875
- const isAllowedToMove = (data, resData, cblDragNDrop) => {
8876
- if (data?.eventType !== 1) {
8877
- return true;
8878
- }
8879
- const allowedMoves = [
8880
- { from: "acftsScheduler", to: "flightsPairingsScheduler" },
8881
- { from: "flightsScheduler", to: "crewAssignmentsScheduler" },
8882
- { from: "opstoolScheduler", to: "opstoolScheduler" },
8883
- { from: "opstoolScheduler", to: "opstoolSchedulerVirtual" },
8884
- { from: "opstoolSchedulerVirtual", to: "opstoolScheduler" },
8885
- { from: "opstoolSchedulerVirtual", to: "opstoolSchedulerVirtual" },
8886
- { from: "vacationsScheduler", to: "vacationsScheduler" }
8887
- ];
8888
- const crewControllAllowedMove = allowedMoves.some(move => move.from === cblDragNDrop.fromId && move.to === cblDragNDrop.toId);
8889
- if (crewControllAllowedMove) {
8890
- return true;
8891
- }
8892
- return data.Crew !== resData.Crewmember_Id;
8893
- };
8894
-
8895
- const OnDrop = ({ e, resource, id, contentArea, state, schedulerProps }) => {
8896
- e.dataTransfer.dropEffect = "move";
8897
- const cblDragNDrop = JSON.parse(e.dataTransfer.getData("data"));
8898
- if (!cblDragNDrop.data || !cblDragNDrop.data[0]) {
8899
- return;
8900
- }
8901
- cblDragNDrop.toId = id;
8902
- const obj = cblDragNDrop.data[0];
8903
- cblDragNDrop.isCtrlKey = e.ctrlKey;
8904
- const isResizeEvent = cblDragNDrop.resizeFromStart === true || cblDragNDrop.resizeFromEnd === true;
8905
- if (isResizeEvent) {
8906
- // Resize
8907
- if (obj.data === undefined || obj.data.eventType === 1) {
8908
- return;
8909
- }
8910
- const _eventX = e.clientX;
8911
- const _caLeft = contentArea?.getBoundingClientRect()?.left ?? 0;
8912
- const leftPos = _eventX - _caLeft;
8913
- let droppedDate = addMinutesToDateFromPx(schedulerProps.startDate, leftPos, state.minutePx);
8914
- if (cblDragNDrop.resizeFromEnd === true) {
8915
- const eventStart = new Date(Date.parse(obj.start));
8916
- droppedDate = droppedDate < eventStart ? eventStart : droppedDate;
8917
- }
8918
- if (cblDragNDrop.resizeFromStart === true) {
8919
- const eventEnd = new Date(Date.parse(obj.end));
8920
- // 3 hours before is the minimun size in the backend
8921
- eventEnd.setHours(eventEnd.getHours() - 3);
8922
- droppedDate = droppedDate > eventEnd ? eventEnd : droppedDate;
8923
- }
8924
- cblDragNDrop.droppedOnDate = droppedDate;
8925
- schedulerProps.scheduler_handleCblEventResize?.call(schedulerProps.parent, cblDragNDrop);
8926
- return;
8927
- }
8928
- // Drag & Drop
8929
- if (!isAllowedToMove(obj.data, resource.data, cblDragNDrop)) {
8930
- return;
8931
- }
8932
- const d = e.clientX - (contentArea?.getBoundingClientRect()?.left ?? 0);
8933
- const date = new Date(schedulerProps.startDate.getTime() + (d / state.minutePx) * 60000);
8934
- cblDragNDrop.droppedOnDate = date;
8935
- onDropEventToResource(schedulerProps, cblDragNDrop, resource);
8936
- };
8937
-
8938
- const onDragOver = (e) => {
8939
- if (e.ctrlKey === true) {
8940
- e.dataTransfer.dropEffect = "copy";
8941
- }
8942
- else {
8943
- e.dataTransfer.dropEffect = "link";
8944
- }
8945
- e.preventDefault();
8946
- };
8947
-
8948
- const arePropsEqual = (prevProps, nextProps) => {
8949
- return prevProps.res.events === nextProps.res.events && prevProps.isInViewport === nextProps.isInViewport;
8950
- };
8951
- const ResourceRender = React.memo(({ res, schedulerProps, contentArea, state }) => {
8952
- return (jsxRuntime.jsx("div", { style: {
8953
- backgroundColor: "#F9F8F8",
8954
- height: res.maxTop,
8955
- width: "100%",
8956
- position: "relative",
8957
- borderBottom: "1px solid rgb(255,255,255)",
8958
- }, onDragOver: (e) => onDragOver(e), onDrop: (e) => {
8959
- OnDrop({
8960
- e,
8961
- resource: res,
8962
- id: schedulerProps.id,
8963
- contentArea,
8964
- state,
8965
- schedulerProps,
8966
- });
8967
- }, className: "cwellt_divRow_schContent", children: res.events.map((evnt) => (jsxRuntime.jsx(EventRender, { event: evnt, schedulerProps: schedulerProps }, evnt.id))) }, res.id));
8968
- }, arePropsEqual);
8969
-
8970
- const ResourceListRender = ({ resources, schedulerProps, state, contentArea,
8971
- // onClickContextMenu,
8972
- crewAssignmentSchedulerContextMenu, }) => {
8973
- return (jsxRuntime.jsx(React.Fragment, { children: resources.map((r, _i) => (jsxRuntime.jsx(CwAnchoredMenu, { placement: "bottom", onContextMenu: (e) => {
8974
- // Dirty temporal solution to remove ANT design, this can be killed when this scheduler is deprecated
8975
- const leftPos = e.currentTarget.getBoundingClientRect().left -
8976
- (contentArea?.getBoundingClientRect()?.left ?? 0) -
8977
- window.scrollX;
8978
- const calculatedDatetime = addMinutesToDateFromPx(schedulerProps.startDate, leftPos, state.minutePx);
8979
- r.__contextMenuDatetime = calculatedDatetime;
8980
- }, options: crewAssignmentSchedulerContextMenu?.map(m => ({
8981
- key: m.key,
8982
- label: (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("span", { className: m.icon, style: { color: m.color } }), jsxRuntime.jsx("span", { children: m.text })] }))
8983
- })) ?? [], onSelect: (key) => {
8984
- const datetime = r.__contextMenuDatetime ?? new Date();
8985
- if (schedulerProps.scheduler_handleOnClickContextMenuResource) {
8986
- schedulerProps.scheduler_handleOnClickContextMenuResource(datetime, r, key, schedulerProps.id);
8987
- }
8988
- }, children: jsxRuntime.jsx("span", { onDoubleClick: () => doubleClickOnResource(schedulerProps, r), id: schedulerProps.id + "_" + r.id, children: jsxRuntime.jsx(ResourceRender, { res: r, schedulerProps: schedulerProps, contentArea: contentArea, state: state, isInViewport: r.isInViewport }, r.id) }) }, r.id))) }));
8989
- };
8990
-
8991
- const TimeLine$1 = ({ id, toolTipTitle, marginLeft, color = "rgba(255,0,0,.6)", pixels = 2, height = "100%", zIndex = 1, }) => {
8992
- return (jsxRuntime.jsx(CwTooltipNew, { content: toolTipTitle, position: "top", children: jsxRuntime.jsx("div", { id: id, style: {
8993
- borderLeft: `${pixels}px solid ${color}`,
8994
- marginLeft: marginLeft,
8995
- width: "0px",
8996
- height: height,
8997
- position: "absolute",
8998
- zIndex: zIndex,
8999
- } }) }));
9000
- };
9001
-
9002
- const SchedulerContentArea = ({ now, showTimeline, timeLineLeftPx, timeSeparatorLeftPx, resources, scheduler, contextMenuContents, onEmptyClick, setContentArea, onClickContextMenu, }) => {
9003
- return (jsxRuntime.jsxs("td", { className: "contentArea", style: { width: "100%", overflow: "hidden", position: "relative" }, ref: (reference) => {
9004
- if (reference) {
9005
- setContentArea(reference);
9006
- }
9007
- }, children: [showTimeline && (jsxRuntime.jsx(TimeLine$1, { id: scheduler.props.id + "_timeline", marginLeft: timeLineLeftPx, zIndex: 8, toolTipTitle: Temporal.PlainTime.from({
9008
- hour: now.getHours(),
9009
- minute: now.getMinutes(),
9010
- }).toString({ smallestUnit: "minute" }) })), timeSeparatorLeftPx.map((pixels) => {
9011
- return jsxRuntime.jsx(TimeLine$1, { marginLeft: pixels, color: "rgba(255,255,255,0.7)" });
9012
- }), jsxRuntime.jsx("span", { onClick: () => {
9013
- if (onEmptyClick) {
9014
- onEmptyClick(scheduler.props.id);
9015
- }
9016
- }, children: jsxRuntime.jsx(ResourceListRender, { resources: resources, state: scheduler.state, schedulerProps: scheduler.props, contentArea: scheduler.contentArea, onClickContextMenu: onClickContextMenu, crewAssignmentSchedulerContextMenu: contextMenuContents }) })] }));
9017
- };
9018
-
9019
- const daysBetweenTwoDates = (date1, date2) => {
9020
- const diff = Math.abs(date1.getTime() - date2.getTime());
9021
- let diffDays = 0;
9022
- const startOffset = Math.abs(date1.getTimezoneOffset());
9023
- const endOffset = Math.abs(date2.getTimezoneOffset());
9024
- // Summer: +1 -> +2, true
9025
- // Winter: +2 -> -1, false
9026
- if (startOffset > endOffset) {
9027
- diffDays = Math.floor(diff / (1000 * 3600 * 24));
9028
- }
9029
- else {
9030
- diffDays = Math.ceil(diff / (1000 * 3600 * 24));
9031
- }
9032
- return diffDays;
9033
- };
9034
-
9035
- const calculateDivisionType = (start, end) => {
9036
- const diffDays = daysBetweenTwoDates(start, end);
9037
- if (diffDays <= 15) {
9038
- return "d";
9039
- }
9040
- else if (diffDays <= 30) {
9041
- return "w";
9042
- }
9043
- else {
9044
- return "m";
9045
- }
9046
- };
9047
-
9048
- const getMonthHeaderData = (dates, maxWidth) => {
9049
- if (dates.length === 0)
9050
- return [];
9051
- const dayWidth = maxWidth / dates.length;
9052
- const ranges = getMonthRanges(dates);
9053
- return ranges.map((range) => {
9054
- return {
9055
- monthFormatted: range.start.getMonth() + 1 + "." + range.start.getFullYear(),
9056
- width: dayWidth * range.daysLong,
9057
- };
9058
- });
9059
- };
9060
- const getMonthRanges = (dates) => {
9061
- const firstDay = dates[0];
9062
- const lastDay = dates[dates.length - 1];
9063
- let currentDate = new Date(firstDay);
9064
- const ranges = [];
9065
- while (currentDate <= lastDay) {
9066
- const rangeStart = new Date(currentDate);
9067
- let rangeEnd = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 0);
9068
- if (rangeEnd >= lastDay) {
9069
- rangeEnd = lastDay;
9070
- }
9071
- ranges.push({
9072
- start: rangeStart,
9073
- daysLong: getDaysBetweenDates(rangeStart, rangeEnd),
9074
- });
9075
- currentDate = new Date(rangeEnd.getFullYear(), rangeEnd.getMonth() + 1, 1);
9076
- }
9077
- return ranges;
9078
- };
9079
- const getDaysBetweenDates = (startDate, endDate) => {
9080
- const timeDifference = endDate.getTime() - startDate.getTime();
9081
- return Math.floor(timeDifference / (1000 * 60 * 60 * 24)) + 1;
9082
- };
9083
-
9084
- const getWeekHeaderDataFromWeekRange = (weekRange, maxWidth, dateFormatter) => weekRange.map(week => {
9085
- const numberOfDaysInScheduler = weekRange
9086
- .flatMap(element => {
9087
- return element.days;
9088
- })
9089
- .reduce((el1, el2) => {
9090
- return el1 + el2;
9091
- });
9092
- return {
9093
- formattedString: getStringForWeekRange(week, dateFormatter),
9094
- width: getWidthForWeekRange(maxWidth, week.days, numberOfDaysInScheduler)
9095
- };
9096
- });
9097
- const getStringForWeekRange = (weekRange, dateFormatter) => weekRange.days == 1
9098
- ? dateFormatter(weekRange.start)
9099
- : `${dateFormatter(weekRange.start)} - ${dateFormatter(weekRange.end)}`;
9100
- const getWidthForWeekRange = (maxWidth, weekDays, monthDays) => {
9101
- const dayWidth = maxWidth / monthDays;
9102
- return dayWidth * weekDays;
9103
- };
9104
-
9105
- // stringRange: `${formatter(date)} - ${formatter(end)}`,
9106
- const listOfDatesToWeekRangeList = (dates) => {
9107
- if (dates.length === 0) {
9108
- return [];
9109
- }
9110
- const datesToReturn = [];
9111
- dates.forEach((date, index) => {
9112
- const dayOfWeek = date.getDay();
9113
- const isFirstDay = index === 0;
9114
- const isLastDay = index === dates.length - 1;
9115
- const isSunday = dayOfWeek === 0;
9116
- const isMonday = dayOfWeek === 1;
9117
- if (isFirstDay && !isSunday) {
9118
- datesToReturn.push(createWeekRange(date, 8 - dayOfWeek));
9119
- return;
9120
- }
9121
- if (isLastDay && !isSunday) {
9122
- if (!isMonday) {
9123
- datesToReturn.pop();
9124
- }
9125
- const firstOfWeek = getFirstDayOfWeek(date);
9126
- datesToReturn.push(createWeekRange(firstOfWeek, dayOfWeek));
9127
- return;
9128
- }
9129
- if (isMonday) {
9130
- datesToReturn.push(createWeekRange(date, 7));
9131
- return;
9132
- }
9133
- // this is because sunday is 0
9134
- if (isFirstDay && isSunday) {
9135
- datesToReturn.push(createWeekRange(date, 1));
9136
- return;
9137
- }
9138
- });
9139
- return datesToReturn;
9140
- };
9141
- const createWeekRange = (start, days) => {
9142
- const end = new Date(start);
9143
- end.setDate(end.getDate() + days - 1);
9144
- return {
9145
- days,
9146
- start,
9147
- end,
9148
- isShortWeek: days < 7
9149
- };
9150
- };
9151
- const getFirstDayOfWeek = (date) => {
9152
- const currentDate = new Date(date);
9153
- const dayOfWeek = currentDate.getDay();
9154
- // dayOfWeek 0 == (Sunday)
9155
- const diffToMonday = dayOfWeek === 0 ? 6 : dayOfWeek - 1;
9156
- // Set the date to the first day of the week
9157
- currentDate.setDate(currentDate.getDate() - diffToMonday);
9158
- return currentDate;
9159
- };
9160
-
9161
- const DayHeader = ({ index, text, width, headerType }) => {
9162
- const isFirstDay = index == 0;
9163
- return (jsxRuntime.jsx("td", { style: {
9164
- display: "inline-block",
9165
- fontSize: "10px",
9166
- width: width,
9167
- maxWidth: width,
9168
- }, id: headerType + index, children: jsxRuntime.jsx("span", { className: isFirstDay ? "cwelltFirstDate_desc" : "", children: text }) }));
9169
- };
9170
-
9171
- const MonthHeader = ({ index, text, width, headerType }) => {
9172
- return (jsxRuntime.jsx("td", { style: {
9173
- display: "inline-block",
9174
- fontSize: "10px",
9175
- width: width,
9176
- maxWidth: width,
9177
- }, id: headerType + index, children: jsxRuntime.jsx("span", { children: text }) }));
9178
- };
9179
-
9180
- const WeekHeader = ({ index, text, width, headerType }) => {
9181
- const isFirstDay = index == 0;
9182
- return (jsxRuntime.jsx("td", { style: {
9183
- display: "inline-block",
9184
- fontSize: "10px",
9185
- width: width,
9186
- maxWidth: width,
9187
- }, id: headerType + index, children: jsxRuntime.jsx("span", { className: isFirstDay ? "cwelltFirstDate_desc" : "", style: { whiteSpace: "nowrap" }, children: text }) }));
9188
- };
9189
-
9190
- const DaysHeader = ({ days, divisionType, maxWidth, headerType }) => {
9191
- let headerToDraw = [];
9192
- const filteredDays = days.filter((date) => {
9193
- return date.getHours() === 0;
9194
- });
9195
- const dateFormatter = (date) => {
9196
- return `${date.getDate()}.${date.getMonth() + 1}.${date.getFullYear()}`;
9197
- };
9198
- switch (divisionType) {
9199
- case "d":
9200
- {
9201
- headerToDraw = filteredDays.map((date, index) => {
9202
- return (jsxRuntime.jsx(DayHeader, { text: dateFormatter(date), index: index, width: maxWidth / filteredDays.length, headerType: headerType }, index));
9203
- });
9204
- }
9205
- break;
9206
- case "w":
9207
- {
9208
- const weekRanges = listOfDatesToWeekRangeList(filteredDays);
9209
- headerToDraw = getWeekHeaderDataFromWeekRange(weekRanges, maxWidth, dateFormatter).map((week, index) => {
9210
- return (jsxRuntime.jsx(WeekHeader, { index: index, text: week.formattedString, width: week.width, headerType: headerType }, index));
9211
- });
9212
- }
9213
- break;
9214
- case "m":
9215
- {
9216
- const monthData = getMonthHeaderData(filteredDays, maxWidth);
9217
- headerToDraw = monthData.map(({ monthFormatted, width }, index) => (jsxRuntime.jsx(MonthHeader, { index: index, text: monthFormatted, width: width, headerType: headerType }, index)));
9218
- }
9219
- break;
9220
- }
9221
- return jsxRuntime.jsx("tr", { className: "cwelltSchRowDate", children: headerToDraw });
9222
- };
9223
-
9224
- function formatHHmm(date) {
9225
- const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
9226
- const zdt = Temporal.Instant.fromEpochMilliseconds(date.getTime()).toZonedDateTimeISO(timeZone);
9227
- return `${zdt.hour.toString().padStart(2, "0")}:${zdt.minute.toString().padStart(2, "0")}`;
9228
- }
9229
- const getFormattedTimeForHeader = (calculatedDivType, calculatedDivision, timeHeader) => {
9230
- let showDate = "";
9231
- switch (calculatedDivType) {
9232
- case "d":
9233
- switch (calculatedDivision) {
9234
- case 8:
9235
- showDate =
9236
- timeHeader.getHours() === 0 ||
9237
- timeHeader.getHours() === 3 ||
9238
- timeHeader.getHours() === 6 ||
9239
- timeHeader.getHours() === 9 ||
9240
- timeHeader.getHours() === 12 ||
9241
- timeHeader.getHours() === 15 ||
9242
- timeHeader.getHours() === 18 ||
9243
- timeHeader.getHours() === 21
9244
- ? formatHHmm(timeHeader)
9245
- : "";
9246
- break;
9247
- case 3:
9248
- showDate =
9249
- timeHeader.getHours() === 0 || timeHeader.getHours() === 8 || timeHeader.getHours() === 16
9250
- ? formatHHmm(timeHeader)
9251
- : "";
9252
- break;
9253
- case 2:
9254
- showDate =
9255
- timeHeader.getHours() === 0 || timeHeader.getHours() === 12 ? formatHHmm(timeHeader) : "";
9256
- break;
9257
- }
9258
- break;
9259
- case "m":
9260
- showDate = timeHeader.getHours() === 0 ? timeHeader.getDate().toString() : "";
9261
- break;
9262
- case "w":
9263
- showDate = timeHeader.getHours() === 0 ? timeHeader.getDate().toString() : "";
9264
- break;
9265
- }
9266
- return {
9267
- text: showDate,
9268
- isWeekend: timeHeader.getDay() === 6 || timeHeader.getDay() === 0,
9269
- };
9270
- };
9271
-
9272
- const calculateDivisions = (start, end) => {
9273
- const diffDays = daysBetweenTwoDates(start, end);
9274
- if (diffDays <= 3) {
9275
- return 8;
9276
- }
9277
- else if (diffDays < 8) {
9278
- return 3;
9279
- }
9280
- else if (diffDays <= 15) {
9281
- return 2;
9282
- }
9283
- else {
9284
- return 1;
9285
- }
9286
- };
9287
-
9288
- const TimeHeader = ({ isWeekend, index, text, width, header }) => {
9289
- if (text === "") {
9290
- return;
9291
- }
9292
- const commonStyles = {
9293
- display: "flex",
9294
- alignItems: "center",
9295
- justifyContent: "left",
9296
- fontSize: "10px",
9297
- width: width,
9298
- maxWidth: width,
9299
- height: "30px",
9300
- borderLeft: "1px solid white",
9301
- background: isWeekend ? "#cbc9c9" : "",
9302
- color: "#000000d9",
9303
- fontWeight: 700,
9304
- };
9305
- return (jsxRuntime.jsx("td", { style: commonStyles, id: `${header}Time${index}`, children: jsxRuntime.jsx("span", { style: { paddingLeft: "8px" }, children: text }) }, `t${index}`));
9306
- };
9307
-
9308
- const TimeHeaderRow = ({ timeHeaders, startDate, endDate, maxWidth, header }) => {
9309
- const calculatedDivision = calculateDivisions(startDate, endDate);
9310
- const calculatedDivType = calculateDivisionType(startDate, endDate);
9311
- const formattedHeaders = timeHeaders.map((th) => {
9312
- return getFormattedTimeForHeader(calculatedDivType, calculatedDivision, th);
9313
- });
9314
- const filteredHeaders = formattedHeaders.filter((element) => element.text !== "");
9315
- return (jsxRuntime.jsx("tr", { className: "cwelltSchRowTime", style: { height: "30px" }, children: filteredHeaders.map(({ text, isWeekend }, index) => {
9316
- return (jsxRuntime.jsx(TimeHeader, { isWeekend: isWeekend, index: index, text: text, width: maxWidth / filteredHeaders.length, header: header }, index));
9317
- }) }));
9318
- };
9319
-
9320
- const SchedulerTimeLine = ({ maxPx, hoursList, startDate, endDate, pxPerHour, headerName, }) => {
9321
- return (jsxRuntime.jsx("table", { className: "content-area cwelltSchTable", style: { width: maxPx }, children: jsxRuntime.jsxs("tbody", { style: { width: "100%", borderSpacing: 0 }, className: "content-area cwelltSchTbody", children: [jsxRuntime.jsx(DaysHeader, { days: hoursList, divisionType: calculateDivisionType(startDate, endDate), maxWidth: pxPerHour * hoursList.length, headerType: headerName ?? "schedulerDateHeader" }), jsxRuntime.jsx(TimeHeaderRow, { timeHeaders: hoursList, startDate: startDate, endDate: endDate, maxWidth: pxPerHour * hoursList.length, header: headerName ?? "schedulerTimeHeader" })] }) }));
9322
- };
9323
-
9324
- const SchedulerHeader$1 = ({ timelineProps, descriptionColumn }) => {
9325
- const { maxPx, hoursList, startDate, endDate, pxPerHour, headerName } = timelineProps;
9326
- return (jsxRuntime.jsx("thead", { className: "cwellt_fc_header_scheduler", style: { position: "sticky", zIndex: 9 }, children: jsxRuntime.jsxs("tr", { className: "cwellt_fc_header_row", children: [jsxRuntime.jsxs("td", { className: "border", style: {
9327
- position: "sticky",
9328
- top: 0,
9329
- backgroundColor: "white",
9330
- width: "100px",
9331
- }, children: [jsxRuntime.jsx("div", { style: {
9332
- display: "flex",
9333
- height: "30px",
9334
- alignItems: "center",
9335
- width: "150px",
9336
- }, children: jsxRuntime.jsx("label", { children: headerName }) }), jsxRuntime.jsx("div", { style: {
9337
- display: "flex",
9338
- height: "30px",
9339
- alignItems: "center",
9340
- background: "rgba(0, 0, 0, 0.04)",
9341
- }, children: jsxRuntime.jsx("span", { children: descriptionColumn }) })] }), jsxRuntime.jsx("td", { style: {
9342
- position: "sticky",
9343
- top: 0,
9344
- zIndex: 6,
9345
- backgroundColor: "white",
9346
- }, children: jsxRuntime.jsx(SchedulerTimeLine, { maxPx: maxPx, hoursList: hoursList, pxPerHour: pxPerHour, startDate: startDate, endDate: endDate, headerName: headerName }) })] }) }));
9347
- };
9348
-
9349
- const daysBetweenTwoDatesIncludingBoth = (date1, date2) => {
9350
- const diff = Math.abs(date1.getTime() - date2.getTime());
9351
- const diffDays = diff / (1000 * 3600 * 24);
9352
- return diffDays;
9353
- };
9354
-
9355
- const getUtcToday = () => {
9356
- const now = new Date();
9357
- const userTimezoneOffset = now.getTimezoneOffset() * 60000;
9358
- const nowUtc = new Date(now.getTime() + userTimezoneOffset);
9359
- return nowUtc;
9360
- };
9361
-
9362
- const filterEvents = (events, start, end, id, module = undefined) => {
9363
- const datesCollide = (event) => event.start <= end && event.end >= start;
9364
- let eventsFiltered = events.filter(event => datesCollide(event));
9365
- if (id !== "flightWatchScheduler") {
9366
- eventsFiltered = sortByDate(eventsFiltered);
9367
- }
9368
- if (id !== "crewAssignmentsScheduler" && id !== "vacationsScheduler") {
9369
- return eventsFiltered;
9370
- }
9371
- eventsFiltered = setNotFullHeightEventsFirst(eventsFiltered);
9372
- if (module === "CrewControl") {
9373
- eventsFiltered = removeDuplicated(eventsFiltered, "Crew_Id");
9374
- }
9375
- if (module === "CrewScheduling") {
9376
- eventsFiltered = removeDuplicated(eventsFiltered, "AssignmentID");
9377
- }
9378
- if (module === "CrewSchedulingVacations") {
9379
- eventsFiltered = removeDuplicated(eventsFiltered, "ID");
9380
- }
9381
- return eventsFiltered;
9382
- };
9383
- const sortByDate = (events) => events.sort((a, b) => +new Date(a.start) - +new Date(b.start));
9384
- const removeDuplicated = (events, key) => {
9385
- return events.filter((obj, index, self) => index === self.findIndex(o => o.data[key] === obj.data[key] && o.data.subject === obj.data.subject));
9386
- };
9387
- const setNotFullHeightEventsFirst = (events) => {
9388
- const notFullHeight = [];
9389
- const isFullHeight = [];
9390
- events.forEach(element => {
9391
- element.isFullHeight ? notFullHeight.push(element) : isFullHeight.push(element);
9392
- });
9393
- return notFullHeight.concat(isFullHeight);
9394
- };
9395
-
9396
- const compareStrings = (str1, str2) => {
9397
- if (str1 > str2)
9398
- return 1;
9399
- if (str1 < str2)
9400
- return -1;
9401
- return 0;
9402
- };
9403
-
9404
- const filterResources = (module, resourceName, resources, groupByFunction, endDate, startDate, scheduleName) => {
9405
- if ((module === "CrewControl" || module === "CrewScheduling" || module === "CrewSchedulingVacations") &&
9406
- resourceName === "Employees") {
9407
- resources = resources.filter(c => (c.data.Eintritt === null || (new Date(c.data.Eintritt) <= endDate)) && (c.data.Austritt === null || (new Date(c.data.Austritt) >= startDate)));
9408
- }
9409
- if (scheduleName === "crewPinnedScheduler" || (module === "CrewControl" || module === "CrewScheduling") && resourceName === "Employees") {
9410
- const sortKey = (groupByFunction || scheduleName === "crewPinnedScheduler") ? "mainFunction" : "C3_LC";
9411
- resources = resources.sort((a, b) => compareStrings(a.data[sortKey], b.data[sortKey]));
9412
- }
9413
- return resources;
9414
- };
9415
-
9416
- const heightScheduler = (resources, visibleRows, isPinnerScheduler) => {
9417
- if (resources.length <= 0) {
9418
- return 100;
9419
- }
9420
- const realVisibleRows = visibleRows > resources.length ? resources.length : visibleRows;
9421
- const rowsHeight = resources.slice(0, realVisibleRows).map((row) => {
9422
- return row.maxTop;
9423
- });
9424
- const height = rowsHeight.reduce((sum, row) => {
9425
- return sum + row;
9426
- }, 0);
9427
- const headerHeight = isPinnerScheduler ? 0 : 60;
9428
- return height + headerHeight;
9429
- };
9430
-
9431
- const getLeftPixels = (eventStart, scheduleStart, dayPx) => {
9432
- if (scheduleStart >= eventStart)
9433
- return 0;
9434
- return daysBetweenTwoDatesIncludingBoth(scheduleStart, eventStart) * dayPx;
9435
- };
9436
- const getEventWithSize = (event, schedulerStart, dayPx) => {
9437
- const eventStartBeforeScheduleStart = event.start.getTime() < schedulerStart.getTime();
9438
- const lengthOfEvent = daysBetweenTwoDatesIncludingBoth(event.start, event.end);
9439
- const daysUntilSchedulerStart = daysBetweenTwoDatesIncludingBoth(event.start, schedulerStart);
9440
- const daysLong = eventStartBeforeScheduleStart ? lengthOfEvent - daysUntilSchedulerStart : lengthOfEvent;
9441
- // we want minimum of 8 px
9442
- const eventMinSize = 8;
9443
- const newEvent = {
9444
- ...event,
9445
- leftPx: getLeftPixels(event.start, schedulerStart, dayPx),
9446
- width: Math.max(daysLong * dayPx, eventMinSize),
9447
- };
9448
- return newEvent;
9449
- };
9450
-
9451
- const checkIfSlotAvailable = (events, event) => {
9452
- if (events.length == 0)
9453
- return true;
9454
- const collide = events.some(existent => {
9455
- return !(existent.end <= event.start || event.end <= existent.start) && !existent.isFullHeight;
9456
- });
9457
- return !collide;
9458
- };
9459
-
9460
- const getEventsInInnerRows = (res, eventHeight, dayPx, start) => {
9461
- let maxTop = 0;
9462
- const tops = [];
9463
- tops[0] = new Array();
9464
- res.events
9465
- .map((e) => {
9466
- return getEventWithSize(e, start, dayPx);
9467
- })
9468
- .forEach((event, i) => {
9469
- if (i === 0 || event.isFullHeight) {
9470
- event.top = 0;
9471
- tops[0].push(event);
9472
- }
9473
- else {
9474
- let found = false;
9475
- for (let j = 0; j < tops.length && found === false; j++) {
9476
- found = checkIfSlotAvailable(tops[j], event);
9477
- if (found === true || event.isFullHeight) {
9478
- event.top = j * eventHeight;
9479
- tops[j].push(event);
9480
- break;
9481
- }
9482
- }
9483
- if (found === false && !event.isFullHeight) {
9484
- maxTop++;
9485
- tops[maxTop] = new Array();
9486
- event.top = maxTop * eventHeight;
9487
- tops[maxTop].push(event);
9488
- }
9489
- else {
9490
- // This is for flightwatch
9491
- if (found === true && event.data.order === 2 && maxTop < 1) {
9492
- maxTop++;
9493
- tops[maxTop] = new Array();
9494
- event.top = maxTop * eventHeight;
9495
- tops[maxTop].push(event);
9496
- maxTop--;
9497
- }
9498
- }
9499
- }
9500
- });
9501
- return tops;
9502
- };
9503
-
9504
- const getTimeHeaders = (startDate, endDate) => {
9505
- const dateArray = new Array();
9506
- const currentDate = new Date(startDate);
9507
- const startOffset = Math.abs(startDate.getTimezoneOffset());
9508
- const endOffset = Math.abs(endDate.getTimezoneOffset());
9509
- // Summer: +1 -> +2, true
9510
- // Winter: +2 -> -1, false
9511
- const offsetSummerWinter = startOffset < endOffset;
9512
- if (offsetSummerWinter === true) {
9513
- while (currentDate < endDate) {
9514
- if (dateArray.length > 0) {
9515
- const lastPosition = dateArray[dateArray.length - 1];
9516
- const differenceHours = currentDate.getHours() - lastPosition.getHours();
9517
- if (differenceHours === 1 || differenceHours < 0) {
9518
- dateArray.push(new Date(currentDate));
9519
- }
9520
- else if (differenceHours > 1) {
9521
- dateArray.push(new Date(currentDate.getHours() - 1));
9522
- dateArray.push(new Date(currentDate));
9523
- }
9524
- }
9525
- else {
9526
- dateArray.push(new Date(currentDate));
9527
- }
9528
- currentDate.setHours(currentDate.getHours() + 1);
9529
- }
9530
- }
9531
- else {
9532
- while (currentDate < endDate) {
9533
- dateArray.push(new Date(currentDate));
9534
- currentDate.setHours(currentDate.getHours() + 1);
9535
- }
9536
- }
9537
- return dateArray;
9538
- };
9539
-
9540
- class CwScheduler extends React.Component {
9541
- contentArea;
9542
- calculateMaxPx = () => {
9543
- const mainElement = document.body;
9544
- const mainRect = mainElement.getBoundingClientRect();
9545
- return Math.floor(mainRect.width - 190);
9546
- };
9547
- constructor(props) {
9548
- super(props);
9549
- const maxPx = this.calculateMaxPx();
9550
- const timeHeaders = getTimeHeaders(props.startDate, props.endDate);
9551
- const dayPx = maxPx / Math.floor(daysBetweenTwoDates(props.startDate, props.endDate));
9552
- const hourPx = dayPx / 24;
9553
- const minutePx = dayPx / 1440;
9554
- window?.addEventListener("resize", this.handleResize);
9555
- const divisions = calculateDivisions(this.props.startDate, this.props.endDate);
9556
- const divisionsLeftPx = timeHeaders
9557
- .filter((_, index) => {
9558
- return index != 0 && index % (24 / divisions) == 0;
9559
- })
9560
- .map((date) => {
9561
- const daysDiff = daysBetweenTwoDatesIncludingBoth(date, props.startDate);
9562
- const pixels = daysDiff * 24 * hourPx;
9563
- return pixels;
9564
- });
9565
- this.state = {
9566
- maxPx: maxPx,
9567
- dayPx: dayPx,
9568
- hourPx: hourPx,
9569
- minutePx: minutePx,
9570
- timeHeaders: timeHeaders,
9571
- divisionsLeftPx: divisionsLeftPx,
9572
- eventHeight: 30,
9573
- resources: props.resources,
9574
- lineStyle: 0,
9575
- nowUtc: getUtcToday(),
9576
- division: divisions,
9577
- divisionType: "",
9578
- pinnedResources: props.pinnedResources ? props.pinnedResources : [],
9579
- selectedEvents: [],
9580
- showConsoleLogs: false, // Change to false to not show the console.log(...)
9581
- };
9582
- }
9583
- handleResize = () => {
9584
- const maxPx = this.calculateMaxPx();
9585
- const days = Math.floor(daysBetweenTwoDates(this.props.startDate, this.props.endDate));
9586
- const dayPx = maxPx / days;
9587
- const hourPx = dayPx / 24;
9588
- const updated = { ...this.state, maxPx: maxPx, hourPx: hourPx, dayPx: dayPx };
9589
- this.setState(updated);
9590
- };
9591
- objectsEqual = (o1, o2) => {
9592
- Object.keys(o1).length === Object.keys(o2).length && Object.keys(o1).every((p) => o1[p] === o2[p]);
9593
- };
9594
- objectsEqualDeep = (o1, o2) => typeof o1 === "object" && Object.keys(o1).length > 0
9595
- ? Object.keys(o1).length === Object.keys(o2).length &&
9596
- Object.keys(o1).every((p) => this.objectsEqual(o1[p], o2[p]))
9597
- : o1 === o2;
9598
- arraysEqual = (a1, a2) => a1.length === a2.length && a1.every((o, idx) => this.objectsEqualDeep(o, a2[idx]));
9599
- componentWillReceiveProps(_nextProps) {
9600
- if (this.state.showConsoleLogs) {
9601
- console.log("Schedule - componentWillReceiveProps, start: ", new Date());
9602
- console.log("Schedule - componentWillReceiveProps - has changes, start: ", new Date());
9603
- }
9604
- const dateChange = _nextProps.startDate.toISOString() !== this.props.startDate.toISOString() ||
9605
- _nextProps.endDate.toISOString() !== this.props.endDate.toISOString();
9606
- if (dateChange) {
9607
- const startDate = _nextProps.startDate;
9608
- const endDate = _nextProps.endDate;
9609
- const maxPx = this.calculateMaxPx();
9610
- const timeHeaders = getTimeHeaders(startDate, endDate);
9611
- const days = Math.floor(daysBetweenTwoDates(startDate, endDate));
9612
- const dayPx = maxPx / days;
9613
- const hourPx = dayPx / 24;
9614
- const minutePx = dayPx / 1440;
9615
- const now = getUtcToday();
9616
- const isInDateRange = now >= startDate && now <= endDate && this.contentArea !== undefined;
9617
- const lineStyle = isInDateRange ? daysBetweenTwoDatesIncludingBoth(startDate, now) * dayPx : 0;
9618
- const divisions = calculateDivisions(startDate, endDate);
9619
- const divisionsLeftPx = timeHeaders
9620
- .filter((_, index) => {
9621
- return index != 0 && index % (24 / divisions) == 0;
9622
- })
9623
- .map((date) => {
9624
- const daysDiff = daysBetweenTwoDatesIncludingBoth(date, startDate);
9625
- const pixels = daysDiff * dayPx;
9626
- return pixels;
9627
- });
9628
- this.setState({
9629
- maxPx: maxPx, // window.screen.width * 0.9,
9630
- dayPx: dayPx,
9631
- hourPx: hourPx,
9632
- minutePx: minutePx,
9633
- timeHeaders: timeHeaders,
9634
- divisionsLeftPx: divisionsLeftPx,
9635
- resources: this.getNewResources(_nextProps, dayPx),
9636
- lineStyle: lineStyle,
9637
- nowUtc: now,
9638
- division: divisions,
9639
- divisionType: "",
9640
- pinnedResources: this.props.pinnedResources ?? [],
9641
- });
9642
- if (this.state.showConsoleLogs) {
9643
- console.log("Schedule - componentWillReceiveProps - print on schedule, end: ", new Date());
9644
- console.log("Schedule - componentWillReceiveProps, end: ", new Date());
9645
- }
9646
- return;
9647
- }
9648
- const areSameEvents = this.arraysEqual(_nextProps.events, this.props.events);
9649
- const areSameRows = this.arraysEqual(_nextProps.resources, this.props.resources);
9650
- if (!areSameEvents || !areSameRows) {
9651
- const startDate = _nextProps.startDate;
9652
- const endDate = _nextProps.endDate;
9653
- const maxPx = this.calculateMaxPx();
9654
- const days = Math.floor(daysBetweenTwoDates(startDate, endDate));
9655
- const dayPx = maxPx / days;
9656
- this.setState({
9657
- resources: this.getNewResources(_nextProps, dayPx),
9658
- });
9659
- return;
9660
- }
9661
- }
9662
- getNewResources = (_nextProps, dayPx) => {
9663
- const mappedEvents = filterEvents(_nextProps.events, _nextProps.startDate, _nextProps.endDate, this.props.id, this.props.module)
9664
- .filter((event) => {
9665
- const outOfRange = event.end <= this.props.startDate || event.start >= this.props.endDate;
9666
- return !outOfRange;
9667
- });
9668
- const resources = filterResources(this.props.module, this.props.resourceName, _nextProps.resources, this.props.groupByFunction, _nextProps.endDate, _nextProps.startDate, this.props.id);
9669
- const newResources = resources
9670
- .map((resource) => {
9671
- return {
9672
- ...resource,
9673
- events: mappedEvents.filter((event) => event.resourceId === resource.id),
9674
- };
9675
- })
9676
- .map((resource) => {
9677
- const tops = getEventsInInnerRows(resource, this.state.eventHeight, dayPx, _nextProps.startDate);
9678
- const height = tops.length === 0 ? this.state.eventHeight : tops.length * this.state.eventHeight;
9679
- let flatMapEvents = [];
9680
- for (let h = 0; h < tops.length; h++) {
9681
- flatMapEvents = flatMapEvents.concat(tops[h]);
9682
- }
9683
- return {
9684
- ...resource,
9685
- maxTop: height,
9686
- events: flatMapEvents,
9687
- };
9688
- });
9689
- return newResources;
9690
- };
9691
- handleOnClickContextMenuResourceScheduler = (_clickEvent, _resource) => {
9692
- let datetime = new Date();
9693
- const _ca = this.contentArea;
9694
- if (_clickEvent.domEvent.currentTarget !== undefined) {
9695
- const leftPos = _clickEvent.domEvent.currentTarget.parentElement.getBoundingClientRect().left -
9696
- (_ca?.getBoundingClientRect()?.left ?? 0) -
9697
- window.scrollX;
9698
- datetime = addMinutesToDateFromPx(this.props.startDate, leftPos, this.state.minutePx);
9699
- }
9700
- if (this.props.scheduler_handleOnClickContextMenuResource) {
9701
- this.props.scheduler_handleOnClickContextMenuResource(datetime, _resource, _clickEvent.key, this.props.id);
9702
- }
9703
- };
9704
- handleCrewPinning = (resource, text) => {
9705
- if (this.props.scheduler_handlePinned) {
9706
- this.props.scheduler_handlePinned.call(this.props.parent, resource.id, text, this.props.id);
9707
- }
9708
- };
9709
- render() {
9710
- const isInDateRange = this.state.nowUtc >= this.props.startDate &&
9711
- this.state.nowUtc <= this.props.endDate &&
9712
- this.contentArea !== undefined;
9713
- const showTimeline = isInDateRange && this.state.lineStyle < this.state.maxPx;
9714
- const isPinnedTable = this.props.id.toLowerCase().includes("pinned");
9715
- const schedulerHeight = heightScheduler(this.state.resources, this.props.height, this.props.id === "crewAssignmentsScheduler");
9716
- return (jsxRuntime.jsx("div", { id: this.props.id, style: {
9717
- maxHeight: isPinnedTable ? "auto" : schedulerHeight,
9718
- }, className: this.state.resources.length > 0 ? "cwellt_tb_con" : "cwellt_tb_con cw_tb_con_emptyValues", children: jsxRuntime.jsxs("table", { id: "cwelltTableScheduler", children: [this.props.id !== "crewAssignmentsScheduler" && (jsxRuntime.jsx(SchedulerHeader$1, { timelineProps: {
9719
- maxPx: this.state.maxPx,
9720
- hoursList: this.state.timeHeaders,
9721
- pxPerHour: this.state.hourPx,
9722
- startDate: this.props.startDate,
9723
- endDate: this.props.endDate,
9724
- headerName: this.props.resourceName,
9725
- }, descriptionColumn: this.props.descriptionColumn })), jsxRuntime.jsx("tbody", { style: {
9726
- width: this.state.maxPx + 150,
9727
- maxHeight: isPinnedTable ? "auto" : schedulerHeight,
9728
- }, className: isPinnedTable ? "fc-body cw-fc-body-pinned" : "fc-body", children: jsxRuntime.jsxs("tr", { className: "fc_body_row", children: [jsxRuntime.jsx(ResourcesTitleList, { resources: this.state.resources, canBePinned: this.props.canBePinned ?? false, includesPinned: this.props.id.toLowerCase().includes("pinned"), onCrewPinning: this.handleCrewPinning, onClickResourceContextMenu: (_e, resource) => {
9729
- if (this.props.scheduler_handleOnClickResourceContextMenu) {
9730
- this.props.scheduler_handleOnClickResourceContextMenu(_e, resource);
9731
- }
9732
- }, ResourceTitleComponent: this.props.resourceComp }), jsxRuntime.jsx("td", { className: "dividerArea" }), jsxRuntime.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 })] }) })] }) }));
9733
- }
9734
- }
9735
-
9736
8682
  function dateFromPercentage(startDate, visibleDays, percentage) {
9737
8683
  const start = Temporal.Instant.fromEpochMilliseconds(startDate.getTime());
9738
8684
  const spanMs = Math.round(visibleDays) * 24 * 60 * 60 * 1000;
@@ -9873,7 +8819,7 @@ class OnClickContextMenu {
9873
8819
  }
9874
8820
  }
9875
8821
 
9876
- 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"};
8822
+ 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"};
9877
8823
 
9878
8824
  const getNow$1 = (isUtc) => {
9879
8825
  let now = new Date();
@@ -9939,7 +8885,7 @@ const HeaderTitle = ({ title, dividerText, width }) => {
9939
8885
  const SchedulerHeader = ({ content, divisions, visibleDays, selectedDate, width, onEvent, timeLinePercentage, isUtc }) => {
9940
8886
  const topWidth = (100 / visibleDays);
9941
8887
  const { title, classification } = content;
9942
- return (jsxRuntime.jsxs("div", { style: { display: "flex" }, children: [jsxRuntime.jsx(HeaderTitle, { title: title, dividerText: classification, width: width }), jsxRuntime.jsxs("div", { className: styles$3["scheduler-header-divisions"], style: { flex: 1, display: "flex", position: "relative" }, onMouseDown: (e) => {
8888
+ return (jsxRuntime.jsxs("div", { className: styles$3["scheduler-header"], children: [jsxRuntime.jsx(HeaderTitle, { title: title, dividerText: classification, width: width }), jsxRuntime.jsxs("div", { className: styles$3["scheduler-header-divisions"], style: { flex: 1, display: "flex", position: "relative" }, onMouseDown: (e) => {
9943
8889
  e.preventDefault();
9944
8890
  const clickPercentage = getPercentageFromMouseEvent(e);
9945
8891
  const date = dateFromPercentage(selectedDate, visibleDays, clickPercentage);
@@ -10807,325 +9753,6 @@ const Scheduler = (props) => {
10807
9753
  class UiEvent {
10808
9754
  }
10809
9755
 
10810
- let topsCounter = 0;
10811
- class CwSuperScheduler extends React__namespace.Component {
10812
- constructor(Props) {
10813
- super(Props);
10814
- this.state = {
10815
- topsCalculated: 0,
10816
- height: 50,
10817
- dataConfig: this.props.dataConfig ? this.props.dataConfig : undefined,
10818
- pinnedResources: []
10819
- };
10820
- }
10821
- componentDidUpdate(_previousProps, _previousState) {
10822
- if (this.props.pinnedResources !== _previousProps.pinnedResources) {
10823
- let returnedTops = 0;
10824
- let returnedHeight = 50;
10825
- let data;
10826
- if (this.props.pinnedResources) {
10827
- const pinned = [...new Set(this.props.pinnedResources)];
10828
- for (let i = 0; i < pinned.length; i++) {
10829
- data = this.returnDynamicHeight(pinned[i], returnedTops);
10830
- returnedTops = data.topsCalculated;
10831
- returnedHeight = data.height;
10832
- }
10833
- this.setState({
10834
- topsCalculated: returnedTops,
10835
- height: returnedHeight !== 50 ? 80 + returnedHeight : 50,
10836
- pinnedResources: this.props.pinnedResources
10837
- });
10838
- }
10839
- }
10840
- }
10841
- scheduler_handleCblEventClick = (cblEvent, schedulerId) => {
10842
- this.props.scheduler_handleCblEventClick(cblEvent, schedulerId);
10843
- };
10844
- scheduler_handleCblEventClickRight = (cblEvent, schedulerId) => {
10845
- if (this.props.scheduler_handleCblEventClickRight) {
10846
- this.props.scheduler_handleCblEventClickRight(cblEvent, schedulerId);
10847
- }
10848
- };
10849
- scheduler_handleCblEventDoubleClick = (cblEvent, schedulerId) => {
10850
- this.props.scheduler_handleCblEventDoubleClick(cblEvent, schedulerId);
10851
- };
10852
- scheduler_handlePinnedClickMultipleIds = (resIds, schedulerId, requestString) => {
10853
- this.props.scheduler_handlePinningOfResources(resIds, "", schedulerId, requestString);
10854
- };
10855
- scheduler_handlePinnedClick = (resId, text, schedulerId) => {
10856
- const array = new Array();
10857
- array.push(resId);
10858
- this.props.scheduler_handlePinningOfResources(array, text, schedulerId, "resources");
10859
- };
10860
- returnDynamicHeight(pinned, topsCalculated) {
10861
- let height = 100;
10862
- let maxTop = 0;
10863
- const eventHeight = 30;
10864
- const tops = new Array();
10865
- tops[0] = new Array();
10866
- const diffDates = this.props.endDate.getTime() - this.props.startDate.getTime();
10867
- const diffDays = diffDates / (1000 * 3600 * 24);
10868
- const dateToFilter = new Date(this.props.startDate.getTime());
10869
- dateToFilter.setDate(dateToFilter.getDate() + diffDays);
10870
- let events = this.props.pinnedEvents !== undefined ? this.props.pinnedEvents : new Array();
10871
- events = events
10872
- .filter(x => pinned === x.resourceId && x.start >= this.props.startDate && x.start <= dateToFilter)
10873
- .sort((a, b) => {
10874
- return +new Date(a.start) - +new Date(b.start);
10875
- });
10876
- for (let i = 0; i < events.length; i++) {
10877
- const event = events[i];
10878
- if (i === 0 || event.isFullHeight) {
10879
- tops[0].push(event);
10880
- }
10881
- else {
10882
- let found = false;
10883
- for (let j = 0; j < tops.length && found === false; j++) {
10884
- found = this.checkIfSlotAvailable(tops[j], event);
10885
- if (found === true || event.isFullHeight) {
10886
- tops[j].push(event);
10887
- }
10888
- }
10889
- if (found === false) {
10890
- maxTop++;
10891
- tops[maxTop] = new Array();
10892
- tops[maxTop].push(event);
10893
- }
10894
- }
10895
- }
10896
- for (let h = 0; h < tops.length; h++) {
10897
- if (tops.length === 0) {
10898
- height = 100;
10899
- }
10900
- else {
10901
- height = (topsCalculated + tops.length) * eventHeight;
10902
- }
10903
- }
10904
- topsCounter = topsCounter + tops.length;
10905
- return {
10906
- topsCalculated: topsCalculated + tops.length,
10907
- height: height
10908
- };
10909
- }
10910
- checkIfSlotAvailable(array, event) {
10911
- let found = false;
10912
- if (array[array.length - 1].end <= event.start || array[array.length - 1].isFullHeight) {
10913
- found = true;
10914
- }
10915
- return found;
10916
- }
10917
- handleOnClickContextMenuResource = (date, resource, key, schedulerId) => {
10918
- let url = "";
10919
- switch (key) {
10920
- case "showReserves": {
10921
- // CrewControl
10922
- if (this.props.module === "CrewControl") {
10923
- url = "/Winops/CrewControl/CrewControlReact/GetCrewIdsOfReserve";
10924
- }
10925
- // CrewScheduling
10926
- if (this.props.module === "CrewScheduling") {
10927
- url = "/Winops/CrewPlanning/CrewPlanning/GetCrewIdsOfReserve";
10928
- }
10929
- const requestOptions = {
10930
- method: "POST",
10931
- headers: { "Content-Type": "application/json" },
10932
- body: JSON.stringify({
10933
- from: this.dateUTCString(this.props.startDate),
10934
- to: this.dateUTCString(this.props.endDate),
10935
- acftCategories: [],
10936
- functions: [],
10937
- clickedDate: this.dateUTCString(date),
10938
- airportSelected: this.props.airportSelected
10939
- })
10940
- };
10941
- if (this.state.dataConfig) {
10942
- fetch(this.state.dataConfig + url, requestOptions)
10943
- .then(response => response.json())
10944
- .then(res => {
10945
- if (res.length > 0) {
10946
- this.scheduler_handlePinnedClickMultipleIds(res, schedulerId, "Reserves");
10947
- }
10948
- else {
10949
- alert("No Reserves");
10950
- }
10951
- });
10952
- }
10953
- break;
10954
- }
10955
- case "showStandbys": {
10956
- // CrewControl
10957
- if (this.props.module === "CrewControl") {
10958
- url = "/Winops/CrewControl/CrewControlReact/GetCrewIdsOfStandby";
10959
- }
10960
- // CrewScheduling
10961
- if (this.props.module === "CrewScheduling") {
10962
- url = "/Winops/CrewPlanning/CrewPlanning/GetCrewIdsOfStandby";
10963
- }
10964
- const requestOptions2 = {
10965
- method: "POST",
10966
- headers: { "Content-Type": "application/json" },
10967
- body: JSON.stringify({
10968
- from: this.dateUTCString(this.props.startDate),
10969
- to: this.dateUTCString(this.props.startDate),
10970
- acftCategories: [],
10971
- functions: [],
10972
- clickedDate: this.dateUTCString(date),
10973
- airportSelected: this.props.airportSelected
10974
- })
10975
- };
10976
- if (this.state.dataConfig) {
10977
- fetch(this.state.dataConfig + url, requestOptions2)
10978
- .then(response => response.json())
10979
- .then(res => {
10980
- if (res.length > 0) {
10981
- this.scheduler_handlePinnedClickMultipleIds(res, schedulerId, "Standbys");
10982
- }
10983
- else {
10984
- alert("No Standbys");
10985
- }
10986
- });
10987
- }
10988
- break;
10989
- }
10990
- case "showAvailables": {
10991
- // CrewControl
10992
- if (this.props.module === "CrewControl") {
10993
- url = "/Winops/CrewControl/CrewControlReact/GetCrewIdsOfAvailables";
10994
- }
10995
- // CrewScheduling
10996
- if (this.props.module === "CrewScheduling") {
10997
- url = "/Winops/CrewPlanning/CrewPlanning/GetCrewIdsOfAvailables";
10998
- }
10999
- const requestOptions3 = {
11000
- method: "POST",
11001
- headers: { "Content-Type": "application/json" },
11002
- body: JSON.stringify({
11003
- from: this.dateUTCString(this.props.startDate),
11004
- to: this.dateUTCString(this.props.startDate),
11005
- acftCategories: [],
11006
- functions: [],
11007
- clickedDate: this.dateUTCString(date),
11008
- airportSelected: this.props.airportSelected
11009
- })
11010
- };
11011
- if (this.state.dataConfig) {
11012
- fetch(this.state.dataConfig + url, requestOptions3)
11013
- .then(response => response.json())
11014
- .then(res => {
11015
- if (res.length > 0) {
11016
- this.scheduler_handlePinnedClickMultipleIds(res, schedulerId, "Availables");
11017
- }
11018
- else {
11019
- alert("No Availables");
11020
- }
11021
- });
11022
- }
11023
- break;
11024
- }
11025
- default: {
11026
- if (this.props.scheduler_handleOnClickContextMenuResource) {
11027
- this.props.scheduler_handleOnClickContextMenuResource(date, resource, key);
11028
- }
11029
- break;
11030
- }
11031
- }
11032
- };
11033
- dateUTCString(date) {
11034
- if (date instanceof Date) {
11035
- if (date.getFullYear() > 1901)
11036
- return new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes())).toISOString();
11037
- }
11038
- return date;
11039
- }
11040
- render() {
11041
- const havePinnedResources = this.state.pinnedResources?.length > 0;
11042
- const firstSchedulerResources = havePinnedResources
11043
- ? this.props.resourcesToPin.filter(x => this.state.pinnedResources.includes(x.id))
11044
- : new Array();
11045
- const secondSchedulerResources = this.props.resources.filter(x => !this.state.pinnedResources.includes(x.id));
11046
- const pinnedEvents = this.props.pinnedEvents !== undefined
11047
- ? this.props.pinnedEvents.filter(x => this.state.pinnedResources.includes(x.resourceId))
11048
- : new Array();
11049
- const notPinnedEvents = this.props.events.filter(x => !this.props.pinnedResources?.includes(x.resourceId));
11050
- return (jsxRuntime.jsxs("div", { className: "cwelltSuperScheduler_content", children: [jsxRuntime.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 && (jsxRuntime.jsx("div", { style: { padding: "0.5rem" }, children: jsxRuntime.jsx(CwButton, { text: "Clear", onClick: () => {
11051
- this.props.scheduler_handleClearPinnedOnParent();
11052
- } }) })), jsxRuntime.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 })] }));
11053
- }
11054
- }
11055
- class CblDragAndDrop {
11056
- fromId;
11057
- toId;
11058
- data;
11059
- droppedOnDate;
11060
- resizeFromStart;
11061
- resizeFromEnd;
11062
- isCtrlKey;
11063
- constructor(fromId, toId, data, droppedOnDate = null, resizeFromStart = null, resizeFromEnd = null, isCtrlKey = null) {
11064
- this.fromId = fromId;
11065
- this.toId = toId;
11066
- this.data = data;
11067
- this.droppedOnDate = droppedOnDate;
11068
- this.resizeFromStart = resizeFromStart;
11069
- this.resizeFromEnd = resizeFromEnd;
11070
- this.isCtrlKey = isCtrlKey;
11071
- }
11072
- }
11073
-
11074
- const getGUID = () => {
11075
- return generateSegment(false) + generateSegment(true) + generateSegment(true) + generateSegment(false);
11076
- };
11077
- const generateSegment = (includeHyphens) => {
11078
- const p = (Math.random().toString(16) + "000000000").substring(2, 10);
11079
- return includeHyphens ? "-" + p.substring(0, 4) + "-" + p.substring(4, 8) : p;
11080
- };
11081
-
11082
- class cblEvent {
11083
- id = "";
11084
- start;
11085
- end;
11086
- resourceId;
11087
- selected = false;
11088
- top = 0;
11089
- leftPx = 0;
11090
- rightPx = 0;
11091
- width = 0;
11092
- isFullHeight = false;
11093
- isReadOnly = false;
11094
- isResizable = false;
11095
- isDraggable = false;
11096
- data = null;
11097
- constructor(start, end, resourceId, data = null, isFullHeight = false, isReadOnly = false, isResizable = false, isDraggable = false) {
11098
- this.start = start;
11099
- this.end = end;
11100
- this.resourceId = resourceId;
11101
- this.data = data;
11102
- this.isFullHeight = isFullHeight;
11103
- this.isReadOnly = isReadOnly;
11104
- this.isResizable = isResizable;
11105
- this.isDraggable = isDraggable;
11106
- this.id = getGUID();
11107
- }
11108
- }
11109
-
11110
- class Resource {
11111
- uid = "";
11112
- id;
11113
- name;
11114
- maxTop;
11115
- events = [];
11116
- isInViewport = false;
11117
- schedulerResourceDisplay;
11118
- isLoading = false;
11119
- data = null;
11120
- constructor(id, name, eventHeight, data = null, schedulerResourceDisplay = null) {
11121
- this.id = id;
11122
- this.name = name;
11123
- this.maxTop = eventHeight;
11124
- this.data = data;
11125
- this.schedulerResourceDisplay = schedulerResourceDisplay || this.name;
11126
- }
11127
- }
11128
-
11129
9756
  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"};
11130
9757
 
11131
9758
  class OnPinRow {
@@ -11608,7 +10235,6 @@ const CwFindCrewmember = ({ handleChange, placeHolder = "Search crew…", requir
11608
10235
  }, "data-direction": direction, children: [jsxRuntime.jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsxRuntime.jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxRuntime.jsxs("div", { className: "cw-search-input-wrapper", ref: wrapperRef, children: [jsxRuntime.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) && (jsxRuntime.jsx("div", { className: "cw-search-input-loading", children: jsxRuntime.jsx(CwIcon, { iconId: "spinner" }) })), jsxRuntime.jsx("div", { className: "cw-search-input-icons", children: inputValue && !disabled && !isInitialLoading ? (jsxRuntime.jsx(CwButton, { type: "button", onClick: handleClear, "aria-label": "Clear selected crewmember", variant: "icon", icon: "close", color: "neutral" })) : (jsxRuntime.jsx(CwIcon, { iconId: "person" })) })] })] }), renderPanel(jsxRuntime.jsx("div", { ref: panelRef, className: dropdownStyles.dropdown, style: panelStyle, role: "listbox", children: jsxRuntime.jsx("ul", { children: options.map((option, index) => (jsxRuntime.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))) }) }))] }));
11609
10236
  };
11610
10237
 
11611
- exports.CblDragAndDrop = CblDragAndDrop;
11612
10238
  exports.CwAccordionContainer = CwAccordionContainer;
11613
10239
  exports.CwAlign = CwAlign;
11614
10240
  exports.CwAnchoredMenu = CwAnchoredMenu;
@@ -11678,7 +10304,6 @@ exports.CwPopoverButton = CwPopoverButton;
11678
10304
  exports.CwProgress = CwProgress;
11679
10305
  exports.CwRadioGroup = CwRadioGroup;
11680
10306
  exports.CwReportModal = CwReportModal;
11681
- exports.CwScheduler = CwScheduler;
11682
10307
  exports.CwSearchAsync = CwSearchAsync;
11683
10308
  exports.CwSearchInput = CwSearchInput;
11684
10309
  exports.CwSelect = CwSelect;
@@ -11687,7 +10312,6 @@ exports.CwSelectListItems = CwSelectListItems;
11687
10312
  exports.CwSkeleton = CwSkeleton;
11688
10313
  exports.CwSortableList = CwSortableList;
11689
10314
  exports.CwSortableTable = CwSortableTable;
11690
- exports.CwSuperScheduler = CwSuperScheduler;
11691
10315
  exports.CwTable = CwTable;
11692
10316
  exports.CwTableGrouped = CwTableGrouped;
11693
10317
  exports.CwTableServerSide = CwTableServerSide;
@@ -11725,14 +10349,12 @@ exports.OnStartClickHeaderEvent = OnStartClickHeaderEvent;
11725
10349
  exports.OnUnpinRow = OnUnpinRow;
11726
10350
  exports.PRESET_LIBRARY_TEMPORAL = PRESET_LIBRARY_TEMPORAL;
11727
10351
  exports.PinRowHeader = PinRowHeader;
11728
- exports.Resource = Resource;
11729
10352
  exports.Scheduler = Scheduler;
11730
10353
  exports.SchedulerEvent = SchedulerEvent;
11731
10354
  exports.SuperScheduler = SuperScheduler;
11732
10355
  exports.TooltipConstraintContext = TooltipConstraintContext;
11733
10356
  exports.UiEvent = UiEvent;
11734
10357
  exports.Weekdays = Weekdays;
11735
- exports.cblEvent = cblEvent;
11736
10358
  exports.configureCwLoading = configureCwLoading;
11737
10359
  exports.eventIsVisible = eventIsVisible;
11738
10360
  exports.filterNavItems = filterNavItems;