Browse Source

Add project details on hover in timesheet project select

tags/Baseline_180220205_Frontend
Wayne 11 months ago
parent
commit
c494e6463b
3 changed files with 41 additions and 8 deletions
  1. +1
    -0
      src/app/api/projects/index.ts
  2. +1
    -1
      src/components/TimeLeaveModal/TimeLeaveInputTable.tsx
  3. +39
    -7
      src/components/TimesheetTable/ProjectSelect.tsx

+ 1
- 0
src/app/api/projects/index.ts View File

@@ -79,6 +79,7 @@ export interface ProjectWithTasks {
id: number;
code: string;
status?: string;
description?: string;
name: string;
tasks: Task[];
milestones: {


+ 1
- 1
src/components/TimeLeaveModal/TimeLeaveInputTable.tsx View File

@@ -194,7 +194,7 @@ const TimeLeaveInputTable: React.FC<Props> = ({
...model,
[id]: { mode: GridRowModes.View, ignoreModifications: true },
}));
const editedRow = entries.find((entry) => entry.id === id);
const editedRow = entries.find((entry) => getRowId(entry) === id);
if (editedRow?._isNew) {
setEntries((es) => es.filter((e) => getRowId(e) !== id));
} else {


+ 39
- 7
src/components/TimesheetTable/ProjectSelect.tsx View File

@@ -1,11 +1,13 @@
import React, { useCallback, useMemo } from "react";
import {
Autocomplete,
Box,
Checkbox,
Chip,
ListSubheader,
MenuItem,
TextField,
Tooltip,
} from "@mui/material";
import { AssignedProject, ProjectWithTasks } from "@/app/api/projects";
import { useTranslation } from "react-i18next";
@@ -184,13 +186,10 @@ const AutocompleteProjectSelect: React.FC<Props> = ({
) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { key, ...rest } = params;
return (
<MenuItem
{...rest}
disableRipple
value={option.value}
key={`${option.value}--${option.label}`}
>
const childKey = `${option.value}--${option.label}`;

const content = (
<MenuItem {...rest} disableRipple value={option.value} key={childKey}>
{multiple && (
<Checkbox
disableRipple
@@ -202,6 +201,39 @@ const AutocompleteProjectSelect: React.FC<Props> = ({
{option.label}
</MenuItem>
);

const associatedProject = allProjects.find(
(p) => p.id === option.value,
);

return associatedProject ? (
<Tooltip
key={childKey}
placement="right"
title={
<Box sx={{ display: "flex", flexDirection: "column", gap: 2 }}>
<Box>
<Box>{t("Project Code")}</Box>
{associatedProject.code}
</Box>
<Box>
<Box>{t("Project Name")}</Box>
{associatedProject.name}
</Box>
{associatedProject.description && (
<Box>
<Box>{t("Project Description")}</Box>
{associatedProject.description}
</Box>
)}
</Box>
}
>
{content}
</Tooltip>
) : (
content
);
}}
renderInput={(params) => <TextField {...params} error={error} />}
/>


Loading…
Cancel
Save