Browse Source

Do not show project pass actual end date in timesheet project selection

tags/Baseline_180220205_Frontend
Wayne 10 months ago
parent
commit
703591adc4
6 changed files with 18 additions and 6 deletions
  1. +1
    -0
      src/app/api/projects/index.ts
  2. +3
    -0
      src/components/TimeLeaveModal/TimeLeaveInputTable.tsx
  3. +3
    -0
      src/components/TimeLeaveModal/TimeLeaveMobileEntry.tsx
  4. +2
    -0
      src/components/TimesheetTable/FastTimeEntryModal.tsx
  5. +7
    -6
      src/components/TimesheetTable/ProjectSelect.tsx
  6. +2
    -0
      src/components/TimesheetTable/TimesheetEditModal.tsx

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

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


+ 3
- 0
src/components/TimeLeaveModal/TimeLeaveInputTable.tsx View File

@@ -345,6 +345,7 @@ const TimeLeaveInputTable: React.FC<Props> = ({
renderEditCell(params: GridRenderEditCellParams<TimeLeaveRow, number>) { renderEditCell(params: GridRenderEditCellParams<TimeLeaveRow, number>) {
return ( return (
<ProjectSelect <ProjectSelect
referenceDay={dayjs(day)}
includeLeaves includeLeaves
leaveTypes={leaveTypes} leaveTypes={leaveTypes}
multiple={false} multiple={false}
@@ -618,6 +619,7 @@ const TimeLeaveInputTable: React.FC<Props> = ({
taskGroupsByProject, taskGroupsByProject,
taskGroupsWithoutProject, taskGroupsWithoutProject,
miscTasks, miscTasks,
day,
], ],
); );


@@ -747,6 +749,7 @@ const TimeLeaveInputTable: React.FC<Props> = ({
/> />
{fastEntryEnabled && ( {fastEntryEnabled && (
<FastTimeEntryModal <FastTimeEntryModal
recordDate={day}
allProjects={allProjects} allProjects={allProjects}
assignedProjects={assignedProjects} assignedProjects={assignedProjects}
open={fastEntryModalOpen} open={fastEntryModalOpen}


+ 3
- 0
src/components/TimeLeaveModal/TimeLeaveMobileEntry.tsx View File

@@ -268,6 +268,7 @@ const TimeLeaveMobileEntry: React.FC<Props> = ({
)} )}
</Stack> </Stack>
<TimesheetEditModal <TimesheetEditModal
recordDate={date}
allProjects={allProjects} allProjects={allProjects}
assignedProjects={assignedProjects} assignedProjects={assignedProjects}
open={editTimeModalOpen} open={editTimeModalOpen}
@@ -278,6 +279,7 @@ const TimeLeaveMobileEntry: React.FC<Props> = ({
{...editTimeModalProps} {...editTimeModalProps}
/> />
<LeaveEditModal <LeaveEditModal
recordDate={date}
leaveTypes={leaveTypes} leaveTypes={leaveTypes}
open={editLeaveModalOpen} open={editLeaveModalOpen}
onClose={closeEditLeaveModal} onClose={closeEditLeaveModal}
@@ -287,6 +289,7 @@ const TimeLeaveMobileEntry: React.FC<Props> = ({
/> />
{fastEntryEnabled && ( {fastEntryEnabled && (
<FastTimeEntryModal <FastTimeEntryModal
recordDate={date}
allProjects={allProjects} allProjects={allProjects}
assignedProjects={assignedProjects} assignedProjects={assignedProjects}
open={fastEntryModalOpen} open={fastEntryModalOpen}


+ 2
- 0
src/components/TimesheetTable/FastTimeEntryModal.tsx View File

@@ -30,6 +30,7 @@ import { manhourFormatter, shortDateFormatter } from "@/app/utils/formatUtil";
import { DAILY_NORMAL_MAX_HOURS } from "@/app/api/timesheets/utils"; import { DAILY_NORMAL_MAX_HOURS } from "@/app/api/timesheets/utils";
import zip from "lodash/zip"; import zip from "lodash/zip";
import intersectionBy from "lodash/intersectionBy"; import intersectionBy from "lodash/intersectionBy";
import dayjs from "dayjs";


export interface FastTimeEntryForm { export interface FastTimeEntryForm {
projectIds: TimeEntry["projectId"][]; projectIds: TimeEntry["projectId"][];
@@ -174,6 +175,7 @@ const FastTimeEntryModal: React.FC<Props> = ({
name="projectIds" name="projectIds"
render={({ field }) => ( render={({ field }) => (
<ProjectSelect <ProjectSelect
referenceDay={dayjs(recordDate)}
includeLeaves={false} includeLeaves={false}
error={Boolean(formState.errors.projectIds)} error={Boolean(formState.errors.projectIds)}
multiple multiple


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

@@ -15,13 +15,14 @@ import differenceBy from "lodash/differenceBy";
import intersectionWith from "lodash/intersectionWith"; import intersectionWith from "lodash/intersectionWith";
import { TFunction } from "i18next"; import { TFunction } from "i18next";
import { LeaveType } from "@/app/api/timesheets"; import { LeaveType } from "@/app/api/timesheets";
import dayjs, { Dayjs } from "dayjs";


interface CommonProps { interface CommonProps {
allProjects: ProjectWithTasks[]; allProjects: ProjectWithTasks[];
assignedProjects: AssignedProject[]; assignedProjects: AssignedProject[];
error?: boolean; error?: boolean;
multiple?: boolean; multiple?: boolean;
showOnlyOngoing?: boolean;
referenceDay: Dayjs;
includeLeaves?: boolean; includeLeaves?: boolean;
leaveTypes?: LeaveType[]; leaveTypes?: LeaveType[];
} }
@@ -64,7 +65,7 @@ const getGroupName = (t: TFunction, groupName: string): string => {


const AutocompleteProjectSelect: React.FC<Props> = ({ const AutocompleteProjectSelect: React.FC<Props> = ({
allProjects, allProjects,
showOnlyOngoing = true,
referenceDay,
assignedProjects, assignedProjects,
value, value,
onProjectSelect, onProjectSelect,
@@ -75,10 +76,10 @@ const AutocompleteProjectSelect: React.FC<Props> = ({
}) => { }) => {
const { t } = useTranslation("home"); const { t } = useTranslation("home");
const allFilteredProjects = useMemo(() => { const allFilteredProjects = useMemo(() => {
return showOnlyOngoing
? allProjects.filter((p) => p.status === "On-going")
: allProjects;
}, [showOnlyOngoing, allProjects]);
return allProjects.filter((p) =>
p.actualEnd ? !referenceDay.isAfter(p.actualEnd) : true,
);
}, [allProjects, referenceDay]);


const nonAssignedProjects = useMemo(() => { const nonAssignedProjects = useMemo(() => {
return differenceBy(allFilteredProjects, assignedProjects, "id"); return differenceBy(allFilteredProjects, assignedProjects, "id");


+ 2
- 0
src/components/TimesheetTable/TimesheetEditModal.tsx View File

@@ -29,6 +29,7 @@ import {
DAILY_NORMAL_MAX_HOURS, DAILY_NORMAL_MAX_HOURS,
TIMESHEET_DAILY_MAX_HOURS, TIMESHEET_DAILY_MAX_HOURS,
} from "@/app/api/timesheets/utils"; } from "@/app/api/timesheets/utils";
import dayjs from "dayjs";


export interface Props extends Omit<ModalProps, "children"> { export interface Props extends Omit<ModalProps, "children"> {
onSave: (timeEntry: TimeEntry, recordDate?: string) => Promise<void>; onSave: (timeEntry: TimeEntry, recordDate?: string) => Promise<void>;
@@ -162,6 +163,7 @@ const TimesheetEditModal: React.FC<Props> = ({
name="projectId" name="projectId"
render={({ field }) => ( render={({ field }) => (
<ProjectSelect <ProjectSelect
referenceDay={dayjs(recordDate)}
multiple={false} multiple={false}
allProjects={allProjects} allProjects={allProjects}
assignedProjects={assignedProjects} assignedProjects={assignedProjects}


Loading…
Cancel
Save