fix: spreadsheet view bug fixes (#1383)

* fix: due date sorting fix

* fix: update and delete sub-issue fix
This commit is contained in:
Anmol Singh Bhatia 2023-06-24 00:35:43 +05:30 committed by GitHub
parent ddaa8df1c5
commit 5ada1e5397
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 12 deletions

View File

@ -38,7 +38,7 @@ type Props = {
expanded: boolean;
handleToggleExpand: (issueId: string) => void;
properties: Properties;
handleEditIssue: () => void;
handleEditIssue: (issue: IIssue) => void;
handleDeleteIssue: (issue: IIssue) => void;
gridTemplateColumns: string;
user: ICurrentUserResponse | undefined;
@ -245,7 +245,7 @@ export const SingleSpreadsheetIssue: React.FC<Props> = ({
>
{!isNotAllowed && (
<CustomMenu width="auto" position="left" ellipsis>
<CustomMenu.MenuItem onClick={handleEditIssue}>
<CustomMenu.MenuItem onClick={() => handleEditIssue(issue)}>
<div className="flex items-center justify-start gap-2">
<PencilIcon className="h-4 w-4" />
<span>Edit issue</span>

View File

@ -59,7 +59,7 @@ export const SpreadsheetIssues: React.FC<Props> = ({
handleToggleExpand={handleToggleExpand}
gridTemplateColumns={gridTemplateColumns}
properties={properties}
handleEditIssue={() => handleEditIssue(issue)}
handleEditIssue={handleEditIssue}
handleDeleteIssue={handleDeleteIssue}
user={user}
userAuth={userAuth}
@ -78,7 +78,7 @@ export const SpreadsheetIssues: React.FC<Props> = ({
setExpandedIssues={setExpandedIssues}
gridTemplateColumns={gridTemplateColumns}
properties={properties}
handleEditIssue={() => handleEditIssue(subIssue)}
handleEditIssue={handleEditIssue}
handleDeleteIssue={handleDeleteIssue}
user={user}
userAuth={userAuth}

View File

@ -18,12 +18,13 @@ import { ExclamationTriangleIcon } from "@heroicons/react/24/outline";
// ui
import { SecondaryButton, DangerButton } from "components/ui";
// types
import type { IIssue, ICurrentUserResponse } from "types";
import type { IIssue, ICurrentUserResponse, ISubIssueResponse } from "types";
// fetch-keys
import {
CYCLE_ISSUES_WITH_PARAMS,
MODULE_ISSUES_WITH_PARAMS,
PROJECT_ISSUES_LIST_WITH_PARAMS,
SUB_ISSUES,
VIEW_ISSUES,
} from "constants/fetch-keys";
@ -84,12 +85,27 @@ export const DeleteIssueModal: React.FC<Props> = ({ isOpen, handleClose, data, u
: viewId
? VIEW_ISSUES(viewId.toString(), spreadsheetParams)
: PROJECT_ISSUES_LIST_WITH_PARAMS(projectId?.toString() ?? "", spreadsheetParams);
if (data.parent) {
mutate<ISubIssueResponse>(
SUB_ISSUES(data.parent.toString()),
(prevData) => {
if (!prevData) return prevData;
const updatedArray = (prevData.sub_issues ?? []).filter((i) => i.id !== data.id);
return {
...prevData,
sub_issues: updatedArray,
};
},
false
);
} else {
mutate<IIssue[]>(
spreadsheetFetchKey,
(prevData) => (prevData ?? []).filter((p) => p.id !== data.id),
false
);
}
} else {
if (cycleId) mutate(CYCLE_ISSUES_WITH_PARAMS(cycleId as string, params));
else if (moduleId) mutate(MODULE_ISSUES_WITH_PARAMS(moduleId as string, params));

View File

@ -276,6 +276,7 @@ export const CreateUpdateIssueModal: React.FC<IssuesModalProps> = ({
} else {
if (issueView === "calendar") mutate(calendarFetchKey);
if (issueView === "spreadsheet") mutate(spreadsheetFetchKey);
if (payload.parent) mutate(SUB_ISSUES(payload.parent.toString()));
mutate(PROJECT_ISSUES_LIST_WITH_PARAMS(activeProject ?? "", params));
}

View File

@ -48,8 +48,8 @@ export const SPREADSHEET_COLUMN = [
colName: "Due Date",
colSize: "128px",
icon: CalendarDaysIcon,
ascendingOrder: "target_date",
descendingOrder: "-target_date",
ascendingOrder: "-target_date",
descendingOrder: "target_date",
},
{
propertyName: "estimate",