mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
fix group by bugs
This commit is contained in:
parent
0d0bfd8a32
commit
fb4ac91f22
@ -119,6 +119,20 @@ export const BaseCalendarRoot = observer((props: IBaseCalendarRoot) => {
|
|||||||
[fetchNextIssues]
|
[fetchNextIssues]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const getPaginationData = useCallback(
|
||||||
|
(groupId: string | undefined) => {
|
||||||
|
return issues?.getPaginationData(groupId, undefined);
|
||||||
|
},
|
||||||
|
[issues?.getPaginationData]
|
||||||
|
);
|
||||||
|
|
||||||
|
const getGroupIssueCount = useCallback(
|
||||||
|
(groupId: string | undefined) => {
|
||||||
|
return issues?.getGroupIssueCount(groupId, undefined, false);
|
||||||
|
},
|
||||||
|
[issues?.getGroupIssueCount]
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<IssueLayoutHOC storeType={storeType} layout={EIssueLayoutTypes.CALENDAR}>
|
<IssueLayoutHOC storeType={storeType} layout={EIssueLayoutTypes.CALENDAR}>
|
||||||
<div className="h-full w-full overflow-hidden bg-custom-background-100 pt-4">
|
<div className="h-full w-full overflow-hidden bg-custom-background-100 pt-4">
|
||||||
@ -145,8 +159,8 @@ export const BaseCalendarRoot = observer((props: IBaseCalendarRoot) => {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
loadMoreIssues={loadMoreIssues}
|
loadMoreIssues={loadMoreIssues}
|
||||||
getPaginationData={issues.getPaginationData}
|
getPaginationData={getPaginationData}
|
||||||
getGroupIssueCount={issues.getGroupIssueCount}
|
getGroupIssueCount={getGroupIssueCount}
|
||||||
addIssuesToView={addIssuesToView}
|
addIssuesToView={addIssuesToView}
|
||||||
quickAddCallback={issues.quickAddIssue}
|
quickAddCallback={issues.quickAddIssue}
|
||||||
viewId={viewId}
|
viewId={viewId}
|
||||||
|
@ -49,7 +49,7 @@ export const BaseGanttRoot: React.FC<IBaseGanttRoot> = observer((props: IBaseGan
|
|||||||
});
|
});
|
||||||
|
|
||||||
const issuesIds = (issues.groupedIssueIds?.[ALL_ISSUES] as string[]) ?? [];
|
const issuesIds = (issues.groupedIssueIds?.[ALL_ISSUES] as string[]) ?? [];
|
||||||
const nextPageResults = issues.getPaginationData(ALL_ISSUES)?.nextPageResults;
|
const nextPageResults = issues.getPaginationData(undefined, undefined)?.nextPageResults;
|
||||||
|
|
||||||
const { enableIssueCreation } = issues?.viewFlags || {};
|
const { enableIssueCreation } = issues?.viewFlags || {};
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ export const IssueLayoutHOC = observer((props: Props) => {
|
|||||||
return <ActiveLoader layout={layout} />;
|
return <ActiveLoader layout={layout} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (issues.getGroupIssueCount(ALL_ISSUES) === 0) {
|
if (issues.getGroupIssueCount(undefined, undefined, false) === 0) {
|
||||||
return <IssueLayoutEmptyState storeType={storeType} />;
|
return <IssueLayoutEmptyState storeType={storeType} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ import { MutableRefObject, memo } from "react";
|
|||||||
//types
|
//types
|
||||||
import { KanbanIssueBlock } from "components/issues";
|
import { KanbanIssueBlock } from "components/issues";
|
||||||
import { TIssue, IIssueDisplayProperties, IIssueMap } from "@plane/types";
|
import { TIssue, IIssueDisplayProperties, IIssueMap } from "@plane/types";
|
||||||
|
import { observer } from "mobx-react";
|
||||||
// components
|
// components
|
||||||
|
|
||||||
interface IssueBlocksListProps {
|
interface IssueBlocksListProps {
|
||||||
@ -21,7 +22,7 @@ interface IssueBlocksListProps {
|
|||||||
isDragStarted?: boolean;
|
isDragStarted?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const KanbanIssueBlocksListMemo: React.FC<IssueBlocksListProps> = (props) => {
|
export const KanbanIssueBlocksList: React.FC<IssueBlocksListProps> = observer((props) => {
|
||||||
const {
|
const {
|
||||||
sub_group_id,
|
sub_group_id,
|
||||||
columnId,
|
columnId,
|
||||||
@ -71,6 +72,4 @@ const KanbanIssueBlocksListMemo: React.FC<IssueBlocksListProps> = (props) => {
|
|||||||
) : null}
|
) : null}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
});
|
||||||
|
|
||||||
export const KanbanIssueBlocksList = memo(KanbanIssueBlocksListMemo);
|
|
||||||
|
@ -34,8 +34,12 @@ import { KanbanStoreType } from "./base-kanban-root";
|
|||||||
export interface IGroupByKanBan {
|
export interface IGroupByKanBan {
|
||||||
issuesMap: IIssueMap;
|
issuesMap: IIssueMap;
|
||||||
groupedIssueIds: TGroupedIssues | TSubGroupedIssues;
|
groupedIssueIds: TGroupedIssues | TSubGroupedIssues;
|
||||||
getGroupIssueCount: (groupId: string | undefined) => number | undefined;
|
getGroupIssueCount: (
|
||||||
getPaginationData: (groupId: string | undefined) => TPaginationData | undefined;
|
groupId: string | undefined,
|
||||||
|
subGroupId: string | undefined,
|
||||||
|
isSubGroupCumulative: boolean
|
||||||
|
) => number | undefined;
|
||||||
|
getPaginationData: (groupId: string | undefined, subGroupId: string | undefined) => TPaginationData | undefined;
|
||||||
displayProperties: IIssueDisplayProperties | undefined;
|
displayProperties: IIssueDisplayProperties | undefined;
|
||||||
sub_group_by: string | null;
|
sub_group_by: string | null;
|
||||||
group_by: string | null;
|
group_by: string | null;
|
||||||
@ -113,7 +117,7 @@ const GroupByKanBan: React.FC<IGroupByKanBan> = observer((props) => {
|
|||||||
|
|
||||||
if (!list) return null;
|
if (!list) return null;
|
||||||
|
|
||||||
const groupWithIssues = list.filter((_list) => (getGroupIssueCount(_list.id) ?? 0) > 0);
|
const groupWithIssues = list.filter((_list) => (getGroupIssueCount(_list.id, undefined, false) ?? 0) > 0);
|
||||||
|
|
||||||
const groupList = showEmptyGroup ? list : groupWithIssues;
|
const groupList = showEmptyGroup ? list : groupWithIssues;
|
||||||
|
|
||||||
@ -149,7 +153,7 @@ const GroupByKanBan: React.FC<IGroupByKanBan> = observer((props) => {
|
|||||||
column_id={_list.id}
|
column_id={_list.id}
|
||||||
icon={_list.icon}
|
icon={_list.icon}
|
||||||
title={_list.name}
|
title={_list.name}
|
||||||
count={getGroupIssueCount(_list.id) ?? 0}
|
count={getGroupIssueCount(_list.id, undefined, false) ?? 0}
|
||||||
issuePayload={_list.payload}
|
issuePayload={_list.payload}
|
||||||
disableIssueCreation={disableIssueCreation || isGroupByCreatedBy}
|
disableIssueCreation={disableIssueCreation || isGroupByCreatedBy}
|
||||||
storeType={storeType}
|
storeType={storeType}
|
||||||
@ -196,8 +200,12 @@ const GroupByKanBan: React.FC<IGroupByKanBan> = observer((props) => {
|
|||||||
export interface IKanBan {
|
export interface IKanBan {
|
||||||
issuesMap: IIssueMap;
|
issuesMap: IIssueMap;
|
||||||
groupedIssueIds: TGroupedIssues | TSubGroupedIssues;
|
groupedIssueIds: TGroupedIssues | TSubGroupedIssues;
|
||||||
getGroupIssueCount: (groupId: string | undefined) => number | undefined;
|
getPaginationData: (groupId: string | undefined, subGroupId: string | undefined) => TPaginationData | undefined;
|
||||||
getPaginationData: (groupId: string | undefined) => TPaginationData | undefined;
|
getGroupIssueCount: (
|
||||||
|
groupId: string | undefined,
|
||||||
|
subGroupId: string | undefined,
|
||||||
|
isSubGroupCumulative: boolean
|
||||||
|
) => number | undefined;
|
||||||
displayProperties: IIssueDisplayProperties | undefined;
|
displayProperties: IIssueDisplayProperties | undefined;
|
||||||
sub_group_by: string | null;
|
sub_group_by: string | null;
|
||||||
group_by: string | null;
|
group_by: string | null;
|
||||||
|
@ -22,8 +22,12 @@ interface IKanbanGroup {
|
|||||||
issuesMap: IIssueMap;
|
issuesMap: IIssueMap;
|
||||||
peekIssueId?: string;
|
peekIssueId?: string;
|
||||||
groupedIssueIds: TGroupedIssues | TSubGroupedIssues;
|
groupedIssueIds: TGroupedIssues | TSubGroupedIssues;
|
||||||
getGroupIssueCount: (groupId: string | undefined) => number | undefined;
|
getPaginationData: (groupId: string | undefined, subGroupId: string | undefined) => TPaginationData | undefined;
|
||||||
getPaginationData: (groupId: string | undefined) => TPaginationData | undefined;
|
getGroupIssueCount: (
|
||||||
|
groupId: string | undefined,
|
||||||
|
subGroupId: string | undefined,
|
||||||
|
isSubGroupCumulative: boolean
|
||||||
|
) => number | undefined;
|
||||||
displayProperties: IIssueDisplayProperties | undefined;
|
displayProperties: IIssueDisplayProperties | undefined;
|
||||||
sub_group_by: string | null;
|
sub_group_by: string | null;
|
||||||
group_by: string | null;
|
group_by: string | null;
|
||||||
@ -135,14 +139,14 @@ export const KanbanGroup = observer((props: IKanbanGroup) => {
|
|||||||
const isSubGroup = !!sub_group_id && sub_group_id !== "null";
|
const isSubGroup = !!sub_group_id && sub_group_id !== "null";
|
||||||
|
|
||||||
const issueIds = isSubGroup
|
const issueIds = isSubGroup
|
||||||
? (groupedIssueIds as TSubGroupedIssues)[groupId][sub_group_id]
|
? (groupedIssueIds as TSubGroupedIssues)?.[groupId]?.[sub_group_id]
|
||||||
: (groupedIssueIds as TGroupedIssues)[groupId];
|
: (groupedIssueIds as TGroupedIssues)?.[groupId];
|
||||||
|
|
||||||
const groupIssueCount = isSubGroup ? getGroupIssueCount(sub_group_id) : getGroupIssueCount(groupId);
|
if (!issueIds) return null;
|
||||||
|
|
||||||
const nextPageResults = isSubGroup
|
const groupIssueCount = getGroupIssueCount(groupId, sub_group_id, false);
|
||||||
? getPaginationData(sub_group_id)?.nextPageResults
|
|
||||||
: getPaginationData(groupId)?.nextPageResults;
|
const nextPageResults = getPaginationData(groupId, sub_group_id)?.nextPageResults;
|
||||||
|
|
||||||
const shouldLoadMore =
|
const shouldLoadMore =
|
||||||
nextPageResults === undefined && groupIssueCount !== undefined
|
nextPageResults === undefined && groupIssueCount !== undefined
|
||||||
|
@ -11,7 +11,6 @@ import {
|
|||||||
IIssueMap,
|
IIssueMap,
|
||||||
TSubGroupedIssues,
|
TSubGroupedIssues,
|
||||||
TIssueKanbanFilters,
|
TIssueKanbanFilters,
|
||||||
TGroupedIssueCount,
|
|
||||||
TPaginationData,
|
TPaginationData,
|
||||||
} from "@plane/types";
|
} from "@plane/types";
|
||||||
import { getGroupByColumns } from "../utils";
|
import { getGroupByColumns } from "../utils";
|
||||||
@ -23,7 +22,11 @@ import { KanbanStoreType } from "./base-kanban-root";
|
|||||||
// constants
|
// constants
|
||||||
|
|
||||||
interface ISubGroupSwimlaneHeader {
|
interface ISubGroupSwimlaneHeader {
|
||||||
getGroupIssueCount: (groupId: string | undefined) => number | undefined;
|
getGroupIssueCount: (
|
||||||
|
groupId: string | undefined,
|
||||||
|
subGroupId: string | undefined,
|
||||||
|
isSubGroupCumulative: boolean
|
||||||
|
) => number | undefined;
|
||||||
sub_group_by: string | null;
|
sub_group_by: string | null;
|
||||||
group_by: string | null;
|
group_by: string | null;
|
||||||
list: IGroupByColumn[];
|
list: IGroupByColumn[];
|
||||||
@ -32,15 +35,8 @@ interface ISubGroupSwimlaneHeader {
|
|||||||
storeType: KanbanStoreType;
|
storeType: KanbanStoreType;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SubGroupSwimlaneHeader: React.FC<ISubGroupSwimlaneHeader> = ({
|
const SubGroupSwimlaneHeader: React.FC<ISubGroupSwimlaneHeader> = observer(
|
||||||
getGroupIssueCount,
|
({ getGroupIssueCount, sub_group_by, group_by, storeType, list, kanbanFilters, handleKanbanFilters }) => (
|
||||||
sub_group_by,
|
|
||||||
group_by,
|
|
||||||
storeType,
|
|
||||||
list,
|
|
||||||
kanbanFilters,
|
|
||||||
handleKanbanFilters,
|
|
||||||
}) => (
|
|
||||||
<div className="relative flex h-max min-h-full w-full items-center gap-2">
|
<div className="relative flex h-max min-h-full w-full items-center gap-2">
|
||||||
{list &&
|
{list &&
|
||||||
list.length > 0 &&
|
list.length > 0 &&
|
||||||
@ -52,7 +48,7 @@ const SubGroupSwimlaneHeader: React.FC<ISubGroupSwimlaneHeader> = ({
|
|||||||
column_id={_list.id}
|
column_id={_list.id}
|
||||||
icon={_list.icon}
|
icon={_list.icon}
|
||||||
title={_list.name}
|
title={_list.name}
|
||||||
count={getGroupIssueCount(_list?.id) ?? 0}
|
count={getGroupIssueCount(_list?.id, undefined, false) ?? 0}
|
||||||
kanbanFilters={kanbanFilters}
|
kanbanFilters={kanbanFilters}
|
||||||
handleKanbanFilters={handleKanbanFilters}
|
handleKanbanFilters={handleKanbanFilters}
|
||||||
issuePayload={_list.payload}
|
issuePayload={_list.payload}
|
||||||
@ -61,13 +57,18 @@ const SubGroupSwimlaneHeader: React.FC<ISubGroupSwimlaneHeader> = ({
|
|||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
interface ISubGroupSwimlane extends ISubGroupSwimlaneHeader {
|
interface ISubGroupSwimlane extends ISubGroupSwimlaneHeader {
|
||||||
issuesMap: IIssueMap;
|
issuesMap: IIssueMap;
|
||||||
groupedIssueIds: TGroupedIssues | TSubGroupedIssues;
|
groupedIssueIds: TGroupedIssues | TSubGroupedIssues;
|
||||||
getGroupIssueCount: (groupId: string | undefined) => number | undefined;
|
getPaginationData: (groupId: string | undefined, subGroupId: string | undefined) => TPaginationData | undefined;
|
||||||
getPaginationData: (groupId: string | undefined) => TPaginationData | undefined;
|
getGroupIssueCount: (
|
||||||
|
groupId: string | undefined,
|
||||||
|
subGroupId: string | undefined,
|
||||||
|
isSubGroupCumulative: boolean
|
||||||
|
) => number | undefined;
|
||||||
showEmptyGroup: boolean;
|
showEmptyGroup: boolean;
|
||||||
displayProperties: IIssueDisplayProperties | undefined;
|
displayProperties: IIssueDisplayProperties | undefined;
|
||||||
updateIssue:
|
updateIssue:
|
||||||
@ -123,7 +124,7 @@ const SubGroupSwimlane: React.FC<ISubGroupSwimlane> = observer((props) => {
|
|||||||
{list &&
|
{list &&
|
||||||
list.length > 0 &&
|
list.length > 0 &&
|
||||||
list.map((_list: any) => {
|
list.map((_list: any) => {
|
||||||
const issueCount = getGroupIssueCount(_list.id) ?? 0;
|
const issueCount = getGroupIssueCount(undefined, _list.id, true) ?? 0;
|
||||||
return (
|
return (
|
||||||
<div key={_list.id} className="flex flex-shrink-0 flex-col">
|
<div key={_list.id} className="flex flex-shrink-0 flex-col">
|
||||||
<div className="sticky top-[50px] z-[1] flex w-full items-center bg-custom-background-90 py-1">
|
<div className="sticky top-[50px] z-[1] flex w-full items-center bg-custom-background-90 py-1">
|
||||||
@ -178,8 +179,12 @@ const SubGroupSwimlane: React.FC<ISubGroupSwimlane> = observer((props) => {
|
|||||||
export interface IKanBanSwimLanes {
|
export interface IKanBanSwimLanes {
|
||||||
issuesMap: IIssueMap;
|
issuesMap: IIssueMap;
|
||||||
groupedIssueIds: TGroupedIssues | TSubGroupedIssues;
|
groupedIssueIds: TGroupedIssues | TSubGroupedIssues;
|
||||||
getGroupIssueCount: (groupId: string | undefined) => number | undefined;
|
getPaginationData: (groupId: string | undefined, subGroupId: string | undefined) => TPaginationData | undefined;
|
||||||
getPaginationData: (groupId: string | undefined) => TPaginationData | undefined;
|
getGroupIssueCount: (
|
||||||
|
groupId: string | undefined,
|
||||||
|
subGroupId: string | undefined,
|
||||||
|
isSubGroupCumulative: boolean
|
||||||
|
) => number | undefined;
|
||||||
displayProperties: IIssueDisplayProperties | undefined;
|
displayProperties: IIssueDisplayProperties | undefined;
|
||||||
sub_group_by: string | null;
|
sub_group_by: string | null;
|
||||||
group_by: string | null;
|
group_by: string | null;
|
||||||
|
@ -105,6 +105,20 @@ export const BaseListRoot = observer((props: IBaseListRoot) => {
|
|||||||
[fetchNextIssues]
|
[fetchNextIssues]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const getPaginationData = useCallback(
|
||||||
|
(groupId?: string) => {
|
||||||
|
return issues?.getPaginationData(groupId, undefined);
|
||||||
|
},
|
||||||
|
[issues?.getPaginationData]
|
||||||
|
);
|
||||||
|
|
||||||
|
const getGroupIssueCount = useCallback(
|
||||||
|
(groupId?: string) => {
|
||||||
|
return issues?.getGroupIssueCount(groupId, undefined, false);
|
||||||
|
},
|
||||||
|
[issues?.getGroupIssueCount]
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<IssueLayoutHOC storeType={storeType} layout={EIssueLayoutTypes.LIST}>
|
<IssueLayoutHOC storeType={storeType} layout={EIssueLayoutTypes.LIST}>
|
||||||
<div className={`relative h-full w-full bg-custom-background-90`}>
|
<div className={`relative h-full w-full bg-custom-background-90`}>
|
||||||
@ -118,8 +132,8 @@ export const BaseListRoot = observer((props: IBaseListRoot) => {
|
|||||||
loadMoreIssues={loadMoreIssues}
|
loadMoreIssues={loadMoreIssues}
|
||||||
showEmptyGroup={showEmptyGroup}
|
showEmptyGroup={showEmptyGroup}
|
||||||
viewId={viewId}
|
viewId={viewId}
|
||||||
getPaginationData={issues.getPaginationData}
|
getPaginationData={getPaginationData}
|
||||||
getGroupIssueCount={issues.getGroupIssueCount}
|
getGroupIssueCount={getGroupIssueCount}
|
||||||
quickAddCallback={issues?.quickAddIssue}
|
quickAddCallback={issues?.quickAddIssue}
|
||||||
enableIssueQuickAdd={!!enableQuickAdd}
|
enableIssueQuickAdd={!!enableQuickAdd}
|
||||||
canEditProperties={canEditProperties}
|
canEditProperties={canEditProperties}
|
||||||
|
@ -161,7 +161,7 @@ export const AllIssueLayoutRoot: React.FC = observer(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const issueIds = groupedIssueIds[ALL_ISSUES];
|
const issueIds = groupedIssueIds[ALL_ISSUES];
|
||||||
const nextPageResults = getPaginationData(ALL_ISSUES)?.nextPageResults;
|
const nextPageResults = getPaginationData(ALL_ISSUES, undefined)?.nextPageResults;
|
||||||
|
|
||||||
const emptyStateType =
|
const emptyStateType =
|
||||||
(workspaceProjectIds ?? []).length > 0 ? `workspace-${globalViewId}` : EmptyStateType.WORKSPACE_NO_PROJECTS;
|
(workspaceProjectIds ?? []).length > 0 ? `workspace-${globalViewId}` : EmptyStateType.WORKSPACE_NO_PROJECTS;
|
||||||
|
@ -74,7 +74,7 @@ export const BaseSpreadsheetRoot = observer((props: IBaseSpreadsheetRoot) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const issueIds = issues.groupedIssueIds?.[ALL_ISSUES] ?? [];
|
const issueIds = issues.groupedIssueIds?.[ALL_ISSUES] ?? [];
|
||||||
const nextPageResults = issues.getPaginationData(ALL_ISSUES)?.nextPageResults;
|
const nextPageResults = issues.getPaginationData(ALL_ISSUES, undefined)?.nextPageResults;
|
||||||
|
|
||||||
const handleDisplayFiltersUpdate = useCallback(
|
const handleDisplayFiltersUpdate = useCallback(
|
||||||
(updatedDisplayFilter: Partial<IIssueDisplayFilterOptions>) => {
|
(updatedDisplayFilter: Partial<IIssueDisplayFilterOptions>) => {
|
||||||
|
@ -83,7 +83,7 @@ export class ArchivedIssues extends BaseIssuesStore implements IArchivedIssues {
|
|||||||
};
|
};
|
||||||
|
|
||||||
fetchNextIssues = async (workspaceSlug: string, projectId: string, groupId?: string, subGroupId?: string) => {
|
fetchNextIssues = async (workspaceSlug: string, projectId: string, groupId?: string, subGroupId?: string) => {
|
||||||
const cursorObject = this.getPaginationData(subGroupId ?? groupId);
|
const cursorObject = this.getPaginationData(groupId, subGroupId);
|
||||||
if (!this.paginationOptions || (cursorObject && !cursorObject?.nextPageResults)) return;
|
if (!this.paginationOptions || (cursorObject && !cursorObject?.nextPageResults)) return;
|
||||||
try {
|
try {
|
||||||
this.loader = "pagination";
|
this.loader = "pagination";
|
||||||
|
@ -135,7 +135,7 @@ export class CycleIssues extends BaseIssuesStore implements ICycleIssues {
|
|||||||
groupId?: string,
|
groupId?: string,
|
||||||
subGroupId?: string
|
subGroupId?: string
|
||||||
) => {
|
) => {
|
||||||
const cursorObject = this.getPaginationData(subGroupId ?? groupId);
|
const cursorObject = this.getPaginationData(groupId, subGroupId);
|
||||||
if (!this.paginationOptions || (cursorObject && !cursorObject?.nextPageResults)) return;
|
if (!this.paginationOptions || (cursorObject && !cursorObject?.nextPageResults)) return;
|
||||||
try {
|
try {
|
||||||
this.loader = "pagination";
|
this.loader = "pagination";
|
||||||
|
@ -80,7 +80,7 @@ export class DraftIssues extends BaseIssuesStore implements IDraftIssues {
|
|||||||
};
|
};
|
||||||
|
|
||||||
fetchNextIssues = async (workspaceSlug: string, projectId: string, groupId?: string, subGroupId?: string) => {
|
fetchNextIssues = async (workspaceSlug: string, projectId: string, groupId?: string, subGroupId?: string) => {
|
||||||
const cursorObject = this.getPaginationData(subGroupId ?? groupId);
|
const cursorObject = this.getPaginationData(groupId, subGroupId);
|
||||||
if (!this.paginationOptions || (cursorObject && !cursorObject?.nextPageResults)) return;
|
if (!this.paginationOptions || (cursorObject && !cursorObject?.nextPageResults)) return;
|
||||||
try {
|
try {
|
||||||
this.loader = "pagination";
|
this.loader = "pagination";
|
||||||
|
@ -58,8 +58,12 @@ export interface IBaseIssuesStore {
|
|||||||
issueDisplayFiltersDefaultData(groupBy: string | null): string[];
|
issueDisplayFiltersDefaultData(groupBy: string | null): string[];
|
||||||
issuesSortWithOrderBy(issueIds: string[], key: Partial<TIssueOrderByOptions>): string[];
|
issuesSortWithOrderBy(issueIds: string[], key: Partial<TIssueOrderByOptions>): string[];
|
||||||
getGroupArray(value: boolean | number | string | string[] | null, isDate?: boolean): string[];
|
getGroupArray(value: boolean | number | string | string[] | null, isDate?: boolean): string[];
|
||||||
getPaginationData(groupId: string | undefined): TPaginationData | undefined;
|
getPaginationData(groupId: string | undefined, subGroupId: string | undefined): TPaginationData | undefined;
|
||||||
getGroupIssueCount: (groupId: string | undefined) => number | undefined;
|
getGroupIssueCount: (
|
||||||
|
groupId: string | undefined,
|
||||||
|
subGroupId: string | undefined,
|
||||||
|
isSubGroupCumulative: boolean
|
||||||
|
) => number | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ISSUE_FILTER_DEFAULT_DATA: Record<TIssueDisplayFilterOptions, keyof TIssue> = {
|
const ISSUE_FILTER_DEFAULT_DATA: Record<TIssueDisplayFilterOptions, keyof TIssue> = {
|
||||||
@ -144,14 +148,20 @@ export class BaseIssuesStore implements IBaseIssuesStore {
|
|||||||
const displayFilters = this.issueFilterStore?.issueFilters?.displayFilters;
|
const displayFilters = this.issueFilterStore?.issueFilters?.displayFilters;
|
||||||
if (!displayFilters) return;
|
if (!displayFilters) return;
|
||||||
|
|
||||||
return displayFilters?.group_by;
|
const layout = displayFilters?.layout;
|
||||||
|
|
||||||
|
return layout === "calendar"
|
||||||
|
? "target_date"
|
||||||
|
: ["list", "kanban"]?.includes(layout)
|
||||||
|
? displayFilters?.group_by
|
||||||
|
: undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
get subGroupBy() {
|
get subGroupBy() {
|
||||||
const displayFilters = this.issueFilterStore?.issueFilters?.displayFilters;
|
const displayFilters = this.issueFilterStore?.issueFilters?.displayFilters;
|
||||||
if (!displayFilters || displayFilters.group_by === displayFilters.sub_group_by) return;
|
if (!displayFilters || displayFilters.group_by === displayFilters.sub_group_by) return;
|
||||||
|
|
||||||
return displayFilters?.sub_group_by;
|
return displayFilters?.layout === "kanban" ? displayFilters?.sub_group_by : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
get issueGroupKey() {
|
get issueGroupKey() {
|
||||||
@ -208,19 +218,22 @@ export class BaseIssuesStore implements IBaseIssuesStore {
|
|||||||
const issueGroupCount = groupedIssueCount[ALL_ISSUES];
|
const issueGroupCount = groupedIssueCount[ALL_ISSUES];
|
||||||
const issuesPath = [groupId];
|
const issuesPath = [groupId];
|
||||||
|
|
||||||
if (!subGroupId) {
|
if (subGroupId) issuesPath.push(subGroupId);
|
||||||
set(this.groupedIssueCount, [groupId], issueGroupCount);
|
|
||||||
}
|
set(this.groupedIssueCount, [this.getGroupKey(groupId, subGroupId)], issueGroupCount);
|
||||||
|
|
||||||
this.updateIssueGroup(issueGroup, issuesPath);
|
this.updateIssueGroup(issueGroup, issuesPath);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set(this.groupedIssueCount, [ALL_ISSUES], groupedIssueCount[ALL_ISSUES]);
|
||||||
|
|
||||||
for (const groupId in groupedIssues) {
|
for (const groupId in groupedIssues) {
|
||||||
const issueGroup = groupedIssues[groupId];
|
const issueGroup = groupedIssues[groupId];
|
||||||
const issueGroupCount = groupedIssueCount[groupId];
|
const issueGroupCount = groupedIssueCount[groupId];
|
||||||
|
|
||||||
set(this.groupedIssueCount, [groupId], issueGroupCount);
|
set(this.groupedIssueCount, [groupId], issueGroupCount);
|
||||||
|
|
||||||
const shouldContinue = this.updateIssueGroup(issueGroup, [groupId]);
|
const shouldContinue = this.updateIssueGroup(issueGroup, [groupId]);
|
||||||
if (shouldContinue) continue;
|
if (shouldContinue) continue;
|
||||||
|
|
||||||
@ -228,7 +241,7 @@ export class BaseIssuesStore implements IBaseIssuesStore {
|
|||||||
const issueSubGroup = (issueGroup as TGroupedIssues)[subGroupId];
|
const issueSubGroup = (issueGroup as TGroupedIssues)[subGroupId];
|
||||||
const issueSubGroupCount = groupedIssueCount[subGroupId];
|
const issueSubGroupCount = groupedIssueCount[subGroupId];
|
||||||
|
|
||||||
set(this.groupedIssueCount, [subGroupId], issueSubGroupCount);
|
set(this.groupedIssueCount, [this.getGroupKey(groupId, subGroupId)], issueSubGroupCount);
|
||||||
this.updateIssueGroup(issueSubGroup, [groupId, subGroupId]);
|
this.updateIssueGroup(issueSubGroup, [groupId, subGroupId]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -421,22 +434,23 @@ export class BaseIssuesStore implements IBaseIssuesStore {
|
|||||||
updateIssueCount(path: string[], increment: number) {
|
updateIssueCount(path: string[], increment: number) {
|
||||||
const [groupId, subGroupId] = path;
|
const [groupId, subGroupId] = path;
|
||||||
|
|
||||||
if (subGroupId) {
|
if (subGroupId && groupId) {
|
||||||
const subGroupIssueCount = get(this.groupedIssueCount, [subGroupId]);
|
const groupKey = this.getGroupKey(groupId, subGroupId);
|
||||||
|
const subGroupIssueCount = get(this.groupedIssueCount, groupKey);
|
||||||
|
|
||||||
set(this.groupedIssueCount, [subGroupId], subGroupIssueCount + increment);
|
set(this.groupedIssueCount, groupKey, subGroupIssueCount + increment);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (groupId) {
|
if (groupId) {
|
||||||
const groupIssueCount = get(this.groupedIssueCount, [groupId]);
|
const groupIssueCount = get(this.groupedIssueCount, [groupId]);
|
||||||
|
|
||||||
set(this.groupedIssueCount, [groupId], groupIssueCount + increment);
|
set(this.groupedIssueCount, groupId, groupIssueCount + increment);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (groupId !== ALL_ISSUES) {
|
if (groupId !== ALL_ISSUES) {
|
||||||
const totalIssueCount = get(this.groupedIssueCount, [ALL_ISSUES]);
|
const totalIssueCount = get(this.groupedIssueCount, [ALL_ISSUES]);
|
||||||
|
|
||||||
set(this.groupedIssueCount, [ALL_ISSUES], totalIssueCount + increment);
|
set(this.groupedIssueCount, ALL_ISSUES, totalIssueCount + increment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -909,6 +923,8 @@ export class BaseIssuesStore implements IBaseIssuesStore {
|
|||||||
const groupedIssues: TGroupedIssues | TSubGroupedIssues = {};
|
const groupedIssues: TGroupedIssues | TSubGroupedIssues = {};
|
||||||
const groupedIssueCount: TGroupedIssueCount = {};
|
const groupedIssueCount: TGroupedIssueCount = {};
|
||||||
|
|
||||||
|
set(groupedIssueCount, [ALL_ISSUES], issueResponse.total_count);
|
||||||
|
|
||||||
for (const groupId in issueResult) {
|
for (const groupId in issueResult) {
|
||||||
const groupIssuesObject = issueResult[groupId];
|
const groupIssuesObject = issueResult[groupId];
|
||||||
const groupIssueResult = groupIssuesObject?.results;
|
const groupIssueResult = groupIssuesObject?.results;
|
||||||
@ -933,7 +949,7 @@ export class BaseIssuesStore implements IBaseIssuesStore {
|
|||||||
|
|
||||||
if (!subGroupIssueResult) continue;
|
if (!subGroupIssueResult) continue;
|
||||||
|
|
||||||
set(groupedIssueCount, [subGroupId], subGroupIssuesObject.total_results);
|
set(groupedIssueCount, [this.getGroupKey(groupId, subGroupId)], subGroupIssuesObject.total_results);
|
||||||
|
|
||||||
if (Array.isArray(subGroupIssueResult)) {
|
if (Array.isArray(subGroupIssueResult)) {
|
||||||
issueList.push(...subGroupIssueResult);
|
issueList.push(...subGroupIssueResult);
|
||||||
@ -964,32 +980,39 @@ export class BaseIssuesStore implements IBaseIssuesStore {
|
|||||||
nextPageResults,
|
nextPageResults,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (groupId && subGroupId) {
|
set(this.issuePaginationData, [this.getGroupKey(groupId, subGroupId)], cursorObject);
|
||||||
set(this.issuePaginationData, [subGroupId], cursorObject);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (groupId) {
|
getGroupKey(groupId?: string, subGroupId?: string) {
|
||||||
set(this.issuePaginationData, [groupId], cursorObject);
|
if (groupId && subGroupId) return `${groupId}_${subGroupId}`;
|
||||||
return;
|
|
||||||
|
if (groupId) return groupId;
|
||||||
|
|
||||||
|
return ALL_ISSUES;
|
||||||
}
|
}
|
||||||
|
|
||||||
set(this.issuePaginationData, [ALL_ISSUES], cursorObject);
|
getPaginationData = computedFn(
|
||||||
|
(groupId: string | undefined, subGroupId: string | undefined): TPaginationData | undefined => {
|
||||||
|
return get(this.issuePaginationData, [this.getGroupKey(groupId, subGroupId)]);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
getGroupIssueCount = computedFn(
|
||||||
|
(
|
||||||
|
groupId: string | undefined,
|
||||||
|
subGroupId: string | undefined,
|
||||||
|
isSubGroupCumulative: boolean
|
||||||
|
): number | undefined => {
|
||||||
|
if (isSubGroupCumulative && subGroupId) {
|
||||||
|
const groupIssuesKeys = Object.keys(this.groupedIssueCount);
|
||||||
|
let subGroupCumulativeCount = 0;
|
||||||
|
|
||||||
|
for (const groupKey of groupIssuesKeys) {
|
||||||
|
if (groupKey.includes(subGroupId)) subGroupCumulativeCount += this.groupedIssueCount[groupKey];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getPaginationData = computedFn((groupId: string | undefined): TPaginationData | undefined => {
|
return get(this.groupedIssueCount, [this.getGroupKey(groupId, subGroupId)]);
|
||||||
if (groupId) {
|
|
||||||
return get(this.issuePaginationData, [groupId]);
|
|
||||||
}
|
}
|
||||||
|
);
|
||||||
return get(this.issuePaginationData, [ALL_ISSUES]);
|
|
||||||
});
|
|
||||||
|
|
||||||
getGroupIssueCount = computedFn((groupId: string | undefined): number | undefined => {
|
|
||||||
if (groupId) {
|
|
||||||
return get(this.groupedIssueCount, [groupId]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return get(this.groupedIssueCount, [ALL_ISSUES]);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ export class ModuleIssues extends BaseIssuesStore implements IModuleIssues {
|
|||||||
groupId?: string,
|
groupId?: string,
|
||||||
subGroupId?: string
|
subGroupId?: string
|
||||||
) => {
|
) => {
|
||||||
const cursorObject = this.getPaginationData(subGroupId ?? groupId);
|
const cursorObject = this.getPaginationData(groupId, subGroupId);
|
||||||
if (!this.paginationOptions || (cursorObject && !cursorObject?.nextPageResults)) return;
|
if (!this.paginationOptions || (cursorObject && !cursorObject?.nextPageResults)) return;
|
||||||
try {
|
try {
|
||||||
this.loader = "pagination";
|
this.loader = "pagination";
|
||||||
|
@ -122,7 +122,7 @@ export class ProfileIssues extends BaseIssuesStore implements IProfileIssues {
|
|||||||
};
|
};
|
||||||
|
|
||||||
fetchNextIssues = async (workspaceSlug: string, userId: string, groupId?: string, subGroupId?: string) => {
|
fetchNextIssues = async (workspaceSlug: string, userId: string, groupId?: string, subGroupId?: string) => {
|
||||||
const cursorObject = this.getPaginationData(subGroupId ?? groupId);
|
const cursorObject = this.getPaginationData(groupId, subGroupId);
|
||||||
if (!this.paginationOptions || (cursorObject && !cursorObject?.nextPageResults)) return;
|
if (!this.paginationOptions || (cursorObject && !cursorObject?.nextPageResults)) return;
|
||||||
try {
|
try {
|
||||||
this.loader = "pagination";
|
this.loader = "pagination";
|
||||||
|
@ -79,7 +79,7 @@ export class ProjectViewIssues extends BaseIssuesStore implements IProjectViewIs
|
|||||||
};
|
};
|
||||||
|
|
||||||
fetchNextIssues = async (workspaceSlug: string, projectId: string, groupId?: string, subGroupId?: string) => {
|
fetchNextIssues = async (workspaceSlug: string, projectId: string, groupId?: string, subGroupId?: string) => {
|
||||||
const cursorObject = this.getPaginationData(subGroupId ?? groupId);
|
const cursorObject = this.getPaginationData(groupId, subGroupId);
|
||||||
if (!this.paginationOptions || (cursorObject && !cursorObject?.nextPageResults)) return;
|
if (!this.paginationOptions || (cursorObject && !cursorObject?.nextPageResults)) return;
|
||||||
try {
|
try {
|
||||||
this.loader = "pagination";
|
this.loader = "pagination";
|
||||||
|
@ -82,7 +82,7 @@ export class ProjectIssues extends BaseIssuesStore implements IProjectIssues {
|
|||||||
};
|
};
|
||||||
|
|
||||||
fetchNextIssues = async (workspaceSlug: string, projectId: string, groupId?: string, subGroupId?: string) => {
|
fetchNextIssues = async (workspaceSlug: string, projectId: string, groupId?: string, subGroupId?: string) => {
|
||||||
const cursorObject = this.getPaginationData(subGroupId ?? groupId);
|
const cursorObject = this.getPaginationData(groupId, subGroupId);
|
||||||
if (!this.paginationOptions || (cursorObject && !cursorObject?.nextPageResults)) return;
|
if (!this.paginationOptions || (cursorObject && !cursorObject?.nextPageResults)) return;
|
||||||
try {
|
try {
|
||||||
this.loader = "pagination";
|
this.loader = "pagination";
|
||||||
|
@ -81,7 +81,7 @@ export class WorkspaceIssues extends BaseIssuesStore implements IWorkspaceIssues
|
|||||||
};
|
};
|
||||||
|
|
||||||
fetchNextIssues = async (workspaceSlug: string, viewId: string, groupId?: string, subGroupId?: string) => {
|
fetchNextIssues = async (workspaceSlug: string, viewId: string, groupId?: string, subGroupId?: string) => {
|
||||||
const cursorObject = this.getPaginationData(subGroupId ?? groupId);
|
const cursorObject = this.getPaginationData(groupId, subGroupId);
|
||||||
if (!this.paginationOptions || (cursorObject && !cursorObject?.nextPageResults)) return;
|
if (!this.paginationOptions || (cursorObject && !cursorObject?.nextPageResults)) return;
|
||||||
try {
|
try {
|
||||||
this.loader = "pagination";
|
this.loader = "pagination";
|
||||||
|
Loading…
Reference in New Issue
Block a user