- Minutes
+ Minutes{' '}
- {loading && Loading assigned tasks…
}
+ {loading && Loading assigned tasks… }
{!locked && validation && {validation}
}
{error && (
@@ -292,13 +299,7 @@ export default function SplitTimeEntryForm({
disabled={busy || !connected || (!locked && (loading || Boolean(validation)))}
onClick={submit}
>
- {busy
- ? 'Saving…'
- : draft.saved
- ? 'Finish timer'
- : locked
- ? 'Retry split save'
- : `Submit ${draft.rows.length} time entries`}
+ {submitLabel(busy, draft.saved, locked, draft.rows.length)}
);
diff --git a/src/components/Timelog/TimeEntryForm/SplitTimeEntryForm.module.css b/src/components/Timelog/TimeEntryForm/SplitTimeEntryForm.module.css
index 7b908e80c0d..3d5da7738a0 100644
--- a/src/components/Timelog/TimeEntryForm/SplitTimeEntryForm.module.css
+++ b/src/components/Timelog/TimeEntryForm/SplitTimeEntryForm.module.css
@@ -3,6 +3,11 @@
min-width: 0;
}
+.status {
+ display: block;
+ margin-bottom: 16px;
+}
+
.totals {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
diff --git a/src/components/Timelog/TimeEntryForm/TimeEntryForm.jsx b/src/components/Timelog/TimeEntryForm/TimeEntryForm.jsx
index 1e1b408ab51..d87ffaa56ef 100644
--- a/src/components/Timelog/TimeEntryForm/TimeEntryForm.jsx
+++ b/src/components/Timelog/TimeEntryForm/TimeEntryForm.jsx
@@ -70,6 +70,92 @@ const customImageUploadHandler = () =>
* @returns
*/
+function renderTimeEntryHeading({ edit, isTangible, darkMode, viewingUser, onAbout, loading }) {
+ return (
+ <>
+
+ {edit ? 'Edit ' : 'Add '}
+ {isTangible ? (
+ Tangible
+ ) : (
+ Intangible
+ )}
+ Time Entry
+ {viewingUser.userId ? ` for ${viewingUser.firstName} ${viewingUser.lastName} ` : ' '}
+
+ {loading && Loading Data... }
+
+
+ Click this icon to learn about this time entry form
+
+ >
+ );
+}
+
+function initialProjectSelection(edit, projectId, wbsId, taskId) {
+ if (!edit) return 'defaultProject';
+ return projectId + (wbsId ? `/${wbsId}` : '') + (taskId ? `/${taskId}` : '');
+}
+
+function entryUserId(from, viewingUser, authUser, data) {
+ return from === 'Timer' ? viewingUser.userId ?? authUser.userid : data.personId;
+}
+
+function allowsTimeChange(from, canEditTimeEntryTime, isSameDayAuthUserEdit) {
+ return from !== 'Timer' && (from === 'TimeLog' || canEditTimeEntryTime || isSameDayAuthUserEdit);
+}
+
+function timeEntryEditorOptions(darkMode) {
+ return {
+ license_key: 'gpl',
+ menubar: false,
+ placeholder: 'Description (10-word minimum) and reference link',
+ plugins: 'advlist autolink autoresize lists link charmap table help wordcount',
+ toolbar:
+ // eslint-disable-next-line no-multi-str
+ 'bold italic underline link removeformat | bullist numlist outdent indent |\
+ styleselect fontsizeselect | table| strikethrough forecolor backcolor |\
+ subscript superscript charmap | help',
+ branding: false,
+ toolbar_mode: 'sliding',
+ min_height: 250,
+ max_height: 300,
+ autoresize_bottom_margin: 1,
+ content_style:
+ 'body { cursor: text !important; } .mce-content-body[data-mce-placeholder]:focus::before {content: "";}',
+ images_upload_handler: customImageUploadHandler,
+ skin: darkMode ? 'oxide-dark' : 'oxide',
+ content_css: darkMode ? 'dark' : 'default',
+ };
+}
+
+function timeEntryTheme(darkMode) {
+ if (darkMode)
+ return {
+ fontColor: 'text-light',
+ headerBg: 'bg-space-cadet',
+ bodyBg: 'bg-yinmn-blue',
+ modalClass: 'text-light dark-mode',
+ modalStyle: boxStyleDark,
+ buttonStyle: boxStyleDark,
+ };
+ return {
+ fontColor: '',
+ headerBg: '',
+ bodyBg: '',
+ modalClass: '',
+ modalStyle: {},
+ buttonStyle: boxStyle,
+ };
+}
+
export function TimeEntryForm(props) {
/* ---------------- variables -------------- */
// props from parent
@@ -114,28 +200,9 @@ export function TimeEntryForm(props) {
...data,
};
- const TINY_MCE_INIT_OPTIONS = {
- license_key: 'gpl',
- menubar: false,
- placeholder: 'Description (10-word minimum) and reference link',
- plugins: 'advlist autolink autoresize lists link charmap table help wordcount',
- toolbar:
- // eslint-disable-next-line no-multi-str
- 'bold italic underline link removeformat | bullist numlist outdent indent |\
- styleselect fontsizeselect | table| strikethrough forecolor backcolor |\
- subscript superscript charmap | help',
- branding: false,
- toolbar_mode: 'sliding',
- min_height: 250,
- max_height: 300,
- autoresize_bottom_margin: 1,
- content_style: 'body { cursor: text !important; } .mce-content-body[data-mce-placeholder]:focus::before {content: "";}',
- images_upload_handler: customImageUploadHandler,
- skin: darkMode ? 'oxide-dark' : 'oxide',
- content_css: darkMode ? 'dark' : 'default',
- };
+ const TINY_MCE_INIT_OPTIONS = timeEntryEditorOptions(darkMode);
- const timeEntryUserId = from === 'Timer' ? viewingUser.userId ?? authUser.userid : data.personId;
+ const timeEntryUserId = entryUserId(from, viewingUser, authUser, data);
const {
dateOfWork: initialDateOfWork,
@@ -148,11 +215,7 @@ export function TimeEntryForm(props) {
isTangible: initialIsTangible,
} = initialFormValues;
- const timeEntryInitialProjectOrTaskId = edit
- ? initialProjectId +
- (initialwbsId ? `/${initialwbsId}` : '') +
- (initialTaskId ? `/${initialTaskId}` : '')
- : 'defaultProject';
+ const timeEntryInitialProjectOrTaskId = initialProjectSelection(edit, initialProjectId, initialwbsId, initialTaskId);
const initialReminder = {
openModal: false,
@@ -224,8 +287,7 @@ export function TimeEntryForm(props) {
const canPutUserProfileImportantInfo = props.hasPermission(permissions.putUserProfileImportantInfo);
// Administrator/Owner can add time entries for any dates, and other roles can only edit their own time entry in the same day.
- const canChangeTime =
- from !== 'Timer' && (from === 'TimeLog' || canEditTimeEntryTime || isSameDayAuthUserEdit);
+ const canChangeTime = allowsTimeChange(from, canEditTimeEntryTime, isSameDayAuthUserEdit);
/* ---------------- methods -------------- */
const toggleRemainder = () =>
@@ -715,42 +777,19 @@ export function TimeEntryForm(props) {
setFormValues(prev => ({ ...prev, ...data }));
}, [data]);
- const fontColor = darkMode ? 'text-light' : '';
- const headerBg = darkMode ? 'bg-space-cadet' : '';
- const bodyBg = darkMode ? 'bg-yinmn-blue' : '';
+ const { fontColor, headerBg, bodyBg, modalClass, modalStyle, buttonStyle } = timeEntryTheme(darkMode);
return (
<>
-
- {edit ? 'Edit ' : 'Add '}
- {formValues.isTangible ? (
- Tangible
- ) : (
- Intangible
- )}
- Time Entry
- {viewingUser.userId ? ` for ${viewingUser.firstName} ${viewingUser.lastName} ` : ' '}
-
- {!isAsyncDataLoaded && Loading Data... }
-
-
- Click this icon to learn about this time entry form
-
+ {renderTimeEntryHeading({ edit, isTangible: formValues.isTangible, darkMode, viewingUser, onAbout: aboutModalToggle, loading: !isAsyncDataLoaded })}