@activecollab/components 2.0.542 → 2.0.544
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/CommandPalette/CommandPalette.js +3 -1
- package/dist/cjs/components/CommandPalette/CommandPalette.js.map +1 -1
- package/dist/cjs/components/ConfirmDialog/ConfirmDialog.js +4 -4
- package/dist/cjs/components/ConfirmDialog/ConfirmDialog.js.map +1 -1
- package/dist/cjs/components/Dialog/Dialog.js +12 -9
- package/dist/cjs/components/Dialog/Dialog.js.map +1 -1
- package/dist/cjs/components/Dialog/DialogContext.js.map +1 -1
- package/dist/cjs/components/Dialog/DialogFrame.js +24 -103
- package/dist/cjs/components/Dialog/DialogFrame.js.map +1 -1
- package/dist/cjs/components/Dialog/usePropWarning.js +34 -0
- package/dist/cjs/components/Dialog/usePropWarning.js.map +1 -0
- package/dist/cjs/components/ModalRoot/ModalRoot.js +32 -8
- package/dist/cjs/components/ModalRoot/ModalRoot.js.map +1 -1
- package/dist/cjs/components/ModalRoot/modalRootStack.js +18 -4
- package/dist/cjs/components/ModalRoot/modalRootStack.js.map +1 -1
- package/dist/cjs/components/ObjectFormModal/ObjectFormModal.js +13 -12
- package/dist/cjs/components/ObjectFormModal/ObjectFormModal.js.map +1 -1
- package/dist/cjs/components/Sheet/Sheet.js +17 -5
- package/dist/cjs/components/Sheet/Sheet.js.map +1 -1
- package/dist/cjs/components/Sheet/useHostAboveOpenModal.js +7 -0
- package/dist/cjs/components/Sheet/useHostAboveOpenModal.js.map +1 -1
- package/dist/cjs/components/Wizard/Wizard.js +1 -0
- package/dist/cjs/components/Wizard/Wizard.js.map +1 -1
- package/dist/cjs/presentation/listView/columns.js +622 -184
- package/dist/cjs/presentation/listView/columns.js.map +1 -1
- package/dist/cjs/presentation/myWork/MyWorkListSettingsDialog.js +1 -1
- package/dist/cjs/presentation/myWork/MyWorkListSettingsDialog.js.map +1 -1
- package/dist/cjs/presentation/reports/availabilityExport.js +1 -1
- package/dist/cjs/presentation/reports/availabilityExport.js.map +1 -1
- package/dist/cjs/presentation/selfHostedRedesign/parts.js +6 -6
- package/dist/cjs/presentation/selfHostedRedesign/parts.js.map +1 -1
- package/dist/cjs/presentation/shared/LinkingCommandsButton.js +1 -1
- package/dist/cjs/presentation/shared/LinkingCommandsButton.js.map +1 -1
- package/dist/cjs/presentation/shared/MessageDialog.js +1 -1
- package/dist/cjs/presentation/shared/MessageDialog.js.map +1 -1
- package/dist/cjs/presentation/shared/MessageFeedback.js +1 -1
- package/dist/cjs/presentation/shared/MessageFeedback.js.map +1 -1
- package/dist/cjs/presentation/shared/ProjectOptionsMenu.js +1 -1
- package/dist/cjs/presentation/shared/ProjectOptionsMenu.js.map +1 -1
- package/dist/cjs/presentation/shared/SourceCodeSection.js +2 -2
- package/dist/cjs/presentation/shared/SourceCodeSection.js.map +1 -1
- package/dist/cjs/presentation/shared/UserDetailsDialog.js +1 -1
- package/dist/cjs/presentation/shared/UserDetailsDialog.js.map +1 -1
- package/dist/cjs/presentation/shared/WebhookLogsDialog.js +1 -1
- package/dist/cjs/presentation/shared/WebhookLogsDialog.js.map +1 -1
- package/dist/cjs/presentation/shared/selfHostedSettings.js +1 -1
- package/dist/cjs/presentation/shared/selfHostedSettings.js.map +1 -1
- package/dist/cjs/presentation/shared/selfHostedUpgrade.js +3 -3
- package/dist/cjs/presentation/shared/selfHostedUpgrade.js.map +1 -1
- package/dist/cjs/presentation/shared/systemSettingsDialog.js +1 -1
- package/dist/cjs/presentation/shared/systemSettingsDialog.js.map +1 -1
- package/dist/cjs/presentation/whiteboard/peopleMenu.js +1 -1
- package/dist/cjs/presentation/whiteboard/peopleMenu.js.map +1 -1
- package/dist/cjs/presentation/whiteboard/projectElements.js +1 -1
- package/dist/cjs/presentation/whiteboard/projectElements.js.map +1 -1
- package/dist/esm/components/CommandPalette/CommandPalette.d.ts +2 -2
- package/dist/esm/components/CommandPalette/CommandPalette.d.ts.map +1 -1
- package/dist/esm/components/CommandPalette/CommandPalette.js +3 -1
- package/dist/esm/components/CommandPalette/CommandPalette.js.map +1 -1
- package/dist/esm/components/ConfirmDialog/ConfirmDialog.d.ts +5 -2
- package/dist/esm/components/ConfirmDialog/ConfirmDialog.d.ts.map +1 -1
- package/dist/esm/components/ConfirmDialog/ConfirmDialog.js +4 -4
- package/dist/esm/components/ConfirmDialog/ConfirmDialog.js.map +1 -1
- package/dist/esm/components/DatePicker/Styles.d.ts +1 -1
- package/dist/esm/components/DatePicker/Styles.d.ts.map +1 -1
- package/dist/esm/components/Dialog/Dialog.d.ts +22 -4
- package/dist/esm/components/Dialog/Dialog.d.ts.map +1 -1
- package/dist/esm/components/Dialog/Dialog.js +12 -9
- package/dist/esm/components/Dialog/Dialog.js.map +1 -1
- package/dist/esm/components/Dialog/DialogContext.d.ts +2 -2
- package/dist/esm/components/Dialog/DialogContext.d.ts.map +1 -1
- package/dist/esm/components/Dialog/DialogContext.js.map +1 -1
- package/dist/esm/components/Dialog/DialogFrame.d.ts +5 -6
- package/dist/esm/components/Dialog/DialogFrame.d.ts.map +1 -1
- package/dist/esm/components/Dialog/DialogFrame.js +26 -103
- package/dist/esm/components/Dialog/DialogFrame.js.map +1 -1
- package/dist/esm/components/Dialog/usePropWarning.d.ts +13 -0
- package/dist/esm/components/Dialog/usePropWarning.d.ts.map +1 -0
- package/dist/esm/components/Dialog/usePropWarning.js +26 -0
- package/dist/esm/components/Dialog/usePropWarning.js.map +1 -0
- package/dist/esm/components/ModalRoot/ModalRoot.d.ts +10 -0
- package/dist/esm/components/ModalRoot/ModalRoot.d.ts.map +1 -1
- package/dist/esm/components/ModalRoot/ModalRoot.js +32 -8
- package/dist/esm/components/ModalRoot/ModalRoot.js.map +1 -1
- package/dist/esm/components/ModalRoot/modalRootStack.d.ts +8 -2
- package/dist/esm/components/ModalRoot/modalRootStack.d.ts.map +1 -1
- package/dist/esm/components/ModalRoot/modalRootStack.js +18 -4
- package/dist/esm/components/ModalRoot/modalRootStack.js.map +1 -1
- package/dist/esm/components/ObjectFormModal/ObjectFormModal.d.ts +9 -1
- package/dist/esm/components/ObjectFormModal/ObjectFormModal.d.ts.map +1 -1
- package/dist/esm/components/ObjectFormModal/ObjectFormModal.js +13 -12
- package/dist/esm/components/ObjectFormModal/ObjectFormModal.js.map +1 -1
- package/dist/esm/components/SelectDate/Styles.d.ts +1 -1
- package/dist/esm/components/SelectDate/Styles.d.ts.map +1 -1
- package/dist/esm/components/Sheet/Sheet.d.ts +6 -1
- package/dist/esm/components/Sheet/Sheet.d.ts.map +1 -1
- package/dist/esm/components/Sheet/Sheet.js +17 -5
- package/dist/esm/components/Sheet/Sheet.js.map +1 -1
- package/dist/esm/components/Sheet/useHostAboveOpenModal.d.ts.map +1 -1
- package/dist/esm/components/Sheet/useHostAboveOpenModal.js +9 -2
- package/dist/esm/components/Sheet/useHostAboveOpenModal.js.map +1 -1
- package/dist/esm/components/Wizard/Wizard.d.ts +1 -1
- package/dist/esm/components/Wizard/Wizard.d.ts.map +1 -1
- package/dist/esm/components/Wizard/Wizard.js +1 -0
- package/dist/esm/components/Wizard/Wizard.js.map +1 -1
- package/dist/esm/presentation/listView/columns.d.ts +20 -7
- package/dist/esm/presentation/listView/columns.d.ts.map +1 -1
- package/dist/esm/presentation/listView/columns.js +538 -166
- package/dist/esm/presentation/listView/columns.js.map +1 -1
- package/dist/esm/presentation/myWork/MyWorkListSettingsDialog.js +1 -1
- package/dist/esm/presentation/myWork/MyWorkListSettingsDialog.js.map +1 -1
- package/dist/esm/presentation/reports/availabilityExport.js +1 -1
- package/dist/esm/presentation/reports/availabilityExport.js.map +1 -1
- package/dist/esm/presentation/selfHostedRedesign/parts.js +6 -6
- package/dist/esm/presentation/selfHostedRedesign/parts.js.map +1 -1
- package/dist/esm/presentation/shared/LinkingCommandsButton.js +1 -1
- package/dist/esm/presentation/shared/LinkingCommandsButton.js.map +1 -1
- package/dist/esm/presentation/shared/MessageDialog.js +1 -1
- package/dist/esm/presentation/shared/MessageDialog.js.map +1 -1
- package/dist/esm/presentation/shared/MessageFeedback.js +1 -1
- package/dist/esm/presentation/shared/MessageFeedback.js.map +1 -1
- package/dist/esm/presentation/shared/ProjectOptionsMenu.js +1 -1
- package/dist/esm/presentation/shared/ProjectOptionsMenu.js.map +1 -1
- package/dist/esm/presentation/shared/SourceCodeSection.js +2 -2
- package/dist/esm/presentation/shared/SourceCodeSection.js.map +1 -1
- package/dist/esm/presentation/shared/UserDetailsDialog.js +1 -1
- package/dist/esm/presentation/shared/UserDetailsDialog.js.map +1 -1
- package/dist/esm/presentation/shared/WebhookLogsDialog.js +1 -1
- package/dist/esm/presentation/shared/WebhookLogsDialog.js.map +1 -1
- package/dist/esm/presentation/shared/selfHostedSettings.js +1 -1
- package/dist/esm/presentation/shared/selfHostedSettings.js.map +1 -1
- package/dist/esm/presentation/shared/selfHostedUpgrade.js +3 -3
- package/dist/esm/presentation/shared/selfHostedUpgrade.js.map +1 -1
- package/dist/esm/presentation/shared/systemSettingsDialog.d.ts.map +1 -1
- package/dist/esm/presentation/shared/systemSettingsDialog.js +1 -1
- package/dist/esm/presentation/shared/systemSettingsDialog.js.map +1 -1
- package/dist/esm/presentation/whiteboard/peopleMenu.js +1 -1
- package/dist/esm/presentation/whiteboard/peopleMenu.js.map +1 -1
- package/dist/esm/presentation/whiteboard/projectElements.js +1 -1
- package/dist/esm/presentation/whiteboard/projectElements.js.map +1 -1
- package/dist/index.js +368 -364
- 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
|
@@ -4,24 +4,32 @@ const _excluded = ["open", "className", "children"],
|
|
|
4
4
|
_excluded2 = ["value", "tooltip"],
|
|
5
5
|
_excluded3 = ["labels"],
|
|
6
6
|
_excluded4 = ["value", "tooltip", "overdue"];
|
|
7
|
-
import React, { createContext, forwardRef, useCallback, useContext, useMemo, useState } from "react";
|
|
7
|
+
import React, { createContext, forwardRef, useCallback, useContext, useMemo, useRef, useState } from "react";
|
|
8
8
|
import moment from "moment-timezone";
|
|
9
9
|
import styled, { css } from "styled-components";
|
|
10
10
|
import { Button } from "../../components/Button";
|
|
11
|
-
import {
|
|
11
|
+
import { Card } from "../../components/Card";
|
|
12
12
|
import { Chip } from "../../components/Chip";
|
|
13
|
+
import { ConfirmDialog } from "../../components/ConfirmDialog";
|
|
13
14
|
import { DatePicker } from "../../components/DatePicker";
|
|
14
15
|
import { Dot } from "../../components/Dot";
|
|
15
|
-
import {
|
|
16
|
+
import { EditableHours } from "../../components/EditableHours";
|
|
17
|
+
import { EditableText } from "../../components/EditableText";
|
|
18
|
+
import { IconButton } from "../../components/IconButton";
|
|
19
|
+
import { CalendarIcon, ClockAddIcon, CollapseExpandSingleIcon, PersonIcon, TaskIcon, ToolsIcon, TrashIcon } from "../../components/Icons";
|
|
16
20
|
import { InputHours } from "../../components/Input";
|
|
17
|
-
import {
|
|
21
|
+
import { Menu } from "../../components/Menu";
|
|
18
22
|
import { ObjectFormModal } from "../../components/ObjectFormModal";
|
|
19
23
|
import { ProgressPie } from "../../components/ProgressPie";
|
|
24
|
+
import { PropertyList, PropertyListRow, PropertyListValue } from "../../components/PropertyList";
|
|
20
25
|
import { Select } from "../../components/Select";
|
|
21
|
-
import { SelectTrigger } from "../../components/SelectTrigger";
|
|
22
26
|
import { Textarea } from "../../components/Textarea";
|
|
23
|
-
import {
|
|
27
|
+
import { Toggle } from "../../components/Toggle";
|
|
28
|
+
import { Tooltip } from "../../components/Tooltip";
|
|
29
|
+
import { Body2, Caption1, Caption2 } from "../../components/Typography";
|
|
30
|
+
import { Typography } from "../../components/Typography/Typography";
|
|
24
31
|
import { formatHours } from "../../utils";
|
|
32
|
+
import { RoundAvatar } from "../shared/RoundAvatar";
|
|
25
33
|
|
|
26
34
|
/**
|
|
27
35
|
* Interactive list-view column cells for the `Presentation/List view` and
|
|
@@ -652,6 +660,16 @@ const TimeTrigger = _ref1 => {
|
|
|
652
660
|
estimated: estimated
|
|
653
661
|
}) : /*#__PURE__*/React.createElement(ClockAddIcon, null));
|
|
654
662
|
};
|
|
663
|
+
|
|
664
|
+
/** 0 Not billable, 1 Billable, 2 Pending payment, 3 Paid (utils/tracking.jsx) */
|
|
665
|
+
|
|
666
|
+
/** mirrors: TimeRecordTrackedItemModalFormContainer timeRecords (timeRecordShape
|
|
667
|
+
in Timesheet/shapes), without the parent fields. userId is the mock user's
|
|
668
|
+
slug, as everywhere in these stories. */
|
|
669
|
+
|
|
670
|
+
/** mirrors: the assignable users the form gets (id, name); the initials
|
|
671
|
+
and colour stand in for the avatar image, as in the stories' people */
|
|
672
|
+
|
|
655
673
|
export const TimeCell = _ref10 => {
|
|
656
674
|
let taskName = _ref10.taskName,
|
|
657
675
|
_ref10$tracked = _ref10.tracked,
|
|
@@ -669,23 +687,31 @@ export const TimeCell = _ref10 => {
|
|
|
669
687
|
var _users$find$name, _users$find;
|
|
670
688
|
return tracked > 0 ? [{
|
|
671
689
|
id: 1,
|
|
672
|
-
|
|
690
|
+
value: tracked,
|
|
691
|
+
recordDate: dayOffset(-3),
|
|
673
692
|
userId: currentUserId,
|
|
674
693
|
userName: (_users$find$name = (_users$find = users.find(user => user.id === currentUserId)) == null ? void 0 : _users$find.name) != null ? _users$find$name : "You",
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
694
|
+
jobTypeId: 1,
|
|
695
|
+
summary: "",
|
|
696
|
+
billableStatus: 1,
|
|
697
|
+
createdOn: dayOffset(-3)
|
|
678
698
|
}] : [];
|
|
679
699
|
}),
|
|
680
700
|
records = _useState6[0],
|
|
681
701
|
setRecords = _useState6[1];
|
|
682
|
-
const total = useMemo(() => records.reduce((sum, record) => sum + record.
|
|
702
|
+
const total = useMemo(() => records.reduce((sum, record) => sum + record.value, 0), [records]);
|
|
683
703
|
const handleAdd = useCallback(record => {
|
|
684
704
|
setRecords(prev => [_extends({}, record, {
|
|
685
|
-
id: prev.
|
|
705
|
+
id: Math.max(0, ...prev.map(item => item.id)) + 1
|
|
686
706
|
}), ...prev]);
|
|
687
707
|
setOpen(false);
|
|
688
708
|
}, []);
|
|
709
|
+
const handleUpdate = useCallback((id, patch) => {
|
|
710
|
+
setRecords(prev => prev.map(record => record.id === id ? _extends({}, record, patch) : record));
|
|
711
|
+
}, []);
|
|
712
|
+
const handleTrash = useCallback(id => {
|
|
713
|
+
setRecords(prev => prev.filter(record => record.id !== id));
|
|
714
|
+
}, []);
|
|
689
715
|
|
|
690
716
|
/* Completed tasks show the value without the "add" affordance (mirrors
|
|
691
717
|
Time.js passing hideIcon for completed tasks) */
|
|
@@ -709,8 +735,9 @@ export const TimeCell = _ref10 => {
|
|
|
709
735
|
users: users,
|
|
710
736
|
currentUserId: currentUserId,
|
|
711
737
|
records: records,
|
|
712
|
-
total: total,
|
|
713
738
|
onSubmit: handleAdd,
|
|
739
|
+
onUpdate: handleUpdate,
|
|
740
|
+
onTrash: handleTrash,
|
|
714
741
|
onClose: () => setOpen(false)
|
|
715
742
|
}) : null);
|
|
716
743
|
};
|
|
@@ -719,205 +746,550 @@ export const TimeCell = _ref10 => {
|
|
|
719
746
|
/* Add Time Record dialog (mirrors TimeRecordForm/*) */
|
|
720
747
|
/* ------------------------------------------------------------------ */
|
|
721
748
|
|
|
749
|
+
/** mirrors: state.job_types (id, name) */
|
|
750
|
+
|
|
722
751
|
const JOB_TYPES = [{
|
|
723
|
-
id:
|
|
752
|
+
id: 1,
|
|
724
753
|
name: "Design"
|
|
725
754
|
}, {
|
|
726
|
-
id:
|
|
755
|
+
id: 2,
|
|
727
756
|
name: "Development"
|
|
728
757
|
}, {
|
|
729
|
-
id:
|
|
758
|
+
id: 3,
|
|
730
759
|
name: "Devops"
|
|
731
760
|
}, {
|
|
732
|
-
id:
|
|
761
|
+
id: 4,
|
|
733
762
|
name: "Consulting"
|
|
734
763
|
}, {
|
|
735
|
-
id:
|
|
764
|
+
id: 5,
|
|
736
765
|
name: "QA"
|
|
737
766
|
}];
|
|
738
767
|
|
|
739
|
-
/*
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
768
|
+
/* the user's default job type in the mock (Devops) */
|
|
769
|
+
const DEFAULT_JOB_TYPE_ID = 3;
|
|
770
|
+
|
|
771
|
+
/* The content of the app's list view time record form
|
|
772
|
+
(TimeRecordTrackedItemModalFormContainer → AddTimeRecordForm). The shell is a
|
|
773
|
+
DS ObjectFormModal, as in the app's TimeRecordModalContainer (size xl,
|
|
774
|
+
fill). On top a grid: the time and the description in one card on the left,
|
|
775
|
+
the property cards (SidebarCard = DS PropertyList) in a 299px column on the
|
|
776
|
+
right; the buttons under it. The body does not scroll: the modal surface
|
|
777
|
+
does, and the records card scrolls its own list. */
|
|
743
778
|
const StyledTimeRecordBody = styled.div.withConfig({
|
|
744
779
|
displayName: "columns__StyledTimeRecordBody",
|
|
745
780
|
componentId: "sc-9f4385-8"
|
|
746
|
-
})(["
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
const
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
const
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
781
|
+
})(["display:flex;flex-direction:column;gap:16px;min-height:0;.trd-form{display:flex;flex-direction:column;gap:16px;flex-shrink:0;width:100%;margin:0;}.trd-grid{display:grid;grid-template-columns:minmax(0,1fr) 299px;gap:16px;}.trd-text{display:flex;flex-direction:column;min-width:0;border:1px solid var(--border-raised);border-radius:24px;overflow:clip;background:var(--surface-raised);}.trd-time{display:flex;align-items:center;gap:8px;box-sizing:border-box;min-height:42px;padding:0 16px;border-bottom:1px solid var(--border-raised);}.trd-time .c-input-wrapper{width:100%;padding:0;border:0;background:transparent;box-shadow:none;opacity:1;}.trd-time input{background:transparent;}.trd-summary{flex:1;box-sizing:border-box;width:100%;min-height:156px;padding:12px 20px;border:0;border-radius:0;background:transparent;box-shadow:none;resize:none;white-space:pre-wrap;overflow-wrap:break-word;font-size:calc(12px * var(--text-scale));}.trd-time:focus-within,.trd-summary:focus{background:color-mix(in srgb,var(--color-theme-200) 40%,transparent);}.trd-properties{display:flex;flex-direction:column;gap:16px;align-self:start;min-width:0;}.trd-parent-name{display:block;max-width:160px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;}.trd-toggles{display:flex;flex-wrap:wrap;align-items:center;gap:8px 16px;box-sizing:border-box;min-height:40px;padding:6px 12px;}.trd-toggle{display:flex;align-items:center;gap:8px;cursor:pointer;}.trd-toggle .trd-toggle-label{color:var(--color-theme-700);}.trd-actions{display:flex;align-items:center;gap:12px;}"]);
|
|
782
|
+
|
|
783
|
+
/* SidebarPopover: raised like the cards it opens from */
|
|
784
|
+
const StyledRowMenu = styled(Menu).withConfig({
|
|
785
|
+
displayName: "columns__StyledRowMenu",
|
|
786
|
+
componentId: "sc-9f4385-9"
|
|
787
|
+
})(["background:var(--surface-raised);"]);
|
|
788
|
+
|
|
789
|
+
/* SidebarSelectRow: a property row that opens its options in a menu as wide
|
|
790
|
+
as the row */
|
|
791
|
+
const TimeRecordSelectRow = _ref11 => {
|
|
792
|
+
var _options$find;
|
|
793
|
+
let icon = _ref11.icon,
|
|
794
|
+
label = _ref11.label,
|
|
795
|
+
placeholder = _ref11.placeholder,
|
|
796
|
+
options = _ref11.options,
|
|
797
|
+
selected = _ref11.selected,
|
|
798
|
+
onChange = _ref11.onChange,
|
|
799
|
+
testId = _ref11.testId;
|
|
800
|
+
const _useState7 = useState(false),
|
|
801
|
+
open = _useState7[0],
|
|
802
|
+
setOpen = _useState7[1];
|
|
803
|
+
const name = (_options$find = options.find(option => option.id === selected)) == null ? void 0 : _options$find.name;
|
|
804
|
+
return /*#__PURE__*/React.createElement(StyledRowMenu, {
|
|
805
|
+
open: open,
|
|
806
|
+
onOpen: () => setOpen(true),
|
|
807
|
+
onClose: () => setOpen(false),
|
|
808
|
+
position: "bottom-start",
|
|
809
|
+
width: "target",
|
|
810
|
+
target: /*#__PURE__*/React.createElement(PropertyListRow, {
|
|
811
|
+
icon: icon,
|
|
812
|
+
label: label,
|
|
813
|
+
value: /*#__PURE__*/React.createElement(PropertyListValue, {
|
|
814
|
+
placeholder: !name
|
|
815
|
+
}, name != null ? name : placeholder),
|
|
816
|
+
"data-testid": testId
|
|
817
|
+
})
|
|
818
|
+
}, open ? /*#__PURE__*/React.createElement(Select, {
|
|
819
|
+
options: options,
|
|
820
|
+
selected: selected,
|
|
821
|
+
focusInput: true,
|
|
822
|
+
onChange: id => {
|
|
823
|
+
setOpen(false);
|
|
824
|
+
/* the option's own id, as SidebarSelectRow hands back */
|
|
825
|
+
const option = options.find(item => "" + item.id === "" + id);
|
|
826
|
+
if (option) {
|
|
827
|
+
onChange(option.id);
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
}) : null);
|
|
831
|
+
};
|
|
832
|
+
|
|
833
|
+
/** utils/tracking.jsx editableBillableStatusOptions */
|
|
834
|
+
const BILLABLE_STATUS_OPTIONS = [{
|
|
835
|
+
id: 0,
|
|
836
|
+
name: "Not billable"
|
|
837
|
+
}, {
|
|
838
|
+
id: 1,
|
|
839
|
+
name: "Billable"
|
|
840
|
+
}, {
|
|
841
|
+
id: 2,
|
|
842
|
+
name: "Pending payment"
|
|
843
|
+
}, {
|
|
844
|
+
id: 3,
|
|
845
|
+
name: "Paid"
|
|
846
|
+
}];
|
|
847
|
+
|
|
848
|
+
/** The UTC day a record date falls on, as a timestamp */
|
|
849
|
+
const recordDay = date => moment.unix(date).utc().startOf("day").unix();
|
|
850
|
+
|
|
851
|
+
/** FormatSmartAbsoluteDate: "Today", "Yesterday", else the date, with the
|
|
852
|
+
year only when it is not this year (formatDateSmart) */
|
|
853
|
+
const formatGroupDate = date => {
|
|
854
|
+
var _formatDateRange;
|
|
855
|
+
const day = moment.unix(date).utc().startOf("day");
|
|
856
|
+
const today = moment.utc().startOf("day");
|
|
857
|
+
if (day.isSame(today)) {
|
|
858
|
+
return "Today";
|
|
859
|
+
}
|
|
860
|
+
if (day.isSame(today.clone().subtract(1, "day"))) {
|
|
861
|
+
return "Yesterday";
|
|
862
|
+
}
|
|
863
|
+
if (!day.isSame(today, "year")) {
|
|
864
|
+
return day.format(DATE_FORMAT);
|
|
865
|
+
}
|
|
866
|
+
return (_formatDateRange = formatDateRange(date, date)) != null ? _formatDateRange : "";
|
|
867
|
+
};
|
|
868
|
+
|
|
869
|
+
/* TimeRecordExistingSection: a raised card under the form with the total as
|
|
870
|
+
a quiet line that opens the records, grouped by date like
|
|
871
|
+
TimeRecordListGroupedByDate (lines) */
|
|
872
|
+
const StyledExistingRecords = styled(Card).withConfig({
|
|
873
|
+
displayName: "columns__StyledExistingRecords",
|
|
874
|
+
componentId: "sc-9f4385-10"
|
|
875
|
+
})(["min-width:0;min-height:0;padding:0 16px;overflow-x:hidden;overflow-y:auto;.trd-total{display:flex;align-items:center;box-sizing:border-box;min-height:40px;margin:0 -16px;padding:0 16px;color:var(--color-theme-600);cursor:pointer;}.trd-total:hover{background:var(--color-theme-200);}.trd-total .c-typography{color:inherit;}.trd-total .trd-total-yours{margin-right:8px;}.trd-total svg{margin-left:auto;fill:currentColor;transition:transform 200ms;}.trd-total[aria-expanded=\"false\"] svg{transform:rotate(180deg);}.trd-groups{padding:8px 0 16px;}@media (max-width:639px){.trd-groups{display:none;}}.trd-group{margin-bottom:24px;}.trd-group:last-child{margin-bottom:0;}.trd-group-header{display:flex;justify-content:space-between;margin:0 0 8px 4px;padding:0 4px;}.trd-group-total{cursor:help;}.trd-record{display:flex;align-items:center;box-sizing:border-box;height:40px;padding:0 8px;border-bottom:1px solid var(--border-raised);}.trd-record:first-child{border-top:1px solid var(--border-raised);}.trd-record:last-child{border-bottom:0;}.trd-record > *{display:flex;flex-shrink:0;margin-right:8px;}.trd-record-value{width:64px;}.trd-record-job-type{width:120px;}.trd-record-user,.trd-record-source{width:32px;justify-content:center;}.trd-record-summary{display:none;flex:1 1 0%;flex-shrink:1;min-width:132px;max-width:320px;}@media (min-width:768px){.trd-record-summary{display:flex;}}.trd-record-billable{width:140px;}.trd-record-actions{gap:8px;margin:0 0 0 auto;}.trd-record-summary > *{width:100%;}", " .trd-job-type-picker{max-width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;}"], CooltipStyle);
|
|
876
|
+
|
|
877
|
+
/** "1:30" / "1:3" / "1.5" / "1,5" → decimal hours, read like the app's
|
|
878
|
+
timeStringToFloat: a comma is a decimal point and one minute digit is
|
|
879
|
+
tens of minutes */
|
|
880
|
+
const hoursFromInput = input => {
|
|
881
|
+
const trimmed = input.trim().replace(",", ".");
|
|
882
|
+
if (!trimmed) {
|
|
883
|
+
return 0;
|
|
884
|
+
}
|
|
885
|
+
if (trimmed.includes(":")) {
|
|
886
|
+
const _trimmed$split = trimmed.split(/[.:]/),
|
|
887
|
+
h = _trimmed$split[0],
|
|
888
|
+
_trimmed$split$ = _trimmed$split[1],
|
|
889
|
+
m = _trimmed$split$ === void 0 ? "" : _trimmed$split$;
|
|
890
|
+
const minutes = m.length === 1 ? m + "0" : m;
|
|
891
|
+
const hours = (parseInt(h, 10) || 0) + (parseInt(minutes, 10) || 0) / 60;
|
|
892
|
+
return Number(hours.toFixed(2));
|
|
893
|
+
}
|
|
894
|
+
return Number(trimmed) || 0;
|
|
895
|
+
};
|
|
782
896
|
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
897
|
+
/* TimeRecordFormListItem for the record's owner: the time, the job type, the
|
|
898
|
+
summary and the billable status edit in place, and the date and the trash
|
|
899
|
+
sit at the end of the line */
|
|
900
|
+
const TimeRecordLine = _ref12 => {
|
|
901
|
+
var _JOB_TYPES$find, _person$bg, _person$initials, _BILLABLE_STATUS_OPTI;
|
|
902
|
+
let record = _ref12.record,
|
|
903
|
+
person = _ref12.person,
|
|
904
|
+
onUpdate = _ref12.onUpdate,
|
|
905
|
+
onTrash = _ref12.onTrash;
|
|
906
|
+
/* "move" after the time is cleared (TimeValue), "delete" from the trash */
|
|
907
|
+
const _useState8 = useState(null),
|
|
908
|
+
confirm = _useState8[0],
|
|
909
|
+
setConfirm = _useState8[1];
|
|
910
|
+
/* remounts the hours to show the record's time again after a cancel */
|
|
911
|
+
const _useState9 = useState(0),
|
|
912
|
+
hoursKey = _useState9[0],
|
|
913
|
+
setHoursKey = _useState9[1];
|
|
914
|
+
/* the picker whose menu is open keeps its button pressed (OptionPicker,
|
|
915
|
+
BillableStatusPicker, SelectTrackingRecordDate) */
|
|
916
|
+
const _useState0 = useState(null),
|
|
917
|
+
openPicker = _useState0[0],
|
|
918
|
+
setOpenPicker = _useState0[1];
|
|
919
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
920
|
+
className: "trd-record",
|
|
921
|
+
"data-testid": "time-record-row"
|
|
922
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
923
|
+
className: "trd-record-value"
|
|
924
|
+
}, /*#__PURE__*/React.createElement(EditableHours, {
|
|
925
|
+
key: hoursKey,
|
|
926
|
+
value: record.value,
|
|
927
|
+
withLeadingZero: false,
|
|
928
|
+
allowEmptyValue: true,
|
|
929
|
+
onSave: event => {
|
|
930
|
+
const value = hoursFromInput(event.target.value);
|
|
931
|
+
if (value > 0) {
|
|
932
|
+
onUpdate(record.id, {
|
|
933
|
+
value
|
|
934
|
+
});
|
|
935
|
+
} else {
|
|
936
|
+
setConfirm("move");
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
940
|
+
className: "trd-record-job-type"
|
|
941
|
+
}, /*#__PURE__*/React.createElement(Select, {
|
|
942
|
+
options: JOB_TYPES,
|
|
943
|
+
selected: record.jobTypeId,
|
|
944
|
+
noResultText: "No result",
|
|
945
|
+
forceCloseMenu: true,
|
|
946
|
+
onSelectOpen: () => setOpenPicker("job-type"),
|
|
947
|
+
onSelectClose: () => setOpenPicker(null),
|
|
948
|
+
onChange: id => onUpdate(record.id, {
|
|
949
|
+
jobTypeId: Number(id)
|
|
950
|
+
}),
|
|
951
|
+
target: /*#__PURE__*/React.createElement(Button, {
|
|
952
|
+
variant: "text gray",
|
|
953
|
+
className: "trd-job-type-picker",
|
|
954
|
+
active: openPicker === "job-type"
|
|
955
|
+
}, (_JOB_TYPES$find = JOB_TYPES.find(item => item.id === record.jobTypeId)) == null ? void 0 : _JOB_TYPES$find.name)
|
|
956
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
957
|
+
className: "trd-record-user"
|
|
958
|
+
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
959
|
+
title: record.userName
|
|
960
|
+
}, /*#__PURE__*/React.createElement(RoundAvatar, {
|
|
961
|
+
$bg: (_person$bg = person == null ? void 0 : person.bg) != null ? _person$bg : "#AEB4BE",
|
|
962
|
+
$size: 24,
|
|
963
|
+
$bordered: false
|
|
964
|
+
}, (_person$initials = person == null ? void 0 : person.initials) != null ? _person$initials : record.userName.charAt(0)))), /*#__PURE__*/React.createElement("span", {
|
|
965
|
+
className: "trd-record-source"
|
|
966
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
967
|
+
className: "trd-record-summary"
|
|
968
|
+
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
969
|
+
title: record.summary,
|
|
970
|
+
disable: record.summary.length < 40
|
|
971
|
+
}, /*#__PURE__*/React.createElement(EditableText, {
|
|
972
|
+
value: record.summary,
|
|
973
|
+
allowEmptyString: true,
|
|
974
|
+
multiline: true,
|
|
975
|
+
submitOnMetaEnter: true,
|
|
976
|
+
onSave: event => onUpdate(record.id, {
|
|
977
|
+
summary: event.target.value
|
|
978
|
+
})
|
|
979
|
+
}))), /*#__PURE__*/React.createElement("span", {
|
|
980
|
+
className: "trd-record-billable"
|
|
981
|
+
}, /*#__PURE__*/React.createElement(Select, {
|
|
982
|
+
options: BILLABLE_STATUS_OPTIONS,
|
|
983
|
+
selected: record.billableStatus,
|
|
984
|
+
disableSearch: true,
|
|
985
|
+
forceCloseMenu: true,
|
|
986
|
+
disabledInternalSort: true,
|
|
987
|
+
keepSameOptionsOrder: true,
|
|
988
|
+
onSelectOpen: () => setOpenPicker("billable"),
|
|
989
|
+
onSelectClose: () => setOpenPicker(null),
|
|
990
|
+
onChange: id => onUpdate(record.id, {
|
|
991
|
+
billableStatus: Number(id)
|
|
992
|
+
}),
|
|
993
|
+
target: /*#__PURE__*/React.createElement(Button, {
|
|
994
|
+
variant: "text gray",
|
|
995
|
+
active: openPicker === "billable"
|
|
996
|
+
}, (_BILLABLE_STATUS_OPTI = BILLABLE_STATUS_OPTIONS.find(item => item.id === record.billableStatus)) == null ? void 0 : _BILLABLE_STATUS_OPTI.name)
|
|
997
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
998
|
+
className: "trd-record-actions"
|
|
999
|
+
}, /*#__PURE__*/React.createElement(DatePicker, {
|
|
1000
|
+
mode: "daily",
|
|
1001
|
+
required: true,
|
|
1002
|
+
firstDayOfWeek: 1,
|
|
1003
|
+
position: "bottom-end",
|
|
1004
|
+
selected: {
|
|
1005
|
+
from: record.recordDate,
|
|
1006
|
+
to: record.recordDate
|
|
1007
|
+
},
|
|
1008
|
+
onCalendarToggle: isOpen => setOpenPicker(isOpen ? "date" : null),
|
|
1009
|
+
onSave: range => range != null && range.from ? onUpdate(record.id, {
|
|
1010
|
+
recordDate: Number(range.from)
|
|
1011
|
+
}) : undefined,
|
|
1012
|
+
target: /*#__PURE__*/React.createElement(IconButton, {
|
|
1013
|
+
variant: "text gray",
|
|
1014
|
+
active: openPicker === "date",
|
|
1015
|
+
"aria-label": "Change Date",
|
|
1016
|
+
"data-tooltip": "Change Date"
|
|
1017
|
+
}, /*#__PURE__*/React.createElement(CalendarIcon, null))
|
|
1018
|
+
}), /*#__PURE__*/React.createElement(Tooltip, {
|
|
1019
|
+
title: "Move to Trash"
|
|
1020
|
+
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
1021
|
+
variant: "text gray",
|
|
1022
|
+
"aria-label": "Move to Trash",
|
|
1023
|
+
onClick: () => setConfirm("delete")
|
|
1024
|
+
}, /*#__PURE__*/React.createElement(TrashIcon, null))), /*#__PURE__*/React.createElement(ConfirmDialog, {
|
|
1025
|
+
open: confirm === "delete",
|
|
1026
|
+
dialogTitle: "Delete time record?",
|
|
1027
|
+
dialogContent: "The time record will remain in Trash for 30 days.",
|
|
1028
|
+
confirmBtnText: "Delete",
|
|
1029
|
+
cancelBtnText: "Cancel",
|
|
1030
|
+
onConfirm: () => {
|
|
1031
|
+
setConfirm(null);
|
|
1032
|
+
onTrash(record.id);
|
|
1033
|
+
},
|
|
1034
|
+
onCancel: () => setConfirm(null)
|
|
1035
|
+
})), /*#__PURE__*/React.createElement(ConfirmDialog, {
|
|
1036
|
+
open: confirm === "move",
|
|
1037
|
+
dialogTitle: "Move to trash",
|
|
1038
|
+
dialogContent: "Move time record to trash?",
|
|
1039
|
+
confirmBtnText: "Move",
|
|
1040
|
+
onConfirm: () => {
|
|
1041
|
+
setConfirm(null);
|
|
1042
|
+
onTrash(record.id);
|
|
1043
|
+
},
|
|
1044
|
+
onCancel: () => {
|
|
1045
|
+
setConfirm(null);
|
|
1046
|
+
setHoursKey(prev => prev + 1);
|
|
788
1047
|
}
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
1048
|
+
}));
|
|
1049
|
+
};
|
|
1050
|
+
const TimeRecordExistingSection = _ref13 => {
|
|
1051
|
+
let records = _ref13.records,
|
|
1052
|
+
users = _ref13.users,
|
|
1053
|
+
currentUserId = _ref13.currentUserId,
|
|
1054
|
+
onUpdate = _ref13.onUpdate,
|
|
1055
|
+
onTrash = _ref13.onTrash;
|
|
1056
|
+
const _useState1 = useState(false),
|
|
1057
|
+
open = _useState1[0],
|
|
1058
|
+
setOpen = _useState1[1];
|
|
1059
|
+
|
|
1060
|
+
/* the app reads your_time / other_time from /time-records/task/{id}/info;
|
|
1061
|
+
the mock has only the records, so it adds them up */
|
|
1062
|
+
const yourTime = records.filter(record => record.userId === currentUserId).reduce((sum, record) => sum + record.value, 0);
|
|
1063
|
+
const otherTime = records.filter(record => record.userId !== currentUserId).reduce((sum, record) => sum + record.value, 0);
|
|
1064
|
+
if (yourTime <= 0 && otherTime <= 0) {
|
|
1065
|
+
return null;
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
/* grouped by the day, like the app's startOf("day") */
|
|
1069
|
+
const dates = Array.from(new Set(records.map(record => recordDay(record.recordDate)))).sort((a, b) => b - a);
|
|
1070
|
+
const toggle = () => setOpen(prev => !prev);
|
|
1071
|
+
return (
|
|
1072
|
+
/*#__PURE__*/
|
|
1073
|
+
/* flat: the app's ObjectFormModal takes the shadow off every c-card in it
|
|
1074
|
+
(FLAT_CARDS), since the modal has its own */
|
|
1075
|
+
React.createElement(StyledExistingRecords, {
|
|
1076
|
+
variant: "raised",
|
|
1077
|
+
radius: 24,
|
|
1078
|
+
shadow: false
|
|
1079
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1080
|
+
className: "trd-total",
|
|
1081
|
+
role: "button",
|
|
1082
|
+
tabIndex: 0,
|
|
1083
|
+
"aria-expanded": open,
|
|
1084
|
+
onClick: toggle,
|
|
1085
|
+
onKeyDown: event => {
|
|
1086
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
1087
|
+
event.preventDefault();
|
|
1088
|
+
toggle();
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
}, otherTime > 0 ? /*#__PURE__*/React.createElement(React.Fragment, null, yourTime > 0 ? /*#__PURE__*/React.createElement(Caption1, {
|
|
1092
|
+
className: "trd-total-yours",
|
|
1093
|
+
tabularNums: true
|
|
1094
|
+
}, "You: ", formatHours(yourTime, false, true), "h,") : null, /*#__PURE__*/React.createElement(Caption1, {
|
|
1095
|
+
tabularNums: true
|
|
1096
|
+
}, "Others: ", formatHours(otherTime, false, true), "h")) : /*#__PURE__*/React.createElement(Caption1, {
|
|
1097
|
+
tabularNums: true
|
|
1098
|
+
}, "Total: ", formatHours(yourTime, false, true), "h"), /*#__PURE__*/React.createElement(CollapseExpandSingleIcon, null)), open ? /*#__PURE__*/React.createElement("div", {
|
|
1099
|
+
className: "trd-groups"
|
|
1100
|
+
}, dates.map(date => {
|
|
1101
|
+
const group = records.filter(record => recordDay(record.recordDate) === date).sort((a, b) => b.createdOn - a.createdOn);
|
|
1102
|
+
const groupTotal = group.reduce((sum, record) => sum + record.value, 0);
|
|
1103
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1104
|
+
key: date,
|
|
1105
|
+
className: "trd-group",
|
|
1106
|
+
"data-testid": "time-record-group"
|
|
1107
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1108
|
+
className: "trd-group-header"
|
|
1109
|
+
}, /*#__PURE__*/React.createElement(Caption1, {
|
|
1110
|
+
weight: "bold"
|
|
1111
|
+
}, formatGroupDate(date)), /*#__PURE__*/React.createElement(Tooltip, {
|
|
1112
|
+
title: /*#__PURE__*/React.createElement("div", null, BILLABLE_STATUS_OPTIONS.map(status => {
|
|
1113
|
+
const statusTotal = group.filter(record => record.billableStatus === status.id).reduce((sum, record) => sum + record.value, 0);
|
|
1114
|
+
return statusTotal > 0 ? /*#__PURE__*/React.createElement(Caption1, {
|
|
1115
|
+
key: status.id,
|
|
1116
|
+
color: "only-white"
|
|
1117
|
+
}, status.name, ":", " ", formatHours(statusTotal, false, true), "h") : null;
|
|
1118
|
+
}))
|
|
1119
|
+
}, /*#__PURE__*/React.createElement(Typography, {
|
|
1120
|
+
className: "trd-group-total",
|
|
1121
|
+
variant: "Caption 1",
|
|
1122
|
+
color: "secondary",
|
|
1123
|
+
weight: "medium",
|
|
1124
|
+
tabularNums: true
|
|
1125
|
+
}, "Total: ", formatHours(groupTotal, false, true), "h"))), /*#__PURE__*/React.createElement("div", null, group.map(record => /*#__PURE__*/React.createElement(TimeRecordLine, {
|
|
1126
|
+
key: record.id,
|
|
1127
|
+
record: record,
|
|
1128
|
+
person: users.find(item => item.id === record.userId),
|
|
1129
|
+
onUpdate: onUpdate,
|
|
1130
|
+
onTrash: onTrash
|
|
1131
|
+
}))));
|
|
1132
|
+
})) : null)
|
|
1133
|
+
);
|
|
1134
|
+
};
|
|
1135
|
+
export const TimeRecordDialog = _ref14 => {
|
|
1136
|
+
let open = _ref14.open,
|
|
1137
|
+
taskName = _ref14.taskName,
|
|
1138
|
+
users = _ref14.users,
|
|
1139
|
+
currentUserId = _ref14.currentUserId,
|
|
1140
|
+
records = _ref14.records,
|
|
1141
|
+
onSubmit = _ref14.onSubmit,
|
|
1142
|
+
onUpdate = _ref14.onUpdate,
|
|
1143
|
+
onTrash = _ref14.onTrash,
|
|
1144
|
+
onClose = _ref14.onClose;
|
|
1145
|
+
const _useState10 = useState(""),
|
|
1146
|
+
value = _useState10[0],
|
|
1147
|
+
setValue = _useState10[1];
|
|
1148
|
+
const _useState11 = useState(todayUnix),
|
|
1149
|
+
initialDate = _useState11[0];
|
|
1150
|
+
const _useState12 = useState(initialDate),
|
|
1151
|
+
date = _useState12[0],
|
|
1152
|
+
setDate = _useState12[1];
|
|
1153
|
+
const _useState13 = useState(currentUserId),
|
|
1154
|
+
userId = _useState13[0],
|
|
1155
|
+
setUserId = _useState13[1];
|
|
1156
|
+
const _useState14 = useState(DEFAULT_JOB_TYPE_ID),
|
|
1157
|
+
jobTypeId = _useState14[0],
|
|
1158
|
+
setJobTypeId = _useState14[1];
|
|
1159
|
+
/* the app starts from task.is_billable; the mock tasks have no such field */
|
|
1160
|
+
const _useState15 = useState(false),
|
|
1161
|
+
billable = _useState15[0],
|
|
1162
|
+
setBillable = _useState15[1];
|
|
1163
|
+
const _useState16 = useState(""),
|
|
1164
|
+
description = _useState16[0],
|
|
1165
|
+
setDescription = _useState16[1];
|
|
1166
|
+
const user = users.find(item => item.id === userId);
|
|
1167
|
+
const hours = useMemo(() => hoursFromInput(value), [value]);
|
|
1168
|
+
const timeRef = useRef(null);
|
|
1169
|
+
/* the app marks the time once the form is dirty (formik.dirty && the time
|
|
1170
|
+
error): any field changed from where the form started */
|
|
1171
|
+
const dirty = value !== "" || description !== "" || date !== initialDate || userId !== currentUserId || jobTypeId !== DEFAULT_JOB_TYPE_ID || billable;
|
|
1172
|
+
const invalidTime = dirty && hours <= 0;
|
|
1173
|
+
const handleSubmit = useCallback(event => {
|
|
1174
|
+
var _user$name;
|
|
1175
|
+
event.preventDefault();
|
|
1176
|
+
if (hours <= 0) {
|
|
1177
|
+
var _timeRef$current;
|
|
1178
|
+
(_timeRef$current = timeRef.current) == null || _timeRef$current.focus();
|
|
1179
|
+
return;
|
|
794
1180
|
}
|
|
795
|
-
return Number(trimmed) || 0;
|
|
796
|
-
}, [value]);
|
|
797
|
-
const handleSubmit = useCallback(() => {
|
|
798
|
-
var _user$name, _jobType$name;
|
|
799
1181
|
onSubmit({
|
|
800
|
-
|
|
1182
|
+
value: hours,
|
|
1183
|
+
recordDate: date,
|
|
801
1184
|
userId,
|
|
802
1185
|
userName: (_user$name = user == null ? void 0 : user.name) != null ? _user$name : "",
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
billable,
|
|
806
|
-
|
|
1186
|
+
jobTypeId,
|
|
1187
|
+
summary: description,
|
|
1188
|
+
billableStatus: billable ? 1 : 0,
|
|
1189
|
+
createdOn: moment().unix()
|
|
807
1190
|
});
|
|
808
|
-
}, [billable, date, description, hours,
|
|
1191
|
+
}, [billable, date, description, hours, jobTypeId, onSubmit, user, userId]);
|
|
809
1192
|
return /*#__PURE__*/React.createElement(ObjectFormModal, {
|
|
810
1193
|
open: open,
|
|
811
1194
|
onClose: onClose,
|
|
812
1195
|
label: "Add Time Record",
|
|
813
1196
|
size: "xl",
|
|
814
1197
|
fill: true
|
|
815
|
-
}, /*#__PURE__*/React.createElement(StyledTimeRecordBody, null, /*#__PURE__*/React.createElement("
|
|
816
|
-
className: "trd-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
1198
|
+
}, /*#__PURE__*/React.createElement(StyledTimeRecordBody, null, /*#__PURE__*/React.createElement("form", {
|
|
1199
|
+
className: "trd-form",
|
|
1200
|
+
onSubmit: handleSubmit
|
|
1201
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1202
|
+
className: "trd-grid"
|
|
1203
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1204
|
+
className: "trd-text"
|
|
1205
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1206
|
+
className: "trd-time"
|
|
1207
|
+
}, /*#__PURE__*/React.createElement(InputHours, {
|
|
1208
|
+
ref: timeRef,
|
|
1209
|
+
autoFocus: true,
|
|
1210
|
+
allowEmptyValue: true,
|
|
1211
|
+
size: "big",
|
|
1212
|
+
align: "left",
|
|
1213
|
+
"aria-label": "Time",
|
|
1214
|
+
invalid: invalidTime,
|
|
1215
|
+
value: value,
|
|
1216
|
+
onChange: setValue
|
|
1217
|
+
})), /*#__PURE__*/React.createElement(Textarea, {
|
|
1218
|
+
className: "trd-summary",
|
|
1219
|
+
name: "summary",
|
|
1220
|
+
placeholder: "Add a description",
|
|
1221
|
+
"aria-label": "Description",
|
|
1222
|
+
value: description,
|
|
1223
|
+
onChange: event => setDescription(event.target.value)
|
|
1224
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
1225
|
+
className: "trd-properties"
|
|
1226
|
+
}, /*#__PURE__*/React.createElement(PropertyList, null, /*#__PURE__*/React.createElement(PropertyListRow, {
|
|
1227
|
+
icon: /*#__PURE__*/React.createElement(TaskIcon, null),
|
|
1228
|
+
label: "Task",
|
|
1229
|
+
readOnly: true,
|
|
1230
|
+
value: /*#__PURE__*/React.createElement(PropertyListValue, null, /*#__PURE__*/React.createElement("span", {
|
|
1231
|
+
className: "trd-parent-name"
|
|
1232
|
+
}, taskName)),
|
|
1233
|
+
"data-testid": "time-record-form-parent"
|
|
1234
|
+
}), /*#__PURE__*/React.createElement(DatePicker, {
|
|
822
1235
|
mode: "daily",
|
|
823
1236
|
required: true,
|
|
824
1237
|
firstDayOfWeek: 1,
|
|
825
|
-
position: "bottom-
|
|
1238
|
+
position: "bottom-start",
|
|
826
1239
|
selected: {
|
|
827
1240
|
from: date,
|
|
828
1241
|
to: date
|
|
829
1242
|
},
|
|
830
1243
|
onSave: range => range != null && range.from ? setDate(Number(range.from)) : undefined,
|
|
831
|
-
target: /*#__PURE__*/React.createElement(
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
className: "trd-hours"
|
|
842
|
-
}, /*#__PURE__*/React.createElement(InputHours, {
|
|
843
|
-
autoFocus: true,
|
|
844
|
-
allowEmptyValue: true,
|
|
845
|
-
size: "biggest",
|
|
846
|
-
placeholder: "00:00",
|
|
847
|
-
value: value,
|
|
848
|
-
onChange: setValue
|
|
849
|
-
})), /*#__PURE__*/React.createElement("span", {
|
|
850
|
-
className: "trd-field"
|
|
851
|
-
}, /*#__PURE__*/React.createElement(Label, {
|
|
852
|
-
size: "small"
|
|
853
|
-
}, "User"), /*#__PURE__*/React.createElement(Select, {
|
|
1244
|
+
target: /*#__PURE__*/React.createElement(PropertyListRow, {
|
|
1245
|
+
icon: /*#__PURE__*/React.createElement(CalendarIcon, null),
|
|
1246
|
+
label: "Date",
|
|
1247
|
+
value: /*#__PURE__*/React.createElement(PropertyListValue, null, formatDateRange(date, date)),
|
|
1248
|
+
"data-testid": "time-record-form-date"
|
|
1249
|
+
})
|
|
1250
|
+
})), /*#__PURE__*/React.createElement(PropertyList, null, /*#__PURE__*/React.createElement(TimeRecordSelectRow, {
|
|
1251
|
+
icon: /*#__PURE__*/React.createElement(PersonIcon, null),
|
|
1252
|
+
label: "User",
|
|
1253
|
+
placeholder: "Choose a User",
|
|
854
1254
|
options: users,
|
|
855
1255
|
selected: userId,
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
className: "trd-field"
|
|
863
|
-
}, /*#__PURE__*/React.createElement(Label, {
|
|
864
|
-
size: "small"
|
|
865
|
-
}, "Job Type"), /*#__PURE__*/React.createElement(Select, {
|
|
1256
|
+
onChange: setUserId,
|
|
1257
|
+
testId: "add-time-record-user"
|
|
1258
|
+
}), /*#__PURE__*/React.createElement(TimeRecordSelectRow, {
|
|
1259
|
+
icon: /*#__PURE__*/React.createElement(ToolsIcon, null),
|
|
1260
|
+
label: "Job Type",
|
|
1261
|
+
placeholder: "Choose a Job Type",
|
|
866
1262
|
options: JOB_TYPES,
|
|
867
1263
|
selected: jobTypeId,
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
})), /*#__PURE__*/React.createElement("span", {
|
|
874
|
-
className: "trd-billable"
|
|
875
|
-
}, /*#__PURE__*/React.createElement(Checkbox, {
|
|
876
|
-
id: "trd-billable",
|
|
877
|
-
checked: billable,
|
|
878
|
-
onChange: () => setBillable(prev => !prev)
|
|
879
|
-
}), /*#__PURE__*/React.createElement(Label, {
|
|
1264
|
+
onChange: setJobTypeId,
|
|
1265
|
+
testId: "add-time-record-job-type"
|
|
1266
|
+
})), /*#__PURE__*/React.createElement(PropertyList, null, /*#__PURE__*/React.createElement("div", {
|
|
1267
|
+
className: "trd-toggles"
|
|
1268
|
+
}, /*#__PURE__*/React.createElement("label", {
|
|
880
1269
|
htmlFor: "trd-billable",
|
|
881
|
-
|
|
882
|
-
},
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
})) : null, /*#__PURE__*/React.createElement("div", {
|
|
1270
|
+
className: "trd-toggle"
|
|
1271
|
+
}, /*#__PURE__*/React.createElement(Toggle, {
|
|
1272
|
+
id: "trd-billable",
|
|
1273
|
+
size: "small",
|
|
1274
|
+
defaultChecked: billable,
|
|
1275
|
+
onChange: event => setBillable(event.target.checked)
|
|
1276
|
+
}), /*#__PURE__*/React.createElement(Body2, {
|
|
1277
|
+
className: "trd-toggle-label"
|
|
1278
|
+
}, "Billable")))))), /*#__PURE__*/React.createElement("div", {
|
|
891
1279
|
className: "trd-actions"
|
|
892
1280
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
893
1281
|
variant: "primary",
|
|
894
|
-
|
|
895
|
-
onClick: handleSubmit
|
|
1282
|
+
type: "submit"
|
|
896
1283
|
}, "Add Time Record"), /*#__PURE__*/React.createElement(Button, {
|
|
897
1284
|
variant: "secondary",
|
|
898
|
-
onClick: onClose
|
|
899
|
-
}, "Cancel"))), total > 0 ? /*#__PURE__*/React.createElement("button", {
|
|
900
1285
|
type: "button",
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
}
|
|
909
|
-
key: record.id,
|
|
910
|
-
className: "trd-record"
|
|
911
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
912
|
-
className: "trd-record-left"
|
|
913
|
-
}, /*#__PURE__*/React.createElement(Caption1, {
|
|
914
|
-
weight: "bold",
|
|
915
|
-
color: "secondary"
|
|
916
|
-
}, formatDateRange(record.date, record.date)), /*#__PURE__*/React.createElement(Body2, null, record.userName), /*#__PURE__*/React.createElement(Caption1, {
|
|
917
|
-
color: "secondary"
|
|
918
|
-
}, record.jobType)), /*#__PURE__*/React.createElement(Body2, {
|
|
919
|
-
weight: "bold",
|
|
920
|
-
tabularNums: true
|
|
921
|
-
}, formatHours(record.hours), "h")))) : null));
|
|
1286
|
+
onClick: onClose
|
|
1287
|
+
}, "Cancel"))), /*#__PURE__*/React.createElement(TimeRecordExistingSection, {
|
|
1288
|
+
records: records,
|
|
1289
|
+
users: users,
|
|
1290
|
+
currentUserId: currentUserId,
|
|
1291
|
+
onUpdate: onUpdate,
|
|
1292
|
+
onTrash: onTrash
|
|
1293
|
+
})));
|
|
922
1294
|
};
|
|
923
1295
|
//# sourceMappingURL=columns.js.map
|