@activecollab/components 2.0.577 → 2.0.579
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.
- package/dist/cjs/components/ViewSwitcher/useApplyToAllOffer.js +3 -1
- package/dist/cjs/components/ViewSwitcher/useApplyToAllOffer.js.map +1 -1
- package/dist/cjs/presentation/myWork/MyWorkTasks.js +83 -30
- package/dist/cjs/presentation/myWork/MyWorkTasks.js.map +1 -1
- package/dist/cjs/presentation/myWork/agendaGrid.js +1095 -0
- package/dist/cjs/presentation/myWork/agendaGrid.js.map +1 -0
- package/dist/cjs/presentation/shared/settings.js +6 -2
- package/dist/cjs/presentation/shared/settings.js.map +1 -1
- package/dist/cjs/presentation/shared/tokens.js +8 -1
- package/dist/cjs/presentation/shared/tokens.js.map +1 -1
- package/dist/cjs/presentation/timeboxes/AdjustmentList.js +31 -0
- package/dist/cjs/presentation/timeboxes/AdjustmentList.js.map +1 -0
- package/dist/cjs/presentation/timeboxes/AgendaDayView.js +1722 -0
- package/dist/cjs/presentation/timeboxes/AgendaDayView.js.map +1 -0
- package/dist/cjs/presentation/timeboxes/CapacityBar.js +54 -0
- package/dist/cjs/presentation/timeboxes/CapacityBar.js.map +1 -0
- package/dist/cjs/presentation/timeboxes/SimulationCard.js +47 -0
- package/dist/cjs/presentation/timeboxes/SimulationCard.js.map +1 -0
- package/dist/cjs/presentation/timeboxes/SimulationPanel.js +319 -0
- package/dist/cjs/presentation/timeboxes/SimulationPanel.js.map +1 -0
- package/dist/cjs/presentation/timeboxes/TimeRecordsSection.js +206 -0
- package/dist/cjs/presentation/timeboxes/TimeRecordsSection.js.map +1 -0
- package/dist/cjs/presentation/timeboxes/WorkloadView.js +887 -0
- package/dist/cjs/presentation/timeboxes/WorkloadView.js.map +1 -0
- package/dist/cjs/presentation/timeboxes/__tests__/timeboxes.test.js +699 -0
- package/dist/cjs/presentation/timeboxes/__tests__/timeboxes.test.js.map +1 -0
- package/dist/cjs/presentation/timeboxes/changes.js +293 -0
- package/dist/cjs/presentation/timeboxes/changes.js.map +1 -0
- package/dist/cjs/presentation/timeboxes/mockData.js +320 -0
- package/dist/cjs/presentation/timeboxes/mockData.js.map +1 -0
- package/dist/cjs/presentation/timeboxes/model.js +186 -0
- package/dist/cjs/presentation/timeboxes/model.js.map +1 -0
- package/dist/cjs/presentation/timeboxes/pillLook.js +72 -0
- package/dist/cjs/presentation/timeboxes/pillLook.js.map +1 -0
- package/dist/cjs/presentation/timeboxes/plan.js +181 -0
- package/dist/cjs/presentation/timeboxes/plan.js.map +1 -0
- package/dist/cjs/presentation/timeboxes/reducer.js +763 -0
- package/dist/cjs/presentation/timeboxes/reducer.js.map +1 -0
- package/dist/cjs/presentation/timeboxes/scheduler.js +147 -0
- package/dist/cjs/presentation/timeboxes/scheduler.js.map +1 -0
- package/dist/cjs/presentation/timeboxes/store.js +65 -0
- package/dist/cjs/presentation/timeboxes/store.js.map +1 -0
- package/dist/cjs/presentation/timeboxes/timeBlocks.js +1931 -0
- package/dist/cjs/presentation/timeboxes/timeBlocks.js.map +1 -0
- package/dist/cjs/presentation/timeboxes/timeboxSettings.js +369 -0
- package/dist/cjs/presentation/timeboxes/timeboxSettings.js.map +1 -0
- package/dist/cjs/presentation/timeboxes/tracked.js +189 -0
- package/dist/cjs/presentation/timeboxes/tracked.js.map +1 -0
- package/dist/esm/components/ViewSwitcher/useApplyToAllOffer.d.ts.map +1 -1
- package/dist/esm/components/ViewSwitcher/useApplyToAllOffer.js +4 -2
- package/dist/esm/components/ViewSwitcher/useApplyToAllOffer.js.map +1 -1
- package/dist/esm/presentation/myWork/MyWorkTasks.d.ts +81 -1
- package/dist/esm/presentation/myWork/MyWorkTasks.d.ts.map +1 -1
- package/dist/esm/presentation/myWork/MyWorkTasks.js +76 -23
- package/dist/esm/presentation/myWork/MyWorkTasks.js.map +1 -1
- package/dist/esm/presentation/myWork/agendaGrid.d.ts +341 -0
- package/dist/esm/presentation/myWork/agendaGrid.d.ts.map +1 -0
- package/dist/esm/presentation/myWork/agendaGrid.js +1001 -0
- package/dist/esm/presentation/myWork/agendaGrid.js.map +1 -0
- package/dist/esm/presentation/shared/settings.d.ts +2 -0
- package/dist/esm/presentation/shared/settings.d.ts.map +1 -1
- package/dist/esm/presentation/shared/settings.js +5 -1
- package/dist/esm/presentation/shared/settings.js.map +1 -1
- package/dist/esm/presentation/shared/tokens.d.ts +6 -0
- package/dist/esm/presentation/shared/tokens.d.ts.map +1 -1
- package/dist/esm/presentation/shared/tokens.js +7 -0
- package/dist/esm/presentation/shared/tokens.js.map +1 -1
- package/dist/esm/presentation/timeboxes/AdjustmentList.d.ts +11 -0
- package/dist/esm/presentation/timeboxes/AdjustmentList.d.ts.map +1 -0
- package/dist/esm/presentation/timeboxes/AdjustmentList.js +22 -0
- package/dist/esm/presentation/timeboxes/AdjustmentList.js.map +1 -0
- package/dist/esm/presentation/timeboxes/AgendaDayView.d.ts +15 -0
- package/dist/esm/presentation/timeboxes/AgendaDayView.d.ts.map +1 -0
- package/dist/esm/presentation/timeboxes/AgendaDayView.js +1524 -0
- package/dist/esm/presentation/timeboxes/AgendaDayView.js.map +1 -0
- package/dist/esm/presentation/timeboxes/CapacityBar.d.ts +15 -0
- package/dist/esm/presentation/timeboxes/CapacityBar.d.ts.map +1 -0
- package/dist/esm/presentation/timeboxes/CapacityBar.js +48 -0
- package/dist/esm/presentation/timeboxes/CapacityBar.js.map +1 -0
- package/dist/esm/presentation/timeboxes/SimulationCard.d.ts +13 -0
- package/dist/esm/presentation/timeboxes/SimulationCard.d.ts.map +1 -0
- package/dist/esm/presentation/timeboxes/SimulationCard.js +41 -0
- package/dist/esm/presentation/timeboxes/SimulationCard.js.map +1 -0
- package/dist/esm/presentation/timeboxes/SimulationPanel.d.ts +18 -0
- package/dist/esm/presentation/timeboxes/SimulationPanel.d.ts.map +1 -0
- package/dist/esm/presentation/timeboxes/SimulationPanel.js +267 -0
- package/dist/esm/presentation/timeboxes/SimulationPanel.js.map +1 -0
- package/dist/esm/presentation/timeboxes/TimeRecordsSection.d.ts +14 -0
- package/dist/esm/presentation/timeboxes/TimeRecordsSection.d.ts.map +1 -0
- package/dist/esm/presentation/timeboxes/TimeRecordsSection.js +159 -0
- package/dist/esm/presentation/timeboxes/TimeRecordsSection.js.map +1 -0
- package/dist/esm/presentation/timeboxes/WorkloadView.d.ts +9 -0
- package/dist/esm/presentation/timeboxes/WorkloadView.d.ts.map +1 -0
- package/dist/esm/presentation/timeboxes/WorkloadView.js +761 -0
- package/dist/esm/presentation/timeboxes/WorkloadView.js.map +1 -0
- package/dist/esm/presentation/timeboxes/__tests__/timeboxes.test.d.ts +2 -0
- package/dist/esm/presentation/timeboxes/__tests__/timeboxes.test.d.ts.map +1 -0
- package/dist/esm/presentation/timeboxes/__tests__/timeboxes.test.js +640 -0
- package/dist/esm/presentation/timeboxes/__tests__/timeboxes.test.js.map +1 -0
- package/dist/esm/presentation/timeboxes/changes.d.ts +72 -0
- package/dist/esm/presentation/timeboxes/changes.d.ts.map +1 -0
- package/dist/esm/presentation/timeboxes/changes.js +224 -0
- package/dist/esm/presentation/timeboxes/changes.js.map +1 -0
- package/dist/esm/presentation/timeboxes/mockData.d.ts +16 -0
- package/dist/esm/presentation/timeboxes/mockData.d.ts.map +1 -0
- package/dist/esm/presentation/timeboxes/mockData.js +297 -0
- package/dist/esm/presentation/timeboxes/mockData.js.map +1 -0
- package/dist/esm/presentation/timeboxes/model.d.ts +136 -0
- package/dist/esm/presentation/timeboxes/model.d.ts.map +1 -0
- package/dist/esm/presentation/timeboxes/model.js +129 -0
- package/dist/esm/presentation/timeboxes/model.js.map +1 -0
- package/dist/esm/presentation/timeboxes/pillLook.d.ts +40 -0
- package/dist/esm/presentation/timeboxes/pillLook.d.ts.map +1 -0
- package/dist/esm/presentation/timeboxes/pillLook.js +65 -0
- package/dist/esm/presentation/timeboxes/pillLook.js.map +1 -0
- package/dist/esm/presentation/timeboxes/plan.d.ts +62 -0
- package/dist/esm/presentation/timeboxes/plan.d.ts.map +1 -0
- package/dist/esm/presentation/timeboxes/plan.js +116 -0
- package/dist/esm/presentation/timeboxes/plan.js.map +1 -0
- package/dist/esm/presentation/timeboxes/reducer.d.ts +203 -0
- package/dist/esm/presentation/timeboxes/reducer.d.ts.map +1 -0
- package/dist/esm/presentation/timeboxes/reducer.js +616 -0
- package/dist/esm/presentation/timeboxes/reducer.js.map +1 -0
- package/dist/esm/presentation/timeboxes/scheduler.d.ts +63 -0
- package/dist/esm/presentation/timeboxes/scheduler.d.ts.map +1 -0
- package/dist/esm/presentation/timeboxes/scheduler.js +120 -0
- package/dist/esm/presentation/timeboxes/scheduler.js.map +1 -0
- package/dist/esm/presentation/timeboxes/store.d.ts +23 -0
- package/dist/esm/presentation/timeboxes/store.d.ts.map +1 -0
- package/dist/esm/presentation/timeboxes/store.js +46 -0
- package/dist/esm/presentation/timeboxes/store.js.map +1 -0
- package/dist/esm/presentation/timeboxes/timeBlocks.d.ts +10 -0
- package/dist/esm/presentation/timeboxes/timeBlocks.d.ts.map +1 -0
- package/dist/esm/presentation/timeboxes/timeBlocks.js +1767 -0
- package/dist/esm/presentation/timeboxes/timeBlocks.js.map +1 -0
- package/dist/esm/presentation/timeboxes/timeboxSettings.d.ts +71 -0
- package/dist/esm/presentation/timeboxes/timeboxSettings.d.ts.map +1 -0
- package/dist/esm/presentation/timeboxes/timeboxSettings.js +302 -0
- package/dist/esm/presentation/timeboxes/timeboxSettings.js.map +1 -0
- package/dist/esm/presentation/timeboxes/tracked.d.ts +51 -0
- package/dist/esm/presentation/timeboxes/tracked.d.ts.map +1 -0
- package/dist/esm/presentation/timeboxes/tracked.js +136 -0
- package/dist/esm/presentation/timeboxes/tracked.js.map +1 -0
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,1524 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import React, { Fragment, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import styled from "styled-components";
|
|
4
|
+
import { ALL_DAY_VISIBLE_LANES, AgendaFilter, AgendaViewSwitch, DAY_GRID_MAX_WIDTH, DAY_GRID_MIN_WIDTH, DAY_GRID_WIDTH_STORAGE_KEY, EventGlyph, LaneRow, MyCalendarOptionsMenu, MeetingServiceIcon, MyWorkTabs, SHORT_MONTHS, StyledDayHeaders, StyledDaySplit, StyledHourGrid, StyledMyCalendarPaper, StyledMyCalendarToolbar, StyledPill, StyledTextTrigger, TIME_GUTTER, formatTimeOfDay, isoToDayNumber, longDayOf, percentOf, periodLabelFor, placeSideBySide, toDate, useViewportFillHeight } from "../myWork/agendaGrid";
|
|
5
|
+
import { DayProjectList, useMyWorkTasks } from "../myWork/MyWorkTasks";
|
|
6
|
+
import { NON_WORKING_HATCH, StyledPanelResizer, TRANSITION, ToastHost, useResizableWidth } from "../shared";
|
|
7
|
+
import { AdjustmentList } from "./AdjustmentList";
|
|
8
|
+
import { CapacityBar } from "./CapacityBar";
|
|
9
|
+
import { adjustmentLines, changedTasksOn, changedTimeboxes } from "./changes";
|
|
10
|
+
import { ME, PROJECTS, TODAY, USERS, WEEK_DAYS } from "./mockData";
|
|
11
|
+
import { MINUTES_PER_DAY, allocationOn, formatMinutes, rangeOf, snap, timeboxesOn, untimedOn } from "./model";
|
|
12
|
+
import { MUTED_EVENT_FILL, PAPER_RING, PILL_LOOK, paletteFill, paletteOf, tentativeHatch, trackedFillColor } from "./pillLook";
|
|
13
|
+
import { eventRange, isInRange, planDay } from "./plan";
|
|
14
|
+
import { draggableMinutes, increaseConfirmText, mergeTargets, planDrop, planMove, planResize, previewDayValue } from "./reducer";
|
|
15
|
+
import { freeGaps } from "./scheduler";
|
|
16
|
+
import { TB_CONTEXT, timeboxStore, useLastChange, useTimeboxState } from "./store";
|
|
17
|
+
import { suggestionKey, timeboxKey, trackedBlocks, trackedByUserOn, trackedOn } from "./tracked";
|
|
18
|
+
import { Button } from "../../components/Button";
|
|
19
|
+
import { ConfirmDialog } from "../../components/ConfirmDialog";
|
|
20
|
+
import { IconButton } from "../../components/IconButton";
|
|
21
|
+
import { AddCrossTinyIcon, ArrowLeftIcon, ArrowRightIcon, ClockStopwatchSmallIcon, PinSmallIcon, SparkIcon, TreeDotsIcon, WarningTriangleSmallIcon } from "../../components/Icons";
|
|
22
|
+
import { List, ListItem, ListSeparator } from "../../components/List";
|
|
23
|
+
import { Menu } from "../../components/Menu";
|
|
24
|
+
import { ToastMessage } from "../../components/ToastMessage";
|
|
25
|
+
import { Tooltip } from "../../components/Tooltip";
|
|
26
|
+
import { Body2, Caption1, Header3 } from "../../components/Typography";
|
|
27
|
+
import { Typography } from "../../components/Typography/Typography";
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The Agenda's day view of the Timeboxes simulation (the "Timeboxes –
|
|
31
|
+
* Simulation" story shows it under My Work). An estimate split and a timebox are the same
|
|
32
|
+
* thing (src/presentation/timeboxes): pinning a suggestion splits the task
|
|
33
|
+
* and carves the box out of the day's untimed part; the scheduler places
|
|
34
|
+
* what is left into free time.
|
|
35
|
+
*
|
|
36
|
+
* Everything here acts on the shared timeboxes store, so the Workload view
|
|
37
|
+
* sees the same tasks; what the last action changed is highlighted. Drag and resize use pointer events; there
|
|
38
|
+
* is no drag-and-drop library.
|
|
39
|
+
*/
|
|
40
|
+
/* ================================================================== */
|
|
41
|
+
/* Geometry */
|
|
42
|
+
/* ================================================================== */
|
|
43
|
+
|
|
44
|
+
/** 48px an hour (the Time Blocks concept's choice: a 30-min block fits a
|
|
45
|
+
line and its handles); the app's grid is 36px. */
|
|
46
|
+
const HOUR_HEIGHT = 48;
|
|
47
|
+
const HALF_HOUR = HOUR_HEIGHT / 2;
|
|
48
|
+
/** Under this a block shows its name line only (DayEvent.jsx's 36px). */
|
|
49
|
+
const TWO_LINE_HEIGHT = 36;
|
|
50
|
+
/** Wednesday 11:45 — the now-line on "today". */
|
|
51
|
+
const NOW_MINUTES = 11 * 60 + 45;
|
|
52
|
+
/** A pointer that moves less than this has clicked, not dragged. */
|
|
53
|
+
const DRAG_THRESHOLD = 4;
|
|
54
|
+
const minuteTop = minutes => minutes / 60 * HOUR_HEIGHT;
|
|
55
|
+
const timeRange = (start, end) => formatTimeOfDay(start) + " \u2013 " + formatTimeOfDay(end);
|
|
56
|
+
|
|
57
|
+
/* ================================================================== */
|
|
58
|
+
/* Styles */
|
|
59
|
+
/* ================================================================== */
|
|
60
|
+
|
|
61
|
+
/* The Agenda's hour grid at 48px an hour, the off-hours tinted under the
|
|
62
|
+
hour and half-hour lines. */
|
|
63
|
+
const StyledTimeboxGrid = styled(StyledHourGrid).withConfig({
|
|
64
|
+
displayName: "AgendaDayView__StyledTimeboxGrid",
|
|
65
|
+
componentId: "sc-jyi6wq-0"
|
|
66
|
+
})([".time-canvas{height:", "px;}.time-column{background-image:none;touch-action:none;}.off-hours{position:absolute;left:0;right:0;background-color:var(--color-theme-200);}.pause-band{position:absolute;left:0;right:0;background-image:", ";}.slot-lines{position:absolute;inset:0;pointer-events:none;background-image:repeating-linear-gradient( to bottom,transparent 0,transparent ", "px,var(--border-primary) ", "px,var(--border-primary) ", "px ),repeating-linear-gradient( to bottom,transparent 0,transparent ", "px,var(--color-theme-transparent-300) ", "px,var(--color-theme-transparent-300) ", "px );}.time-column.today{background-color:transparent;}.time-column.past .suggestion{opacity:0.5;}.time-column.past .timebox{opacity:0.7;}.drop-preview{box-sizing:border-box;position:absolute;left:2px;right:2px;z-index:4;display:flex;align-items:flex-start;padding:2px 6px;border:2px dashed var(--color-primary);border-radius:var(--ac-br-4);background-color:color-mix(in srgb,var(--color-primary) 10%,transparent);pointer-events:none;}.drop-preview.invalid{border-color:var(--red-alert);background-color:color-mix(in srgb,var(--red-alert) 8%,transparent);}.edge-hint{position:absolute;right:6px;z-index:6;padding:2px 6px;border-radius:var(--ac-br-4);background-color:var(--page-paper-main);box-shadow:var(--shadow-popover);transform:translateY(-50%);pointer-events:none;white-space:nowrap;}"], 24 * HOUR_HEIGHT, NON_WORKING_HATCH, HOUR_HEIGHT - 1, HOUR_HEIGHT - 1, HOUR_HEIGHT, HALF_HOUR - 1, HALF_HOUR - 1, HALF_HOUR);
|
|
67
|
+
|
|
68
|
+
/* The hover-only "…" of a block (top right; centred in a one-line block),
|
|
69
|
+
the first line making room for it. */
|
|
70
|
+
const blockMenuAnchor = "\n .block-menu-anchor {\n position: absolute;\n top: 1px;\n right: 1px;\n z-index: 2;\n display: flex;\n opacity: 0;\n transition: opacity " + TRANSITION + ";\n }\n\n &.compact .block-menu-anchor {\n top: 50%;\n transform: translateY(-50%);\n }\n\n &:hover .block-menu-anchor,\n .block-menu-anchor.open {\n opacity: 1;\n }\n\n &:hover .block-line,\n &.menu-open .block-line {\n padding-right: 22px;\n }\n";
|
|
71
|
+
|
|
72
|
+
/* A pinned timebox: the new_task pill filled with its project's palette
|
|
73
|
+
colour (pillLook). Its body moves it, its edges resize it. */
|
|
74
|
+
const StyledTimebox = styled.div.withConfig({
|
|
75
|
+
displayName: "AgendaDayView__StyledTimebox",
|
|
76
|
+
componentId: "sc-jyi6wq-1"
|
|
77
|
+
})(["", " cursor:grab;touch-action:none;user-select:none;transition:box-shadow ", ";&.dragging{z-index:5;cursor:grabbing;}&.merge-target{outline:2px dashed var(--color-primary);outline-offset:1px;}&.dragging ~ &.merge-target{z-index:6;pointer-events:none;}&.overtime{border-style:dashed;border-color:var(--warning);}&.completed{opacity:0.5;}.edge{position:absolute;left:0;right:0;z-index:1;height:6px;cursor:ns-resize;}.edge.top{top:0;}.edge.bottom{bottom:0;}.edge::after{content:\"\";position:absolute;left:50%;top:50%;display:none;width:24px;height:2px;border-top:3px double var(--border-primary);transform:translate(-50%,-50%);}&:hover .edge::after,&.dragging .edge::after{display:block;}", ""], PILL_LOOK, TRANSITION, blockMenuAnchor);
|
|
78
|
+
|
|
79
|
+
/* A suggestion: the new_task pill with a see-through hatch of the project's
|
|
80
|
+
palette colour; after the window, the hatch in the warning colour and a
|
|
81
|
+
dashed warning edge, with an "overtime" mark. */
|
|
82
|
+
const StyledSuggestion = styled.div.withConfig({
|
|
83
|
+
displayName: "AgendaDayView__StyledSuggestion",
|
|
84
|
+
componentId: "sc-jyi6wq-2"
|
|
85
|
+
})(["", " cursor:pointer;transition:box-shadow ", ";&.overtime{border-style:dashed;border-color:var(--warning);}&& .overtime-mark{flex-shrink:0;color:var(--warning);}", ""], PILL_LOOK, TRANSITION, blockMenuAnchor);
|
|
86
|
+
|
|
87
|
+
/* Tracked time in the "Tracked" column: the pill in the darker rung of its
|
|
88
|
+
project's colour (trackedFillColor). A block that runs past the task's
|
|
89
|
+
blocks is dashed; in the warning colour when it is past the day's plan
|
|
90
|
+
too. */
|
|
91
|
+
const StyledTrackedBlock = styled.div.withConfig({
|
|
92
|
+
displayName: "AgendaDayView__StyledTrackedBlock",
|
|
93
|
+
componentId: "sc-jyi6wq-3"
|
|
94
|
+
})(["", " cursor:default;&.after{border-style:dashed;border-color:var(--border-primary);}&.after.over{border-color:var(--warning);}"], PILL_LOOK);
|
|
95
|
+
|
|
96
|
+
/* A timed event: the new_task pill in its calendar's palette colour, or
|
|
97
|
+
neutral with the colour on its edge when the user is not taking part. */
|
|
98
|
+
const StyledEventPill = styled.div.withConfig({
|
|
99
|
+
displayName: "AgendaDayView__StyledEventPill",
|
|
100
|
+
componentId: "sc-jyi6wq-4"
|
|
101
|
+
})(["", " cursor:pointer;.meeting-icon{display:flex;flex-shrink:0;}"], PILL_LOOK);
|
|
102
|
+
|
|
103
|
+
/* The day header: the project calendar's 64px cell, with the overbooked
|
|
104
|
+
warning on the right. */
|
|
105
|
+
const StyledTimeboxDayHeader = styled(StyledDayHeaders).withConfig({
|
|
106
|
+
displayName: "AgendaDayView__StyledTimeboxDayHeader",
|
|
107
|
+
componentId: "sc-jyi6wq-5"
|
|
108
|
+
})(["&&.dated .header-cell{flex-direction:row;align-items:stretch;justify-content:space-between;gap:12px;}.header-main{display:flex;flex:1 1 auto;flex-direction:column;min-width:0;}.header-warning{display:flex;flex-shrink:0;align-items:center;gap:4px;}"]);
|
|
109
|
+
|
|
110
|
+
/* All Day pills: a task without an estimate is dragged onto the grid; the
|
|
111
|
+
part of a day that did not fit is dashed in the alert colour. */
|
|
112
|
+
const StyledDragPill = styled(StyledPill).withConfig({
|
|
113
|
+
displayName: "AgendaDayView__StyledDragPill",
|
|
114
|
+
componentId: "sc-jyi6wq-6"
|
|
115
|
+
})(["&&{justify-content:flex-start;cursor:grab;touch-action:none;user-select:none;}"]);
|
|
116
|
+
const StyledUnscheduledPill = styled(StyledPill).withConfig({
|
|
117
|
+
displayName: "AgendaDayView__StyledUnscheduledPill",
|
|
118
|
+
componentId: "sc-jyi6wq-7"
|
|
119
|
+
})(["&&{justify-content:flex-start;border-style:dashed;border-width:1px;border-color:var(--red-alert);background-color:var(--page-paper-main);}"]);
|
|
120
|
+
|
|
121
|
+
/* The dragged task, under the pointer. */
|
|
122
|
+
const StyledDragGhost = styled.div.withConfig({
|
|
123
|
+
displayName: "AgendaDayView__StyledDragGhost",
|
|
124
|
+
componentId: "sc-jyi6wq-8"
|
|
125
|
+
})(["position:fixed;z-index:1000;display:flex;align-items:center;gap:6px;max-width:280px;padding:4px 8px;border-radius:var(--ac-br-4);background-color:var(--page-paper-main);box-shadow:var(--shadow-float);pointer-events:none;transform:translate(12px,12px);.ghost-name{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}"]);
|
|
126
|
+
|
|
127
|
+
/* The day list: a row's second line, its parts a dot apart. */
|
|
128
|
+
const StyledDayAgenda = styled.div.withConfig({
|
|
129
|
+
displayName: "AgendaDayView__StyledDayAgenda",
|
|
130
|
+
componentId: "sc-jyi6wq-9"
|
|
131
|
+
})([".block-part{display:inline-flex;align-items:center;gap:4px;min-width:0;white-space:nowrap;}.block-part + .block-part::before{content:\"\";flex-shrink:0;width:2px;height:2px;margin:0 4px 0 2px;border-radius:100%;background-color:var(--color-theme-600);}.row-menu.open,.list-row:hover .row-menu{opacity:1;}.row-menu{opacity:0;transition:opacity ", ";}"], TRANSITION);
|
|
132
|
+
|
|
133
|
+
/* ================================================================== */
|
|
134
|
+
/* Pieces */
|
|
135
|
+
/* ================================================================== */
|
|
136
|
+
|
|
137
|
+
const run = action => timeboxStore.dispatch(action).error;
|
|
138
|
+
const projectColorOf = task => {
|
|
139
|
+
var _PROJECTS$find$color, _PROJECTS$find;
|
|
140
|
+
return (_PROJECTS$find$color = (_PROJECTS$find = PROJECTS.find(project => project.id === task.projectId)) == null ? void 0 : _PROJECTS$find.color) != null ? _PROJECTS$find$color : "";
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
/** A block's "…" with its actions. Clicks act, then close. */
|
|
144
|
+
const BlockMenu = _ref => {
|
|
145
|
+
let open = _ref.open,
|
|
146
|
+
onOpen = _ref.onOpen,
|
|
147
|
+
onClose = _ref.onClose,
|
|
148
|
+
items = _ref.items;
|
|
149
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
150
|
+
className: open ? "block-menu-anchor open" : "block-menu-anchor"
|
|
151
|
+
}, /*#__PURE__*/React.createElement(Menu, {
|
|
152
|
+
open: open,
|
|
153
|
+
onOpen: onOpen,
|
|
154
|
+
onClose: onClose,
|
|
155
|
+
position: "bottom-end",
|
|
156
|
+
target: /*#__PURE__*/React.createElement(IconButton, {
|
|
157
|
+
type: "button",
|
|
158
|
+
size: "small",
|
|
159
|
+
variant: "text gray",
|
|
160
|
+
"aria-label": "Block options",
|
|
161
|
+
active: open,
|
|
162
|
+
onPointerDown: event => event.stopPropagation()
|
|
163
|
+
}, /*#__PURE__*/React.createElement(TreeDotsIcon, null))
|
|
164
|
+
}, /*#__PURE__*/React.createElement(List, {
|
|
165
|
+
tabIndex: 0
|
|
166
|
+
}, items.map((item, index) => item === "separator" ? /*#__PURE__*/React.createElement(ListSeparator, {
|
|
167
|
+
key: index
|
|
168
|
+
}) : /*#__PURE__*/React.createElement(ListItem, {
|
|
169
|
+
key: item.label,
|
|
170
|
+
onClick: () => {
|
|
171
|
+
onClose();
|
|
172
|
+
item.onSelect();
|
|
173
|
+
}
|
|
174
|
+
}, item.label)))));
|
|
175
|
+
};
|
|
176
|
+
BlockMenu.displayName = "BlockMenu";
|
|
177
|
+
|
|
178
|
+
/** The shadow a pill draws: the ring of paper between fills, the primary
|
|
179
|
+
outline the last change leaves, or the lift while it is dragged. */
|
|
180
|
+
/* No outline for the last change here: the pill keeps the design's look,
|
|
181
|
+
the Simulation panel lists the change. */
|
|
182
|
+
const pillShadow = function (dragging) {
|
|
183
|
+
if (dragging === void 0) {
|
|
184
|
+
dragging = false;
|
|
185
|
+
}
|
|
186
|
+
return dragging ? "var(--shadow-float)" : PAPER_RING;
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
/** A pinned timebox. */
|
|
190
|
+
const TimeboxCard = _ref2 => {
|
|
191
|
+
let timebox = _ref2.timebox,
|
|
192
|
+
range = _ref2.range,
|
|
193
|
+
style = _ref2.style,
|
|
194
|
+
dragging = _ref2.dragging,
|
|
195
|
+
mergeTarget = _ref2.mergeTarget,
|
|
196
|
+
changed = _ref2.changed,
|
|
197
|
+
menuOpen = _ref2.menuOpen,
|
|
198
|
+
onMenu = _ref2.onMenu,
|
|
199
|
+
onPointerDownBody = _ref2.onPointerDownBody,
|
|
200
|
+
onPointerDownEdge = _ref2.onPointerDownEdge;
|
|
201
|
+
const task = timebox.task,
|
|
202
|
+
part = timebox.part;
|
|
203
|
+
const _paletteOf = paletteOf(projectColorOf(task)),
|
|
204
|
+
base = _paletteOf.base;
|
|
205
|
+
const height = Math.max(minuteTop(range.end - range.start), 20);
|
|
206
|
+
const className = ["timebox", height < TWO_LINE_HEIGHT ? "compact" : "", timebox.overtime ? "overtime" : "", task.isCompleted ? "completed" : "", dragging ? "dragging" : "", mergeTarget ? "merge-target" : "", changed ? "changed" : "", menuOpen ? "menu-open" : ""].filter(Boolean).join(" ");
|
|
207
|
+
return /*#__PURE__*/React.createElement(StyledTimebox, {
|
|
208
|
+
className: className,
|
|
209
|
+
style: _extends({}, style, {
|
|
210
|
+
height,
|
|
211
|
+
/* Data colour: the project's palette fill. */
|
|
212
|
+
backgroundColor: paletteFill(base),
|
|
213
|
+
boxShadow: pillShadow(dragging)
|
|
214
|
+
}),
|
|
215
|
+
onPointerDown: onPointerDownBody
|
|
216
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
217
|
+
className: "edge top",
|
|
218
|
+
onPointerDown: event => onPointerDownEdge(event, "start")
|
|
219
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
220
|
+
className: "block-line"
|
|
221
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
222
|
+
className: "block-glyph"
|
|
223
|
+
}, /*#__PURE__*/React.createElement(PinSmallIcon, {
|
|
224
|
+
width: 12,
|
|
225
|
+
height: 12,
|
|
226
|
+
style: {
|
|
227
|
+
fill: base
|
|
228
|
+
},
|
|
229
|
+
"aria-label": "Pinned"
|
|
230
|
+
})), /*#__PURE__*/React.createElement(Caption1, {
|
|
231
|
+
color: "tertiary",
|
|
232
|
+
className: "block-meta fill-text"
|
|
233
|
+
}, "#" + task.id), /*#__PURE__*/React.createElement(Caption1, {
|
|
234
|
+
className: "block-name",
|
|
235
|
+
color: task.isImportant ? "alert" : "primary",
|
|
236
|
+
decoration: task.isCompleted ? "line-through" : undefined
|
|
237
|
+
}, task.name)), /*#__PURE__*/React.createElement("span", {
|
|
238
|
+
className: "block-detail"
|
|
239
|
+
}, /*#__PURE__*/React.createElement(Caption1, {
|
|
240
|
+
color: "secondary",
|
|
241
|
+
className: "fill-text"
|
|
242
|
+
}, "" + timeRange(range.start, range.end) + (timebox.overtime ? " · overtime" : "")), timebox.overlapping.map(event => /*#__PURE__*/React.createElement(Tooltip, {
|
|
243
|
+
title: "Overlaps: " + event.name,
|
|
244
|
+
key: event.id
|
|
245
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
246
|
+
className: "overlap-chip"
|
|
247
|
+
}, /*#__PURE__*/React.createElement(WarningTriangleSmallIcon, {
|
|
248
|
+
width: 12,
|
|
249
|
+
height: 12,
|
|
250
|
+
style: {
|
|
251
|
+
fill: "var(--red-alert)",
|
|
252
|
+
flexShrink: 0
|
|
253
|
+
},
|
|
254
|
+
"aria-hidden": true
|
|
255
|
+
}), /*#__PURE__*/React.createElement(Caption1, {
|
|
256
|
+
color: "alert",
|
|
257
|
+
className: "block-name"
|
|
258
|
+
}, event.name))))), /*#__PURE__*/React.createElement("span", {
|
|
259
|
+
className: "edge bottom",
|
|
260
|
+
onPointerDown: event => onPointerDownEdge(event, "end")
|
|
261
|
+
}), /*#__PURE__*/React.createElement(BlockMenu, {
|
|
262
|
+
open: menuOpen,
|
|
263
|
+
onOpen: () => onMenu(true),
|
|
264
|
+
onClose: () => onMenu(false),
|
|
265
|
+
items: [{
|
|
266
|
+
label: "Unpin",
|
|
267
|
+
onSelect: () => run({
|
|
268
|
+
type: "unpin",
|
|
269
|
+
partId: part.id
|
|
270
|
+
})
|
|
271
|
+
}, "separator", {
|
|
272
|
+
label: "Open task",
|
|
273
|
+
onSelect: () => undefined
|
|
274
|
+
}]
|
|
275
|
+
}));
|
|
276
|
+
};
|
|
277
|
+
TimeboxCard.displayName = "TimeboxCard";
|
|
278
|
+
|
|
279
|
+
/** A suggestion fragment: the hatch, the name, its place among the day's
|
|
280
|
+
fragments as dots. */
|
|
281
|
+
const SuggestionCard = _ref3 => {
|
|
282
|
+
let suggestion = _ref3.suggestion,
|
|
283
|
+
task = _ref3.task,
|
|
284
|
+
style = _ref3.style,
|
|
285
|
+
linked = _ref3.linked,
|
|
286
|
+
changed = _ref3.changed,
|
|
287
|
+
menuOpen = _ref3.menuOpen,
|
|
288
|
+
onMenu = _ref3.onMenu,
|
|
289
|
+
onHover = _ref3.onHover,
|
|
290
|
+
onPin = _ref3.onPin,
|
|
291
|
+
onPinAll = _ref3.onPinAll;
|
|
292
|
+
const _paletteOf2 = paletteOf(projectColorOf(task)),
|
|
293
|
+
base = _paletteOf2.base;
|
|
294
|
+
const height = Math.max(minuteTop(suggestion.end - suggestion.start), 20);
|
|
295
|
+
const className = ["suggestion", height < TWO_LINE_HEIGHT ? "compact" : "", suggestion.overtime ? "overtime" : "", changed ? "changed" : "", menuOpen ? "menu-open" : ""].filter(Boolean).join(" ");
|
|
296
|
+
return /*#__PURE__*/React.createElement(StyledSuggestion, {
|
|
297
|
+
className: className,
|
|
298
|
+
style: _extends({}, style, {
|
|
299
|
+
height,
|
|
300
|
+
/* Data colour, mixed at render; the warning colour after hours. */
|
|
301
|
+
backgroundImage: suggestion.overtime ? tentativeHatch("var(--warning)", linked) : tentativeHatch(base, linked),
|
|
302
|
+
boxShadow: pillShadow()
|
|
303
|
+
}),
|
|
304
|
+
onMouseEnter: () => onHover(task.id),
|
|
305
|
+
onMouseLeave: () => onHover(null)
|
|
306
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
307
|
+
className: "block-line"
|
|
308
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
309
|
+
className: "block-glyph"
|
|
310
|
+
}, /*#__PURE__*/React.createElement(SparkIcon, {
|
|
311
|
+
width: 12,
|
|
312
|
+
height: 12,
|
|
313
|
+
style: {
|
|
314
|
+
fill: base
|
|
315
|
+
},
|
|
316
|
+
"aria-label": "Suggested"
|
|
317
|
+
})), /*#__PURE__*/React.createElement(Caption1, {
|
|
318
|
+
color: "tertiary",
|
|
319
|
+
className: "block-meta fill-text"
|
|
320
|
+
}, "#" + task.id), /*#__PURE__*/React.createElement(Caption1, {
|
|
321
|
+
className: "block-name"
|
|
322
|
+
}, task.name), suggestion.overtime ? /*#__PURE__*/React.createElement(Caption1, {
|
|
323
|
+
weight: "bold",
|
|
324
|
+
className: "overtime-mark"
|
|
325
|
+
}, "overtime") : null), /*#__PURE__*/React.createElement("span", {
|
|
326
|
+
className: "block-detail"
|
|
327
|
+
}, /*#__PURE__*/React.createElement(Caption1, {
|
|
328
|
+
color: "secondary",
|
|
329
|
+
className: "fill-text"
|
|
330
|
+
}, timeRange(suggestion.start, suggestion.end)), suggestion.fragments > 1 ? /*#__PURE__*/React.createElement(Tooltip, {
|
|
331
|
+
title: "Part " + suggestion.fragment + " of " + suggestion.fragments
|
|
332
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
333
|
+
className: "fragment-dots"
|
|
334
|
+
}, Array.from({
|
|
335
|
+
length: suggestion.fragments
|
|
336
|
+
}, (_, index) => /*#__PURE__*/React.createElement("span", {
|
|
337
|
+
className: "fragment-dot",
|
|
338
|
+
key: index,
|
|
339
|
+
style: {
|
|
340
|
+
borderColor: base,
|
|
341
|
+
backgroundColor: index + 1 === suggestion.fragment ? base : "transparent"
|
|
342
|
+
}
|
|
343
|
+
})))) : null), /*#__PURE__*/React.createElement(BlockMenu, {
|
|
344
|
+
open: menuOpen,
|
|
345
|
+
onOpen: () => onMenu(true),
|
|
346
|
+
onClose: () => onMenu(false),
|
|
347
|
+
items: [{
|
|
348
|
+
label: "Pin",
|
|
349
|
+
onSelect: onPin
|
|
350
|
+
}, {
|
|
351
|
+
label: "Pin all for today",
|
|
352
|
+
onSelect: onPinAll
|
|
353
|
+
}, "separator", {
|
|
354
|
+
label: "Open task",
|
|
355
|
+
onSelect: () => undefined
|
|
356
|
+
}]
|
|
357
|
+
}));
|
|
358
|
+
};
|
|
359
|
+
SuggestionCard.displayName = "SuggestionCard";
|
|
360
|
+
|
|
361
|
+
/** A timed event (DayEvent.jsx's content: the calendar glyph, the meeting
|
|
362
|
+
logo, the name; the times under it). */
|
|
363
|
+
const EventPill = _ref4 => {
|
|
364
|
+
var _style$height;
|
|
365
|
+
let event = _ref4.event,
|
|
366
|
+
style = _ref4.style;
|
|
367
|
+
const _paletteOf3 = paletteOf(event.color),
|
|
368
|
+
base = _paletteOf3.base;
|
|
369
|
+
const muted = !event.isParticipant;
|
|
370
|
+
const range = eventRange(event);
|
|
371
|
+
const height = Number((_style$height = style.height) != null ? _style$height : 20);
|
|
372
|
+
return /*#__PURE__*/React.createElement(StyledEventPill, {
|
|
373
|
+
className: height < TWO_LINE_HEIGHT ? "event compact" : "event",
|
|
374
|
+
style: _extends({}, style, {
|
|
375
|
+
backgroundColor: muted ? MUTED_EVENT_FILL : paletteFill(base),
|
|
376
|
+
borderLeftColor: muted ? base : undefined,
|
|
377
|
+
boxShadow: PAPER_RING
|
|
378
|
+
})
|
|
379
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
380
|
+
className: "block-line"
|
|
381
|
+
}, /*#__PURE__*/React.createElement(EventGlyph, {
|
|
382
|
+
color: base
|
|
383
|
+
}), event.meetingUrl ? /*#__PURE__*/React.createElement(MeetingServiceIcon, {
|
|
384
|
+
url: event.meetingUrl
|
|
385
|
+
}) : null, /*#__PURE__*/React.createElement(Typography, {
|
|
386
|
+
variant: "Caption 1",
|
|
387
|
+
weight: "medium",
|
|
388
|
+
className: "block-name",
|
|
389
|
+
color: muted ? "tertiary" : "primary"
|
|
390
|
+
}, event.name)), /*#__PURE__*/React.createElement("span", {
|
|
391
|
+
className: "block-detail"
|
|
392
|
+
}, /*#__PURE__*/React.createElement(Caption1, {
|
|
393
|
+
color: "secondary",
|
|
394
|
+
className: muted ? undefined : "fill-text"
|
|
395
|
+
}, timeRange(range.start, range.end))));
|
|
396
|
+
};
|
|
397
|
+
EventPill.displayName = "EventPill";
|
|
398
|
+
|
|
399
|
+
/** How a tracked block left the plan: "30m late", "15m past its blocks". */
|
|
400
|
+
const trackedShifts = block => [...(block.lateMinutes > 0 ? [formatMinutes(block.lateMinutes) + " late"] : []), ...(block.afterMinutes > 0 ? [formatMinutes(block.afterMinutes) + " past its blocks"] : [])];
|
|
401
|
+
|
|
402
|
+
/** A piece of tracked time: the task, then its times, minutes and how it
|
|
403
|
+
left the plan. */
|
|
404
|
+
const TrackedBlockCard = _ref5 => {
|
|
405
|
+
let block = _ref5.block,
|
|
406
|
+
task = _ref5.task,
|
|
407
|
+
style = _ref5.style,
|
|
408
|
+
label = _ref5.label;
|
|
409
|
+
const _paletteOf4 = paletteOf(projectColorOf(task)),
|
|
410
|
+
base = _paletteOf4.base;
|
|
411
|
+
const height = Math.max(minuteTop(block.end - block.start), 20);
|
|
412
|
+
const className = ["tracked-block", height < TWO_LINE_HEIGHT ? "compact" : "", block.afterMinutes > 0 ? "after" : "", block.afterMinutes > 0 && block.tracked > block.planned ? "over" : ""].filter(Boolean).join(" ");
|
|
413
|
+
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
414
|
+
title: label
|
|
415
|
+
}, /*#__PURE__*/React.createElement(StyledTrackedBlock, {
|
|
416
|
+
className: className,
|
|
417
|
+
style: _extends({}, style, {
|
|
418
|
+
height,
|
|
419
|
+
/* Data colour: the project's tracked rung. */
|
|
420
|
+
backgroundColor: trackedFillColor(projectColorOf(task)),
|
|
421
|
+
boxShadow: PAPER_RING
|
|
422
|
+
}),
|
|
423
|
+
"aria-label": label
|
|
424
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
425
|
+
className: "block-line"
|
|
426
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
427
|
+
className: "block-glyph"
|
|
428
|
+
}, /*#__PURE__*/React.createElement(ClockStopwatchSmallIcon, {
|
|
429
|
+
width: 12,
|
|
430
|
+
height: 12,
|
|
431
|
+
style: {
|
|
432
|
+
fill: base
|
|
433
|
+
},
|
|
434
|
+
"aria-label": "Tracked"
|
|
435
|
+
})), /*#__PURE__*/React.createElement(Caption1, {
|
|
436
|
+
color: "tertiary",
|
|
437
|
+
className: "block-meta fill-text"
|
|
438
|
+
}, "#" + task.id), /*#__PURE__*/React.createElement(Caption1, {
|
|
439
|
+
className: "block-name",
|
|
440
|
+
decoration: task.isCompleted ? "line-through" : undefined
|
|
441
|
+
}, task.name)), /*#__PURE__*/React.createElement("span", {
|
|
442
|
+
className: "block-detail"
|
|
443
|
+
}, /*#__PURE__*/React.createElement(Caption1, {
|
|
444
|
+
color: "secondary",
|
|
445
|
+
className: "fill-text"
|
|
446
|
+
}, [timeRange(block.start, block.end) + " \xB7 " + formatMinutes(block.end - block.start), ...trackedShifts(block)].join(" · ")))));
|
|
447
|
+
};
|
|
448
|
+
TrackedBlockCard.displayName = "TrackedBlockCard";
|
|
449
|
+
|
|
450
|
+
/** The task as the Tasks tab's row reads it (day numbers, hours). */
|
|
451
|
+
const listTaskOf = task => ({
|
|
452
|
+
id: task.id,
|
|
453
|
+
project_id: task.projectId,
|
|
454
|
+
task_list_id: 0,
|
|
455
|
+
name: task.name,
|
|
456
|
+
start_on: isoToDayNumber(task.startOn),
|
|
457
|
+
due_on: isoToDayNumber(task.dueOn),
|
|
458
|
+
label_ids: [],
|
|
459
|
+
is_important: task.isImportant,
|
|
460
|
+
is_completed: task.isCompleted,
|
|
461
|
+
estimate: task.estimate === null ? undefined : task.estimate / 60
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
/* ================================================================== */
|
|
465
|
+
/* Drag sessions */
|
|
466
|
+
/* ================================================================== */
|
|
467
|
+
|
|
468
|
+
/* ================================================================== */
|
|
469
|
+
/* The page */
|
|
470
|
+
/* ================================================================== */
|
|
471
|
+
|
|
472
|
+
const DEFAULT_OPTIONS = {
|
|
473
|
+
showTasks: true,
|
|
474
|
+
showEvents: true,
|
|
475
|
+
showCompleted: true,
|
|
476
|
+
showSubtasks: true,
|
|
477
|
+
showNonWorking: true,
|
|
478
|
+
showWeekNumbers: true,
|
|
479
|
+
showTaskIds: true
|
|
480
|
+
};
|
|
481
|
+
export const AgendaDayView = _ref6 => {
|
|
482
|
+
var _actual$untimed, _confirm$lines;
|
|
483
|
+
let date = _ref6.date,
|
|
484
|
+
onDateChange = _ref6.onDateChange,
|
|
485
|
+
onMessage = _ref6.onMessage,
|
|
486
|
+
_ref6$trackedColumn = _ref6.trackedColumn,
|
|
487
|
+
trackedColumn = _ref6$trackedColumn === void 0 ? false : _ref6$trackedColumn;
|
|
488
|
+
const state = useTimeboxState();
|
|
489
|
+
const myWorkTasks = useMyWorkTasks();
|
|
490
|
+
const _useState = useState(DEFAULT_OPTIONS),
|
|
491
|
+
options = _useState[0],
|
|
492
|
+
setOptions = _useState[1];
|
|
493
|
+
const _useState2 = useState(null),
|
|
494
|
+
session = _useState2[0],
|
|
495
|
+
setSession = _useState2[1];
|
|
496
|
+
const _useState3 = useState(null),
|
|
497
|
+
hovered = _useState3[0],
|
|
498
|
+
setHovered = _useState3[1];
|
|
499
|
+
const _useState4 = useState(null),
|
|
500
|
+
menuKey = _useState4[0],
|
|
501
|
+
setMenuKey = _useState4[1];
|
|
502
|
+
const _useState5 = useState(null),
|
|
503
|
+
confirm = _useState5[0],
|
|
504
|
+
setConfirm = _useState5[1];
|
|
505
|
+
const _useState6 = useState(null),
|
|
506
|
+
toast = _useState6[0],
|
|
507
|
+
setToast = _useState6[1];
|
|
508
|
+
const paperRef = useRef(null);
|
|
509
|
+
const scrollRef = useRef(null);
|
|
510
|
+
const columnRef = useRef(null);
|
|
511
|
+
const sessionRef = useRef(null);
|
|
512
|
+
sessionRef.current = session;
|
|
513
|
+
const fillHeight = useViewportFillHeight(paperRef, true);
|
|
514
|
+
const dayGrid = useResizableWidth({
|
|
515
|
+
min: DAY_GRID_MIN_WIDTH,
|
|
516
|
+
max: DAY_GRID_MAX_WIDTH,
|
|
517
|
+
storageKey: DAY_GRID_WIDTH_STORAGE_KEY
|
|
518
|
+
});
|
|
519
|
+
const user = USERS[0];
|
|
520
|
+
const day = isoToDayNumber(date);
|
|
521
|
+
const plan = useMemo(() => planDay(state, TB_CONTEXT, ME, date), [state, date]);
|
|
522
|
+
/* The "Tracked" column's pieces; display only, the plan above ignores
|
|
523
|
+
them. */
|
|
524
|
+
const actual = useMemo(() => trackedColumn ? trackedBlocks(state, TB_CONTEXT, date) : null, [trackedColumn, state, date]);
|
|
525
|
+
const trackedDay = date === TODAY ? "today" : "on " + longDayOf(isoToDayNumber(date));
|
|
526
|
+
/** A tracked block's tooltip: the task's day, and how it left the plan. */
|
|
527
|
+
const trackedBlockLabel = block => ["Tracked " + formatMinutes(block.tracked) + " of " + formatMinutes(block.planned) + " " + trackedDay, ...trackedShifts(block)].join(" · ");
|
|
528
|
+
/* What the last action changed, from either view. */
|
|
529
|
+
const lastChange = useLastChange();
|
|
530
|
+
const changedBoxes = changedTimeboxes(lastChange);
|
|
531
|
+
const changedTasks = changedTasksOn(lastChange, date);
|
|
532
|
+
const myTasks = useMemo(() => state.tasks.filter(task => task.assigneeId === ME), [state.tasks]);
|
|
533
|
+
const taskOf = useCallback(taskId => state.tasks.find(task => task.id === taskId), [state.tasks]);
|
|
534
|
+
|
|
535
|
+
/** Runs an action; a refusal shows as a toast and in the panel. */
|
|
536
|
+
const act = useCallback(function (action, quiet) {
|
|
537
|
+
if (quiet === void 0) {
|
|
538
|
+
quiet = false;
|
|
539
|
+
}
|
|
540
|
+
const error = run(action);
|
|
541
|
+
if (error) {
|
|
542
|
+
onMessage(error);
|
|
543
|
+
if (!quiet) setToast(error);
|
|
544
|
+
} else {
|
|
545
|
+
onMessage("Done: " + action.type);
|
|
546
|
+
}
|
|
547
|
+
}, [onMessage]);
|
|
548
|
+
|
|
549
|
+
/* Open on the hour before the work window. */
|
|
550
|
+
useEffect(() => {
|
|
551
|
+
if (scrollRef.current) {
|
|
552
|
+
scrollRef.current.scrollTop = minuteTop(Math.max(0, plan.window.start - 60));
|
|
553
|
+
}
|
|
554
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
555
|
+
}, [date]);
|
|
556
|
+
|
|
557
|
+
/* ---------------------------------------------------------------- */
|
|
558
|
+
/* Pointer tracking */
|
|
559
|
+
/* ---------------------------------------------------------------- */
|
|
560
|
+
|
|
561
|
+
const minuteAt = clientY => {
|
|
562
|
+
var _columnRef$current;
|
|
563
|
+
const rect = (_columnRef$current = columnRef.current) == null ? void 0 : _columnRef$current.getBoundingClientRect();
|
|
564
|
+
if (!rect) return 0;
|
|
565
|
+
return Math.min(MINUTES_PER_DAY, Math.max(0, (clientY - rect.top) / HOUR_HEIGHT * 60));
|
|
566
|
+
};
|
|
567
|
+
const overGrid = (clientX, clientY) => {
|
|
568
|
+
var _columnRef$current2, _scrollRef$current;
|
|
569
|
+
const column = (_columnRef$current2 = columnRef.current) == null ? void 0 : _columnRef$current2.getBoundingClientRect();
|
|
570
|
+
const viewport = (_scrollRef$current = scrollRef.current) == null ? void 0 : _scrollRef$current.getBoundingClientRect();
|
|
571
|
+
if (!column || !viewport) return false;
|
|
572
|
+
return clientX >= column.left && clientX <= column.right && clientY >= viewport.top && clientY <= viewport.bottom;
|
|
573
|
+
};
|
|
574
|
+
useEffect(() => {
|
|
575
|
+
if (!session) return undefined;
|
|
576
|
+
const handleMove = event => {
|
|
577
|
+
const current = sessionRef.current;
|
|
578
|
+
if (!current) return;
|
|
579
|
+
const latest = timeboxStore.getState();
|
|
580
|
+
if (current.kind === "task") {
|
|
581
|
+
setSession(_extends({}, current, {
|
|
582
|
+
x: event.clientX,
|
|
583
|
+
y: event.clientY,
|
|
584
|
+
minute: overGrid(event.clientX, event.clientY) ? minuteAt(event.clientY) : null
|
|
585
|
+
}));
|
|
586
|
+
} else if (current.kind === "move") {
|
|
587
|
+
setSession(_extends({}, current, {
|
|
588
|
+
start: planMove(latest, current.partId, minuteAt(event.clientY) - current.grab)
|
|
589
|
+
}));
|
|
590
|
+
} else {
|
|
591
|
+
const part = latest.parts.find(item => item.id === current.partId);
|
|
592
|
+
if (!part) return;
|
|
593
|
+
const own = rangeOf(part);
|
|
594
|
+
const minute = minuteAt(event.clientY);
|
|
595
|
+
setSession(_extends({}, current, {
|
|
596
|
+
plan: current.edge === "end" ? planResize(latest, TB_CONTEXT, part.id, own.start, minute) : planResize(latest, TB_CONTEXT, part.id, minute, own.end)
|
|
597
|
+
}));
|
|
598
|
+
}
|
|
599
|
+
};
|
|
600
|
+
const handleUp = () => {
|
|
601
|
+
const current = sessionRef.current;
|
|
602
|
+
setSession(null);
|
|
603
|
+
if (!current) return;
|
|
604
|
+
if (current.kind === "task") {
|
|
605
|
+
const moved = Math.hypot(current.x - current.originX, current.y - current.originY) > DRAG_THRESHOLD;
|
|
606
|
+
if (moved && current.minute !== null) {
|
|
607
|
+
act({
|
|
608
|
+
type: "dropTask",
|
|
609
|
+
taskId: current.taskId,
|
|
610
|
+
date,
|
|
611
|
+
start: current.minute
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
} else if (current.kind === "move") {
|
|
615
|
+
if (current.start !== current.original) {
|
|
616
|
+
act({
|
|
617
|
+
type: "moveTimebox",
|
|
618
|
+
partId: current.partId,
|
|
619
|
+
start: current.start
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
} else {
|
|
623
|
+
const resize = current.plan;
|
|
624
|
+
const part = timeboxStore.getState().parts.find(item => item.id === current.partId);
|
|
625
|
+
if (!part) return;
|
|
626
|
+
const own = rangeOf(part);
|
|
627
|
+
if (resize.start === own.start && resize.end === own.end) return;
|
|
628
|
+
if (resize.kind === "increase") {
|
|
629
|
+
const task = taskOf(part.taskId);
|
|
630
|
+
if (task) {
|
|
631
|
+
setConfirm({
|
|
632
|
+
partId: part.id,
|
|
633
|
+
start: resize.start,
|
|
634
|
+
end: resize.end,
|
|
635
|
+
text: increaseConfirmText(task, resize.from, resize.to),
|
|
636
|
+
lines: adjustmentLines(previewDayValue(timeboxStore.getState(), TB_CONTEXT, task.id, part.date, resize.to), timeboxStore.getState())
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
} else {
|
|
640
|
+
/* A stopped edge keeps where it stopped; its reason showed while
|
|
641
|
+
dragging. */
|
|
642
|
+
act({
|
|
643
|
+
type: "resizeTimebox",
|
|
644
|
+
partId: part.id,
|
|
645
|
+
start: resize.start,
|
|
646
|
+
end: resize.end
|
|
647
|
+
}, true);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
};
|
|
651
|
+
window.addEventListener("pointermove", handleMove);
|
|
652
|
+
window.addEventListener("pointerup", handleUp);
|
|
653
|
+
return () => {
|
|
654
|
+
window.removeEventListener("pointermove", handleMove);
|
|
655
|
+
window.removeEventListener("pointerup", handleUp);
|
|
656
|
+
};
|
|
657
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
658
|
+
}, [session !== null, date]);
|
|
659
|
+
const startTaskDrag = (taskId, event) => {
|
|
660
|
+
event.preventDefault();
|
|
661
|
+
setSession({
|
|
662
|
+
kind: "task",
|
|
663
|
+
taskId,
|
|
664
|
+
x: event.clientX,
|
|
665
|
+
y: event.clientY,
|
|
666
|
+
originX: event.clientX,
|
|
667
|
+
originY: event.clientY,
|
|
668
|
+
minute: null
|
|
669
|
+
});
|
|
670
|
+
};
|
|
671
|
+
const startMove = (timebox, event) => {
|
|
672
|
+
if (event.target.closest(".block-menu-anchor")) return;
|
|
673
|
+
if (timebox.task.isCompleted) return;
|
|
674
|
+
event.preventDefault();
|
|
675
|
+
setSession({
|
|
676
|
+
kind: "move",
|
|
677
|
+
partId: timebox.part.id,
|
|
678
|
+
grab: minuteAt(event.clientY) - timebox.range.start,
|
|
679
|
+
start: timebox.range.start,
|
|
680
|
+
original: timebox.range.start
|
|
681
|
+
});
|
|
682
|
+
};
|
|
683
|
+
const startResize = (timebox, event, edge) => {
|
|
684
|
+
event.preventDefault();
|
|
685
|
+
event.stopPropagation();
|
|
686
|
+
if (timebox.task.isCompleted) return;
|
|
687
|
+
setSession({
|
|
688
|
+
kind: "resize",
|
|
689
|
+
partId: timebox.part.id,
|
|
690
|
+
edge,
|
|
691
|
+
plan: {
|
|
692
|
+
kind: "free",
|
|
693
|
+
start: timebox.range.start,
|
|
694
|
+
end: timebox.range.end,
|
|
695
|
+
merges: []
|
|
696
|
+
}
|
|
697
|
+
});
|
|
698
|
+
};
|
|
699
|
+
|
|
700
|
+
/* ---------------------------------------------------------------- */
|
|
701
|
+
/* Actions from menus */
|
|
702
|
+
/* ---------------------------------------------------------------- */
|
|
703
|
+
|
|
704
|
+
const pinSuggestion = suggestion => act({
|
|
705
|
+
type: "pin",
|
|
706
|
+
taskId: suggestion.taskId,
|
|
707
|
+
date,
|
|
708
|
+
start: suggestion.start,
|
|
709
|
+
minutes: suggestion.end - suggestion.start
|
|
710
|
+
});
|
|
711
|
+
const pinAllForToday = () => act({
|
|
712
|
+
type: "pinAll",
|
|
713
|
+
date,
|
|
714
|
+
suggestions: plan.suggestions.map(suggestion => ({
|
|
715
|
+
taskId: suggestion.taskId,
|
|
716
|
+
start: suggestion.start,
|
|
717
|
+
minutes: suggestion.end - suggestion.start
|
|
718
|
+
}))
|
|
719
|
+
});
|
|
720
|
+
|
|
721
|
+
/** "Schedule…": the task's first slot that takes it, from the window's
|
|
722
|
+
start (then overtime). */
|
|
723
|
+
const scheduleTask = taskId => {
|
|
724
|
+
const latest = timeboxStore.getState();
|
|
725
|
+
const latestPlan = planDay(latest, TB_CONTEXT, ME, date);
|
|
726
|
+
const gaps = freeGaps(latestPlan.window.start, latestPlan.window.end, [...latestPlan.events.map(eventRange), ...latestPlan.timeboxes.map(timebox => timebox.range), ...(latestPlan.pause ? [latestPlan.pause] : [])]);
|
|
727
|
+
const slot = gaps.find(gap => gap.end - gap.start >= 5 && !("error" in planDrop(latest, TB_CONTEXT, taskId, date, gap.start)));
|
|
728
|
+
if (!slot) {
|
|
729
|
+
setToast("No free slot left today");
|
|
730
|
+
return;
|
|
731
|
+
}
|
|
732
|
+
act({
|
|
733
|
+
type: "dropTask",
|
|
734
|
+
taskId,
|
|
735
|
+
date,
|
|
736
|
+
start: slot.start
|
|
737
|
+
});
|
|
738
|
+
};
|
|
739
|
+
|
|
740
|
+
/* ---------------------------------------------------------------- */
|
|
741
|
+
/* The grid */
|
|
742
|
+
/* ---------------------------------------------------------------- */
|
|
743
|
+
|
|
744
|
+
const past = date < TODAY;
|
|
745
|
+
const isToday = date === TODAY;
|
|
746
|
+
const events = options.showEvents ? plan.events : [];
|
|
747
|
+
const visibleTimeboxes = plan.timeboxes.filter(timebox => options.showCompleted || !timebox.task.isCompleted);
|
|
748
|
+
|
|
749
|
+
/* What the drag or resize will merge into: the task's own timeboxes it
|
|
750
|
+
reaches, the union drawn as its preview, and where the hint goes. */
|
|
751
|
+
const merge = (() => {
|
|
752
|
+
if (!session) return null;
|
|
753
|
+
if (session.kind === "resize") {
|
|
754
|
+
const resize = session.plan;
|
|
755
|
+
if (resize.kind === "blocked" || resize.merges.length === 0) return null;
|
|
756
|
+
return {
|
|
757
|
+
targets: resize.merges,
|
|
758
|
+
union: {
|
|
759
|
+
start: resize.start,
|
|
760
|
+
end: resize.end
|
|
761
|
+
},
|
|
762
|
+
at: session.edge === "end" ? resize.end : resize.start
|
|
763
|
+
};
|
|
764
|
+
}
|
|
765
|
+
let taskId;
|
|
766
|
+
let range;
|
|
767
|
+
let exceptPartId;
|
|
768
|
+
if (session.kind === "move") {
|
|
769
|
+
const part = state.parts.find(item => item.id === session.partId);
|
|
770
|
+
if (!part) return null;
|
|
771
|
+
taskId = part.taskId;
|
|
772
|
+
range = {
|
|
773
|
+
start: session.start,
|
|
774
|
+
end: session.start + part.durationMinutes
|
|
775
|
+
};
|
|
776
|
+
exceptPartId = part.id;
|
|
777
|
+
} else {
|
|
778
|
+
if (session.minute === null) return null;
|
|
779
|
+
const drop = planDrop(state, TB_CONTEXT, session.taskId, date, session.minute);
|
|
780
|
+
if ("error" in drop) return null;
|
|
781
|
+
taskId = session.taskId;
|
|
782
|
+
range = {
|
|
783
|
+
start: drop.start,
|
|
784
|
+
end: drop.start + drop.minutes
|
|
785
|
+
};
|
|
786
|
+
}
|
|
787
|
+
const _mergeTargets = mergeTargets(state, taskId, date, range, exceptPartId),
|
|
788
|
+
parts = _mergeTargets.parts,
|
|
789
|
+
union = _mergeTargets.union;
|
|
790
|
+
if (parts.length === 0) return null;
|
|
791
|
+
/* The hint sits at the edge that meets the first timebox it joins. */
|
|
792
|
+
const first = rangeOf(parts[0]);
|
|
793
|
+
return {
|
|
794
|
+
targets: parts,
|
|
795
|
+
union,
|
|
796
|
+
at: first.start >= range.start ? range.end : range.start
|
|
797
|
+
};
|
|
798
|
+
})();
|
|
799
|
+
const mergeHint = merge ? /*#__PURE__*/React.createElement("span", {
|
|
800
|
+
className: "edge-hint",
|
|
801
|
+
style: {
|
|
802
|
+
top: minuteTop(merge.at)
|
|
803
|
+
}
|
|
804
|
+
}, /*#__PURE__*/React.createElement(Caption1, null, "Merges with " + merge.targets.map(part => timeRange(rangeOf(part).start, rangeOf(part).end)).join(", "))) : null;
|
|
805
|
+
const ridesOnDragged = partId => {
|
|
806
|
+
var _merge$targets$some;
|
|
807
|
+
return ((session == null ? void 0 : session.kind) === "move" || (session == null ? void 0 : session.kind) === "resize") && ((_merge$targets$some = merge == null ? void 0 : merge.targets.some(part => part.id === partId)) != null ? _merge$targets$some : false);
|
|
808
|
+
};
|
|
809
|
+
const rangeFor = timebox => {
|
|
810
|
+
if ((session == null ? void 0 : session.kind) === "move" && session.partId === timebox.part.id) {
|
|
811
|
+
return merge ? merge.union : {
|
|
812
|
+
start: session.start,
|
|
813
|
+
end: session.start + timebox.part.durationMinutes
|
|
814
|
+
};
|
|
815
|
+
}
|
|
816
|
+
if ((session == null ? void 0 : session.kind) === "resize" && session.partId === timebox.part.id) {
|
|
817
|
+
return {
|
|
818
|
+
start: session.plan.start,
|
|
819
|
+
end: session.plan.end
|
|
820
|
+
};
|
|
821
|
+
}
|
|
822
|
+
return timebox.range;
|
|
823
|
+
};
|
|
824
|
+
const items = [...events.map(event => _extends({
|
|
825
|
+
kind: "event",
|
|
826
|
+
event
|
|
827
|
+
}, eventRange(event))),
|
|
828
|
+
/* Timeboxes a move or resize will join ride on the dragged one's lane
|
|
829
|
+
(drawn with it, below), so the union does not push them aside. */
|
|
830
|
+
...visibleTimeboxes.filter(timebox => !ridesOnDragged(timebox.part.id)).map(timebox => _extends({
|
|
831
|
+
kind: "timebox",
|
|
832
|
+
timebox
|
|
833
|
+
}, rangeFor(timebox))), ...plan.suggestions.map(suggestion => ({
|
|
834
|
+
kind: "suggestion",
|
|
835
|
+
suggestion,
|
|
836
|
+
start: suggestion.start,
|
|
837
|
+
end: suggestion.end
|
|
838
|
+
}))];
|
|
839
|
+
const dragPreview = (_merge$union => {
|
|
840
|
+
if ((session == null ? void 0 : session.kind) !== "task" || session.minute === null) return null;
|
|
841
|
+
const task = taskOf(session.taskId);
|
|
842
|
+
if (!task) return null;
|
|
843
|
+
const drop = planDrop(state, TB_CONTEXT, session.taskId, date, session.minute);
|
|
844
|
+
if ("error" in drop) {
|
|
845
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
846
|
+
className: "drop-preview invalid",
|
|
847
|
+
style: {
|
|
848
|
+
top: minuteTop(snap(session.minute)),
|
|
849
|
+
height: minuteTop(30)
|
|
850
|
+
}
|
|
851
|
+
}, /*#__PURE__*/React.createElement(Caption1, {
|
|
852
|
+
color: "alert"
|
|
853
|
+
}, drop.error));
|
|
854
|
+
}
|
|
855
|
+
/* Joining one of its own timeboxes, the preview is the union. */
|
|
856
|
+
const shown = (_merge$union = merge == null ? void 0 : merge.union) != null ? _merge$union : {
|
|
857
|
+
start: drop.start,
|
|
858
|
+
end: drop.start + drop.minutes
|
|
859
|
+
};
|
|
860
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
861
|
+
className: "drop-preview",
|
|
862
|
+
style: {
|
|
863
|
+
top: minuteTop(shown.start),
|
|
864
|
+
height: minuteTop(shown.end - shown.start)
|
|
865
|
+
}
|
|
866
|
+
}, /*#__PURE__*/React.createElement(Caption1, null, task.name + " \xB7 " + timeRange(shown.start, shown.end)));
|
|
867
|
+
})();
|
|
868
|
+
const edgeHint = (() => {
|
|
869
|
+
if (mergeHint) return mergeHint;
|
|
870
|
+
if ((session == null ? void 0 : session.kind) !== "resize") return null;
|
|
871
|
+
const resize = session.plan;
|
|
872
|
+
const at = session.edge === "end" ? resize.end : resize.start;
|
|
873
|
+
if (resize.kind === "blocked" && resize.reason) {
|
|
874
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
875
|
+
className: "edge-hint",
|
|
876
|
+
style: {
|
|
877
|
+
top: minuteTop(at)
|
|
878
|
+
}
|
|
879
|
+
}, /*#__PURE__*/React.createElement(Caption1, {
|
|
880
|
+
color: "alert"
|
|
881
|
+
}, resize.reason));
|
|
882
|
+
}
|
|
883
|
+
if (resize.kind === "increase") {
|
|
884
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
885
|
+
className: "edge-hint",
|
|
886
|
+
style: {
|
|
887
|
+
top: minuteTop(at)
|
|
888
|
+
}
|
|
889
|
+
}, /*#__PURE__*/React.createElement(Caption1, null, "+" + formatMinutes(resize.to - resize.from) + " from the following days"));
|
|
890
|
+
}
|
|
891
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
892
|
+
className: "edge-hint",
|
|
893
|
+
style: {
|
|
894
|
+
top: minuteTop(at)
|
|
895
|
+
}
|
|
896
|
+
}, /*#__PURE__*/React.createElement(Caption1, null, "" + formatMinutes(resize.end - resize.start)));
|
|
897
|
+
})();
|
|
898
|
+
const firstOvertime = plan.suggestions.find(suggestion => suggestion.overtime);
|
|
899
|
+
const scrollToOvertime = () => {
|
|
900
|
+
if (!firstOvertime || !scrollRef.current) return;
|
|
901
|
+
scrollRef.current.scrollTo({
|
|
902
|
+
top: minuteTop(firstOvertime.start) - HOUR_HEIGHT,
|
|
903
|
+
behavior: "smooth"
|
|
904
|
+
});
|
|
905
|
+
};
|
|
906
|
+
const header = /*#__PURE__*/React.createElement(StyledTimeboxDayHeader, {
|
|
907
|
+
className: "dated"
|
|
908
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
909
|
+
className: "header-gutter",
|
|
910
|
+
style: {
|
|
911
|
+
width: TIME_GUTTER
|
|
912
|
+
}
|
|
913
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
914
|
+
className: isToday ? "header-cell today" : "header-cell",
|
|
915
|
+
"aria-current": isToday ? "date" : undefined
|
|
916
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
917
|
+
className: "header-main"
|
|
918
|
+
}, /*#__PURE__*/React.createElement(Body2, {
|
|
919
|
+
weight: "bold",
|
|
920
|
+
color: isToday ? "theme-primary" : "primary",
|
|
921
|
+
className: "header-line"
|
|
922
|
+
}, longDayOf(day)), /*#__PURE__*/React.createElement(Typography, {
|
|
923
|
+
variant: "Caption 1",
|
|
924
|
+
weight: "medium",
|
|
925
|
+
color: isToday ? "theme-primary" : "secondary",
|
|
926
|
+
className: "header-line"
|
|
927
|
+
}, SHORT_MONTHS[toDate(day).getUTCMonth()] + " " + toDate(day).getUTCDate()), /*#__PURE__*/React.createElement(CapacityBar, {
|
|
928
|
+
scheduled: plan.scheduled,
|
|
929
|
+
allocated: plan.allocated,
|
|
930
|
+
capacity: plan.capacity,
|
|
931
|
+
over: plan.overbooked > 0,
|
|
932
|
+
tooltip: formatMinutes(plan.scheduled) + " / " + formatMinutes(plan.allocated) + " / " + formatMinutes(plan.capacity) + " \u2014 scheduled / allocated / capacity",
|
|
933
|
+
onClick: firstOvertime ? scrollToOvertime : undefined
|
|
934
|
+
})), plan.overbooked > 0 ? /*#__PURE__*/React.createElement("div", {
|
|
935
|
+
className: "header-warning"
|
|
936
|
+
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
937
|
+
title: firstOvertime ? "Show the first overtime block" : "Part of today did not fit before midnight"
|
|
938
|
+
}, /*#__PURE__*/React.createElement(StyledTextTrigger, {
|
|
939
|
+
onClick: scrollToOvertime
|
|
940
|
+
}, /*#__PURE__*/React.createElement(WarningTriangleSmallIcon, {
|
|
941
|
+
width: 12,
|
|
942
|
+
height: 12,
|
|
943
|
+
style: {
|
|
944
|
+
fill: "var(--red-alert)",
|
|
945
|
+
marginRight: 4
|
|
946
|
+
},
|
|
947
|
+
"aria-hidden": true
|
|
948
|
+
}), /*#__PURE__*/React.createElement(Caption1, {
|
|
949
|
+
color: "alert",
|
|
950
|
+
weight: "bold"
|
|
951
|
+
}, "Overbooked " + formatMinutes(plan.overbooked))))) : null), actual ? /*#__PURE__*/React.createElement("div", {
|
|
952
|
+
className: "header-cell tracked-header"
|
|
953
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
954
|
+
className: "header-main"
|
|
955
|
+
}, /*#__PURE__*/React.createElement(Body2, {
|
|
956
|
+
weight: "bold",
|
|
957
|
+
className: "header-line"
|
|
958
|
+
}, "Tracked"), /*#__PURE__*/React.createElement(Typography, {
|
|
959
|
+
variant: "Caption 1",
|
|
960
|
+
weight: "medium",
|
|
961
|
+
color: "secondary",
|
|
962
|
+
className: "header-line"
|
|
963
|
+
}, formatMinutes(trackedByUserOn(state, ME, date)) + " of " + formatMinutes(plan.allocated) + " planned"))) : null);
|
|
964
|
+
|
|
965
|
+
/* All Day: tasks without an estimate (dragged in as 1h), subtasks, and
|
|
966
|
+
what did not fit before midnight. */
|
|
967
|
+
const allDayEntries = [...plan.withoutEstimate.map(task => ({
|
|
968
|
+
key: "task-" + task.id,
|
|
969
|
+
kind: "task",
|
|
970
|
+
name: task.name,
|
|
971
|
+
startDay: day,
|
|
972
|
+
endDay: day,
|
|
973
|
+
color: projectColorOf(task),
|
|
974
|
+
completed: task.isCompleted,
|
|
975
|
+
important: task.isImportant,
|
|
976
|
+
participant: true,
|
|
977
|
+
taskNumber: task.id
|
|
978
|
+
})), ...(options.showSubtasks ? state.subtasks : []).filter(subtask => subtask.dueOn === date).filter(subtask => options.showCompleted || !subtask.isCompleted).map(subtask => {
|
|
979
|
+
const parent = taskOf(subtask.taskId);
|
|
980
|
+
return {
|
|
981
|
+
key: "subtask-" + subtask.id,
|
|
982
|
+
kind: "subtask",
|
|
983
|
+
name: subtask.name,
|
|
984
|
+
startDay: day,
|
|
985
|
+
endDay: day,
|
|
986
|
+
color: parent ? projectColorOf(parent) : "",
|
|
987
|
+
completed: subtask.isCompleted,
|
|
988
|
+
important: false,
|
|
989
|
+
participant: true
|
|
990
|
+
};
|
|
991
|
+
}), ...plan.unscheduled.map(rest => {
|
|
992
|
+
var _taskOf$name, _taskOf;
|
|
993
|
+
return {
|
|
994
|
+
key: "unscheduled-" + rest.taskId,
|
|
995
|
+
kind: "task",
|
|
996
|
+
name: ((_taskOf$name = (_taskOf = taskOf(rest.taskId)) == null ? void 0 : _taskOf.name) != null ? _taskOf$name : "") + " \xB7 " + formatMinutes(rest.minutes) + " unscheduled",
|
|
997
|
+
startDay: day,
|
|
998
|
+
endDay: day,
|
|
999
|
+
color: "",
|
|
1000
|
+
completed: false,
|
|
1001
|
+
important: false,
|
|
1002
|
+
participant: true
|
|
1003
|
+
};
|
|
1004
|
+
}),
|
|
1005
|
+
/* The Tracked column's half (the row's second "day"): tracked time
|
|
1006
|
+
with no block to take the place of. */
|
|
1007
|
+
...((_actual$untimed = actual == null ? void 0 : actual.untimed) != null ? _actual$untimed : []).map(item => {
|
|
1008
|
+
var _task$name, _task$isCompleted;
|
|
1009
|
+
const task = taskOf(item.taskId);
|
|
1010
|
+
return {
|
|
1011
|
+
key: "tracked-untimed-" + item.taskId,
|
|
1012
|
+
kind: "task",
|
|
1013
|
+
name: ((_task$name = task == null ? void 0 : task.name) != null ? _task$name : "") + " \xB7 " + formatMinutes(item.minutes) + " tracked",
|
|
1014
|
+
startDay: day + 1,
|
|
1015
|
+
endDay: day + 1,
|
|
1016
|
+
color: task ? projectColorOf(task) : "",
|
|
1017
|
+
completed: (_task$isCompleted = task == null ? void 0 : task.isCompleted) != null ? _task$isCompleted : false,
|
|
1018
|
+
important: false,
|
|
1019
|
+
participant: true
|
|
1020
|
+
};
|
|
1021
|
+
})];
|
|
1022
|
+
const renderAllDay = (segment, style) => {
|
|
1023
|
+
if (segment.key.startsWith("unscheduled-")) {
|
|
1024
|
+
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
1025
|
+
title: "Did not fit before midnight"
|
|
1026
|
+
}, /*#__PURE__*/React.createElement(StyledUnscheduledPill, {
|
|
1027
|
+
style: style
|
|
1028
|
+
}, /*#__PURE__*/React.createElement(WarningTriangleSmallIcon, {
|
|
1029
|
+
width: 12,
|
|
1030
|
+
height: 12,
|
|
1031
|
+
style: {
|
|
1032
|
+
fill: "var(--red-alert)",
|
|
1033
|
+
flexShrink: 0
|
|
1034
|
+
},
|
|
1035
|
+
"aria-hidden": true
|
|
1036
|
+
}), /*#__PURE__*/React.createElement(Caption1, {
|
|
1037
|
+
color: "alert",
|
|
1038
|
+
className: "pill-name"
|
|
1039
|
+
}, segment.name)));
|
|
1040
|
+
}
|
|
1041
|
+
if (segment.kind === "task" && segment.taskNumber !== undefined) {
|
|
1042
|
+
const taskId = segment.taskNumber;
|
|
1043
|
+
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
1044
|
+
title: "Drag onto the day to pin an hour"
|
|
1045
|
+
}, /*#__PURE__*/React.createElement(StyledDragPill, {
|
|
1046
|
+
style: _extends({}, style, {
|
|
1047
|
+
["--event-color"]: segment.color
|
|
1048
|
+
}),
|
|
1049
|
+
onPointerDown: event => startTaskDrag(taskId, event)
|
|
1050
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
1051
|
+
className: "pill-lead"
|
|
1052
|
+
}, /*#__PURE__*/React.createElement(Caption1, {
|
|
1053
|
+
color: "tertiary",
|
|
1054
|
+
className: "pill-time"
|
|
1055
|
+
}, "#" + taskId), /*#__PURE__*/React.createElement(Caption1, {
|
|
1056
|
+
className: "pill-name"
|
|
1057
|
+
}, segment.name))));
|
|
1058
|
+
}
|
|
1059
|
+
return null;
|
|
1060
|
+
};
|
|
1061
|
+
|
|
1062
|
+
/* ---------------------------------------------------------------- */
|
|
1063
|
+
/* The task list */
|
|
1064
|
+
/* ---------------------------------------------------------------- */
|
|
1065
|
+
|
|
1066
|
+
const listState = _extends({}, myWorkTasks, {
|
|
1067
|
+
/* Completion lives in the timeboxes store, so the payload's flag is
|
|
1068
|
+
the truth and nothing is toggled locally. */
|
|
1069
|
+
completed: new Set(),
|
|
1070
|
+
toggleCompleted: key => {
|
|
1071
|
+
const _key$split = key.split("-"),
|
|
1072
|
+
kind = _key$split[0],
|
|
1073
|
+
id = _key$split[1];
|
|
1074
|
+
if (kind === "task") {
|
|
1075
|
+
const task = taskOf(Number(id));
|
|
1076
|
+
if (task) act({
|
|
1077
|
+
type: "setCompleted",
|
|
1078
|
+
taskId: task.id,
|
|
1079
|
+
completed: !task.isCompleted
|
|
1080
|
+
});
|
|
1081
|
+
} else {
|
|
1082
|
+
const subtask = state.subtasks.find(item => item.id === Number(id));
|
|
1083
|
+
if (subtask) {
|
|
1084
|
+
act({
|
|
1085
|
+
type: "setSubtaskCompleted",
|
|
1086
|
+
subtaskId: subtask.id,
|
|
1087
|
+
completed: !subtask.isCompleted
|
|
1088
|
+
});
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
});
|
|
1093
|
+
const groups = PROJECTS.map(project => {
|
|
1094
|
+
const tasks = myTasks.filter(task => task.projectId === project.id && isInRange(task, date)).filter(task => options.showCompleted || !task.isCompleted).sort((a, b) => a.position - b.position);
|
|
1095
|
+
const rows = tasks.flatMap(task => [{
|
|
1096
|
+
kind: "task",
|
|
1097
|
+
key: "task-" + task.id,
|
|
1098
|
+
task: listTaskOf(task)
|
|
1099
|
+
}, ...(options.showSubtasks ? state.subtasks : []).filter(subtask => subtask.taskId === task.id && subtask.dueOn === date).filter(subtask => options.showCompleted || !subtask.isCompleted).map(subtask => ({
|
|
1100
|
+
kind: "subtask",
|
|
1101
|
+
key: "subtask-" + subtask.id,
|
|
1102
|
+
subtask: {
|
|
1103
|
+
id: subtask.id,
|
|
1104
|
+
task_id: subtask.taskId,
|
|
1105
|
+
name: subtask.name,
|
|
1106
|
+
due_on: isoToDayNumber(subtask.dueOn),
|
|
1107
|
+
is_completed: subtask.isCompleted
|
|
1108
|
+
},
|
|
1109
|
+
task: listTaskOf(task)
|
|
1110
|
+
}))]);
|
|
1111
|
+
return {
|
|
1112
|
+
project: {
|
|
1113
|
+
id: project.id,
|
|
1114
|
+
name: project.name,
|
|
1115
|
+
company: project.company
|
|
1116
|
+
},
|
|
1117
|
+
rows
|
|
1118
|
+
};
|
|
1119
|
+
}).filter(group => group.rows.length > 0);
|
|
1120
|
+
|
|
1121
|
+
/** A row's second line: today's timeboxes, suggestions and what is left. */
|
|
1122
|
+
const rowPlanLine = task => {
|
|
1123
|
+
/* "Plan 1h30 · tracked 1h": the day's allocation and its records. */
|
|
1124
|
+
const tracked = trackedColumn ? trackedOn(state, task.id, date) : 0;
|
|
1125
|
+
const trackedPart = !trackedColumn ? null : task.isCompleted || task.estimate === null ? tracked > 0 ? /*#__PURE__*/React.createElement(Caption1, {
|
|
1126
|
+
color: "secondary",
|
|
1127
|
+
className: "block-part"
|
|
1128
|
+
}, "Tracked " + formatMinutes(tracked)) : null : /*#__PURE__*/React.createElement(Caption1, {
|
|
1129
|
+
color: "secondary",
|
|
1130
|
+
className: "block-part"
|
|
1131
|
+
}, "Plan " + formatMinutes(allocationOn(state, task, user, date)) + " \xB7 tracked " + formatMinutes(tracked));
|
|
1132
|
+
if (task.isCompleted) return trackedPart;
|
|
1133
|
+
if (task.estimate === null) {
|
|
1134
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, trackedPart, /*#__PURE__*/React.createElement(Caption1, {
|
|
1135
|
+
color: "tertiary",
|
|
1136
|
+
className: "block-part"
|
|
1137
|
+
}, "No estimate \xB7 drag it in to pin 1h"));
|
|
1138
|
+
}
|
|
1139
|
+
const boxes = timeboxesOn(state, task.id, date);
|
|
1140
|
+
const suggestions = plan.suggestions.filter(item => item.taskId === task.id);
|
|
1141
|
+
const overtime = suggestions.filter(item => item.overtime);
|
|
1142
|
+
const left = Math.max(0, untimedOn(state, task, user, date));
|
|
1143
|
+
const unscheduled = plan.unscheduled.find(item => item.taskId === task.id);
|
|
1144
|
+
const color = projectColorOf(task);
|
|
1145
|
+
if (boxes.length === 0 && left === 0) return trackedPart;
|
|
1146
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, trackedPart, boxes.map(part => {
|
|
1147
|
+
const range = rangeOf(part);
|
|
1148
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
1149
|
+
className: "block-part",
|
|
1150
|
+
key: part.id
|
|
1151
|
+
}, /*#__PURE__*/React.createElement(PinSmallIcon, {
|
|
1152
|
+
width: 12,
|
|
1153
|
+
height: 12,
|
|
1154
|
+
style: {
|
|
1155
|
+
fill: color,
|
|
1156
|
+
flexShrink: 0
|
|
1157
|
+
},
|
|
1158
|
+
"aria-hidden": true
|
|
1159
|
+
}), /*#__PURE__*/React.createElement(Caption1, {
|
|
1160
|
+
color: "secondary"
|
|
1161
|
+
}, timeRange(range.start, range.end) + " \xB7 pinned"));
|
|
1162
|
+
}), suggestions.length > 0 ? /*#__PURE__*/React.createElement("span", {
|
|
1163
|
+
className: "block-part"
|
|
1164
|
+
}, /*#__PURE__*/React.createElement(SparkIcon, {
|
|
1165
|
+
width: 12,
|
|
1166
|
+
height: 12,
|
|
1167
|
+
style: {
|
|
1168
|
+
fill: color,
|
|
1169
|
+
flexShrink: 0
|
|
1170
|
+
},
|
|
1171
|
+
"aria-hidden": true
|
|
1172
|
+
}), /*#__PURE__*/React.createElement(Caption1, {
|
|
1173
|
+
color: "secondary"
|
|
1174
|
+
}, suggestions.length + " " + (suggestions.length === 1 ? "suggestion" : "suggestions") + (overtime.length > 0 ? " (" + overtime.length + " overtime)" : ""))) : null, left > 0 ? /*#__PURE__*/React.createElement(Caption1, {
|
|
1175
|
+
color: "tertiary",
|
|
1176
|
+
className: "block-part"
|
|
1177
|
+
}, formatMinutes(left) + " left to pin") : null, unscheduled ? /*#__PURE__*/React.createElement(Caption1, {
|
|
1178
|
+
color: "alert",
|
|
1179
|
+
className: "block-part"
|
|
1180
|
+
}, formatMinutes(unscheduled.minutes) + " unscheduled") : null);
|
|
1181
|
+
};
|
|
1182
|
+
const rowBehaviour = row => {
|
|
1183
|
+
if (row.kind !== "task") return undefined;
|
|
1184
|
+
const task = taskOf(row.task.id);
|
|
1185
|
+
if (!task || task.isCompleted) return undefined;
|
|
1186
|
+
const minutes = draggableMinutes(state, TB_CONTEXT, task.id, date);
|
|
1187
|
+
const menuOpen = menuKey === "row-" + task.id;
|
|
1188
|
+
const menu = /*#__PURE__*/React.createElement(Menu, {
|
|
1189
|
+
open: menuOpen,
|
|
1190
|
+
onOpen: () => setMenuKey("row-" + task.id),
|
|
1191
|
+
onClose: () => setMenuKey(null),
|
|
1192
|
+
position: "bottom-end",
|
|
1193
|
+
target: /*#__PURE__*/React.createElement(IconButton, {
|
|
1194
|
+
type: "button",
|
|
1195
|
+
size: "small",
|
|
1196
|
+
variant: "text gray",
|
|
1197
|
+
"aria-label": "Task options",
|
|
1198
|
+
className: menuOpen ? "row-menu open" : "row-menu",
|
|
1199
|
+
active: menuOpen
|
|
1200
|
+
}, /*#__PURE__*/React.createElement(TreeDotsIcon, null))
|
|
1201
|
+
}, /*#__PURE__*/React.createElement(List, {
|
|
1202
|
+
tabIndex: 0
|
|
1203
|
+
}, /*#__PURE__*/React.createElement(ListItem, {
|
|
1204
|
+
onClick: () => {
|
|
1205
|
+
setMenuKey(null);
|
|
1206
|
+
scheduleTask(task.id);
|
|
1207
|
+
}
|
|
1208
|
+
}, "Schedule\u2026"), /*#__PURE__*/React.createElement(ListSeparator, null), /*#__PURE__*/React.createElement(ListItem, {
|
|
1209
|
+
onClick: () => setMenuKey(null)
|
|
1210
|
+
}, "Open task")));
|
|
1211
|
+
return minutes > 0 ? {
|
|
1212
|
+
onPointerDown: event => startTaskDrag(task.id, event),
|
|
1213
|
+
menu
|
|
1214
|
+
} : {
|
|
1215
|
+
hint: "All of today's allocation is scheduled",
|
|
1216
|
+
menu
|
|
1217
|
+
};
|
|
1218
|
+
};
|
|
1219
|
+
|
|
1220
|
+
/* ---------------------------------------------------------------- */
|
|
1221
|
+
/* Render */
|
|
1222
|
+
/* ---------------------------------------------------------------- */
|
|
1223
|
+
|
|
1224
|
+
/* A column's off-hours, pause and hour lines. */
|
|
1225
|
+
const offHours = /*#__PURE__*/React.createElement(React.Fragment, null, plan.capacity > 0 ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
1226
|
+
className: "off-hours",
|
|
1227
|
+
style: {
|
|
1228
|
+
top: 0,
|
|
1229
|
+
height: minuteTop(plan.window.start)
|
|
1230
|
+
}
|
|
1231
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
1232
|
+
className: "off-hours",
|
|
1233
|
+
style: {
|
|
1234
|
+
top: minuteTop(plan.window.end),
|
|
1235
|
+
bottom: 0
|
|
1236
|
+
}
|
|
1237
|
+
})) : null, plan.pause ? /*#__PURE__*/React.createElement("span", {
|
|
1238
|
+
className: "pause-band",
|
|
1239
|
+
style: {
|
|
1240
|
+
top: minuteTop(plan.pause.start),
|
|
1241
|
+
height: minuteTop(plan.pause.end - plan.pause.start)
|
|
1242
|
+
}
|
|
1243
|
+
}) : null, /*#__PURE__*/React.createElement("span", {
|
|
1244
|
+
className: "slot-lines"
|
|
1245
|
+
}));
|
|
1246
|
+
const dayIndex = WEEK_DAYS.indexOf(date);
|
|
1247
|
+
const dragged = (session == null ? void 0 : session.kind) === "task" ? taskOf(session.taskId) : undefined;
|
|
1248
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MyWorkTabs, {
|
|
1249
|
+
active: "agenda",
|
|
1250
|
+
onSelect: () => undefined,
|
|
1251
|
+
tasksCount: myWorkTasks.openCount,
|
|
1252
|
+
controls: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(AgendaFilter, null), /*#__PURE__*/React.createElement(AgendaViewSwitch, {
|
|
1253
|
+
view: "day",
|
|
1254
|
+
onChange: () => undefined
|
|
1255
|
+
}))
|
|
1256
|
+
}), /*#__PURE__*/React.createElement(StyledMyCalendarPaper, {
|
|
1257
|
+
type: "paper-2",
|
|
1258
|
+
ref: paperRef,
|
|
1259
|
+
className: fillHeight === null ? undefined : "fill-height",
|
|
1260
|
+
style: fillHeight === null ? undefined : {
|
|
1261
|
+
"--fill-height": fillHeight + "px"
|
|
1262
|
+
}
|
|
1263
|
+
}, /*#__PURE__*/React.createElement(StyledMyCalendarToolbar, null, /*#__PURE__*/React.createElement(Tooltip, {
|
|
1264
|
+
title: "Previous Day"
|
|
1265
|
+
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
1266
|
+
type: "button",
|
|
1267
|
+
size: "small",
|
|
1268
|
+
variant: "text gray",
|
|
1269
|
+
"aria-label": "Previous Day",
|
|
1270
|
+
disabled: dayIndex <= 0,
|
|
1271
|
+
onClick: () => onDateChange(WEEK_DAYS[dayIndex - 1])
|
|
1272
|
+
}, /*#__PURE__*/React.createElement(ArrowLeftIcon, null))), /*#__PURE__*/React.createElement(Tooltip, {
|
|
1273
|
+
title: "Next Day"
|
|
1274
|
+
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
1275
|
+
type: "button",
|
|
1276
|
+
size: "small",
|
|
1277
|
+
variant: "text gray",
|
|
1278
|
+
"aria-label": "Next Day",
|
|
1279
|
+
disabled: dayIndex >= WEEK_DAYS.length - 1,
|
|
1280
|
+
onClick: () => onDateChange(WEEK_DAYS[dayIndex + 1])
|
|
1281
|
+
}, /*#__PURE__*/React.createElement(ArrowRightIcon, null))), /*#__PURE__*/React.createElement(Body2, {
|
|
1282
|
+
weight: "bold",
|
|
1283
|
+
className: "period-label"
|
|
1284
|
+
}, periodLabelFor("day", day)), isToday ? null : /*#__PURE__*/React.createElement(Button, {
|
|
1285
|
+
type: "button",
|
|
1286
|
+
size: "small",
|
|
1287
|
+
variant: "text gray",
|
|
1288
|
+
onClick: () => onDateChange(TODAY)
|
|
1289
|
+
}, "Today"), /*#__PURE__*/React.createElement("span", {
|
|
1290
|
+
className: "toolbar-spacer"
|
|
1291
|
+
}), /*#__PURE__*/React.createElement(MyCalendarOptionsMenu, {
|
|
1292
|
+
options: options,
|
|
1293
|
+
onToggle: key => setOptions(previous => _extends({}, previous, {
|
|
1294
|
+
[key]: !previous[key]
|
|
1295
|
+
}))
|
|
1296
|
+
})), /*#__PURE__*/React.createElement(StyledDaySplit, {
|
|
1297
|
+
style: dayGrid.width === null ? trackedColumn ? /* Two columns: more of the page than the 40% default. */
|
|
1298
|
+
{
|
|
1299
|
+
"--day-grid-width": "60%"
|
|
1300
|
+
} : undefined : {
|
|
1301
|
+
"--day-grid-width": dayGrid.width + "px"
|
|
1302
|
+
}
|
|
1303
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1304
|
+
className: "day-grid"
|
|
1305
|
+
}, header, /*#__PURE__*/React.createElement(LaneRow, {
|
|
1306
|
+
className: "all-day-row",
|
|
1307
|
+
days: actual ? [day, day + 1] : [day],
|
|
1308
|
+
entries: allDayEntries,
|
|
1309
|
+
today: isoToDayNumber(TODAY),
|
|
1310
|
+
isNonWorking: () => false,
|
|
1311
|
+
gutterWidth: TIME_GUTTER,
|
|
1312
|
+
gutter: /*#__PURE__*/React.createElement(Caption1, {
|
|
1313
|
+
color: "secondary"
|
|
1314
|
+
}, "All Day"),
|
|
1315
|
+
showTaskIds: true,
|
|
1316
|
+
maxLanes: ALL_DAY_VISIBLE_LANES,
|
|
1317
|
+
renderSegment: renderAllDay
|
|
1318
|
+
}), /*#__PURE__*/React.createElement(StyledTimeboxGrid, {
|
|
1319
|
+
ref: scrollRef,
|
|
1320
|
+
className: "hour-grid"
|
|
1321
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1322
|
+
className: "time-canvas"
|
|
1323
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1324
|
+
className: "time-gutter",
|
|
1325
|
+
style: {
|
|
1326
|
+
width: TIME_GUTTER
|
|
1327
|
+
}
|
|
1328
|
+
}, Array.from({
|
|
1329
|
+
length: 23
|
|
1330
|
+
}, (_, index) => index + 1).map(hour => /*#__PURE__*/React.createElement(Caption1, {
|
|
1331
|
+
color: "secondary",
|
|
1332
|
+
className: "hour-label",
|
|
1333
|
+
key: hour,
|
|
1334
|
+
style: {
|
|
1335
|
+
top: hour * HOUR_HEIGHT
|
|
1336
|
+
}
|
|
1337
|
+
}, formatTimeOfDay(hour * 60)))), /*#__PURE__*/React.createElement("div", {
|
|
1338
|
+
className: "time-columns"
|
|
1339
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1340
|
+
ref: columnRef,
|
|
1341
|
+
className: ["time-column", isToday ? "today" : "", past ? "past" : ""].filter(Boolean).join(" ")
|
|
1342
|
+
}, offHours, placeSideBySide(items, item => item.start, item => item.end).map(_ref7 => {
|
|
1343
|
+
let item = _ref7.item,
|
|
1344
|
+
column = _ref7.column,
|
|
1345
|
+
columns = _ref7.columns;
|
|
1346
|
+
const placement = {
|
|
1347
|
+
top: minuteTop(item.start),
|
|
1348
|
+
left: "calc(" + percentOf(column, columns) + " + 2px)",
|
|
1349
|
+
width: "calc(" + percentOf(1, columns) + " - 4px)"
|
|
1350
|
+
};
|
|
1351
|
+
if (item.kind === "event") {
|
|
1352
|
+
const height = Math.max(minuteTop(item.end - item.start), 20);
|
|
1353
|
+
return /*#__PURE__*/React.createElement(EventPill, {
|
|
1354
|
+
key: "event-" + item.event.id,
|
|
1355
|
+
event: item.event,
|
|
1356
|
+
style: _extends({}, placement, {
|
|
1357
|
+
height
|
|
1358
|
+
})
|
|
1359
|
+
});
|
|
1360
|
+
}
|
|
1361
|
+
if (item.kind === "timebox") {
|
|
1362
|
+
var _merge$targets$some2;
|
|
1363
|
+
const timebox = item.timebox;
|
|
1364
|
+
const key = timeboxKey(timebox.part.id);
|
|
1365
|
+
const dragged = ((session == null ? void 0 : session.kind) === "move" || (session == null ? void 0 : session.kind) === "resize") && session.partId === timebox.part.id;
|
|
1366
|
+
/* The timeboxes it will join, outlined over the
|
|
1367
|
+
union in the same lane. */
|
|
1368
|
+
const joining = dragged ? visibleTimeboxes.filter(other => ridesOnDragged(other.part.id)) : [];
|
|
1369
|
+
const card = /*#__PURE__*/React.createElement(TimeboxCard, {
|
|
1370
|
+
key: key,
|
|
1371
|
+
timebox: timebox,
|
|
1372
|
+
range: {
|
|
1373
|
+
start: item.start,
|
|
1374
|
+
end: item.end
|
|
1375
|
+
},
|
|
1376
|
+
style: placement,
|
|
1377
|
+
dragging: dragged,
|
|
1378
|
+
mergeTarget: (_merge$targets$some2 = merge == null ? void 0 : merge.targets.some(part => part.id === timebox.part.id)) != null ? _merge$targets$some2 : false,
|
|
1379
|
+
changed: changedBoxes.has(timebox.part.id),
|
|
1380
|
+
menuOpen: menuKey === key,
|
|
1381
|
+
onMenu: open => setMenuKey(open ? key : null),
|
|
1382
|
+
onPointerDownBody: event => startMove(timebox, event),
|
|
1383
|
+
onPointerDownEdge: (event, edge) => startResize(timebox, event, edge)
|
|
1384
|
+
});
|
|
1385
|
+
if (joining.length === 0) return card;
|
|
1386
|
+
return /*#__PURE__*/React.createElement(Fragment, {
|
|
1387
|
+
key: key
|
|
1388
|
+
}, card, joining.map(other => /*#__PURE__*/React.createElement(TimeboxCard, {
|
|
1389
|
+
key: "box-" + other.part.id,
|
|
1390
|
+
timebox: other,
|
|
1391
|
+
range: other.range,
|
|
1392
|
+
style: _extends({}, placement, {
|
|
1393
|
+
top: minuteTop(other.range.start)
|
|
1394
|
+
}),
|
|
1395
|
+
dragging: false,
|
|
1396
|
+
mergeTarget: true,
|
|
1397
|
+
changed: false,
|
|
1398
|
+
menuOpen: false,
|
|
1399
|
+
onMenu: () => undefined,
|
|
1400
|
+
onPointerDownBody: () => undefined,
|
|
1401
|
+
onPointerDownEdge: () => undefined
|
|
1402
|
+
})));
|
|
1403
|
+
}
|
|
1404
|
+
const suggestion = item.suggestion;
|
|
1405
|
+
const task = taskOf(suggestion.taskId);
|
|
1406
|
+
if (!task) return null;
|
|
1407
|
+
const key = suggestionKey(suggestion);
|
|
1408
|
+
return /*#__PURE__*/React.createElement(SuggestionCard, {
|
|
1409
|
+
key: key,
|
|
1410
|
+
suggestion: suggestion,
|
|
1411
|
+
task: task,
|
|
1412
|
+
style: placement,
|
|
1413
|
+
linked: hovered === task.id,
|
|
1414
|
+
changed: changedTasks.has(task.id),
|
|
1415
|
+
menuOpen: menuKey === key,
|
|
1416
|
+
onMenu: open => setMenuKey(open ? key : null),
|
|
1417
|
+
onHover: setHovered,
|
|
1418
|
+
onPin: () => pinSuggestion(suggestion),
|
|
1419
|
+
onPinAll: pinAllForToday
|
|
1420
|
+
});
|
|
1421
|
+
}), dragPreview, edgeHint, isToday ? /*#__PURE__*/React.createElement("span", {
|
|
1422
|
+
className: "now-line",
|
|
1423
|
+
style: {
|
|
1424
|
+
top: minuteTop(NOW_MINUTES)
|
|
1425
|
+
}
|
|
1426
|
+
}) : null), actual ? /*#__PURE__*/React.createElement("div", {
|
|
1427
|
+
className: ["time-column", "tracked-column", isToday ? "today" : ""].filter(Boolean).join(" ")
|
|
1428
|
+
}, offHours, actual.blocks.map(block => {
|
|
1429
|
+
const task = taskOf(block.taskId);
|
|
1430
|
+
if (!task) return null;
|
|
1431
|
+
return /*#__PURE__*/React.createElement(TrackedBlockCard, {
|
|
1432
|
+
key: block.key,
|
|
1433
|
+
block: block,
|
|
1434
|
+
task: task,
|
|
1435
|
+
label: trackedBlockLabel(block),
|
|
1436
|
+
style: {
|
|
1437
|
+
top: minuteTop(block.start),
|
|
1438
|
+
left: 2,
|
|
1439
|
+
right: 2
|
|
1440
|
+
}
|
|
1441
|
+
});
|
|
1442
|
+
}), isToday ? /*#__PURE__*/React.createElement("span", {
|
|
1443
|
+
className: "now-line",
|
|
1444
|
+
style: {
|
|
1445
|
+
top: minuteTop(NOW_MINUTES)
|
|
1446
|
+
}
|
|
1447
|
+
}) : null) : null))), /*#__PURE__*/React.createElement(StyledPanelResizer, {
|
|
1448
|
+
role: "separator",
|
|
1449
|
+
"aria-label": "Resize calendar",
|
|
1450
|
+
"aria-orientation": "vertical",
|
|
1451
|
+
className: dayGrid.resizing ? "day-resizer resizing" : "day-resizer",
|
|
1452
|
+
onPointerDown: dayGrid.startResize
|
|
1453
|
+
})), /*#__PURE__*/React.createElement(StyledDayAgenda, {
|
|
1454
|
+
className: "day-agenda"
|
|
1455
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1456
|
+
className: "agenda-header"
|
|
1457
|
+
}, /*#__PURE__*/React.createElement(Header3, null, "Tasks"), /*#__PURE__*/React.createElement(Tooltip, {
|
|
1458
|
+
title: "Add Task"
|
|
1459
|
+
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
1460
|
+
size: "small",
|
|
1461
|
+
variant: "text gray",
|
|
1462
|
+
"aria-label": "Add Task"
|
|
1463
|
+
}, /*#__PURE__*/React.createElement(AddCrossTinyIcon, null)))), /*#__PURE__*/React.createElement(DayProjectList, {
|
|
1464
|
+
groups: groups,
|
|
1465
|
+
state: listState,
|
|
1466
|
+
empty: /*#__PURE__*/React.createElement(Body2, {
|
|
1467
|
+
color: "tertiary"
|
|
1468
|
+
}, "No tasks on this day."),
|
|
1469
|
+
extraFor: row => {
|
|
1470
|
+
if (row.kind !== "task") return null;
|
|
1471
|
+
const task = taskOf(row.task.id);
|
|
1472
|
+
return task ? rowPlanLine(task) : null;
|
|
1473
|
+
},
|
|
1474
|
+
behaviourFor: rowBehaviour
|
|
1475
|
+
})))), dragged && (session == null ? void 0 : session.kind) === "task" ? /*#__PURE__*/React.createElement(StyledDragGhost, {
|
|
1476
|
+
style: {
|
|
1477
|
+
left: session.x,
|
|
1478
|
+
top: session.y
|
|
1479
|
+
}
|
|
1480
|
+
}, /*#__PURE__*/React.createElement(PinSmallIcon, {
|
|
1481
|
+
width: 12,
|
|
1482
|
+
height: 12,
|
|
1483
|
+
style: {
|
|
1484
|
+
fill: projectColorOf(dragged),
|
|
1485
|
+
flexShrink: 0
|
|
1486
|
+
},
|
|
1487
|
+
"aria-hidden": true
|
|
1488
|
+
}), /*#__PURE__*/React.createElement(Caption1, {
|
|
1489
|
+
className: "ghost-name"
|
|
1490
|
+
}, dragged.name), /*#__PURE__*/React.createElement(Caption1, {
|
|
1491
|
+
color: "tertiary"
|
|
1492
|
+
}, formatMinutes(draggableMinutes(state, TB_CONTEXT, dragged.id, date)))) : null, /*#__PURE__*/React.createElement(ConfirmDialog, {
|
|
1493
|
+
open: confirm !== null,
|
|
1494
|
+
dialogTitle: "Increase today's allocation?",
|
|
1495
|
+
dialogContent: /*#__PURE__*/React.createElement(AdjustmentList, {
|
|
1496
|
+
text: confirm == null ? void 0 : confirm.text,
|
|
1497
|
+
lines: (_confirm$lines = confirm == null ? void 0 : confirm.lines) != null ? _confirm$lines : []
|
|
1498
|
+
}),
|
|
1499
|
+
confirmBtnText: "Increase",
|
|
1500
|
+
cancelBtnText: "Cancel",
|
|
1501
|
+
initialFocus: "confirm",
|
|
1502
|
+
onCancel: () => setConfirm(null),
|
|
1503
|
+
onConfirm: () => {
|
|
1504
|
+
if (confirm) {
|
|
1505
|
+
act({
|
|
1506
|
+
type: "resizeTimebox",
|
|
1507
|
+
partId: confirm.partId,
|
|
1508
|
+
start: confirm.start,
|
|
1509
|
+
end: confirm.end,
|
|
1510
|
+
allowIncrease: true
|
|
1511
|
+
});
|
|
1512
|
+
}
|
|
1513
|
+
setConfirm(null);
|
|
1514
|
+
}
|
|
1515
|
+
}), toast ? /*#__PURE__*/React.createElement(ToastHost, null, /*#__PURE__*/React.createElement(ToastMessage, {
|
|
1516
|
+
text: toast,
|
|
1517
|
+
type: "warning",
|
|
1518
|
+
timeout: 3000,
|
|
1519
|
+
dismissible: true,
|
|
1520
|
+
onClose: () => setToast(null)
|
|
1521
|
+
})) : null);
|
|
1522
|
+
};
|
|
1523
|
+
AgendaDayView.displayName = "AgendaDayView";
|
|
1524
|
+
//# sourceMappingURL=AgendaDayView.js.map
|