mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
fix issue mutation and count (#4804)
This commit is contained in:
parent
ab3a00dd6e
commit
d75e33ccf0
@ -137,21 +137,15 @@ export const getDifference = (
|
|||||||
const DELETE = [];
|
const DELETE = [];
|
||||||
|
|
||||||
// For all the current issues values that are not in the previous array, Add them to the ADD array
|
// For all the current issues values that are not in the previous array, Add them to the ADD array
|
||||||
if (isEmpty(current)) ADD.push("None");
|
for (const currentValue of current) {
|
||||||
else {
|
if (previous.includes(currentValue)) continue;
|
||||||
for (const currentValue of current) {
|
ADD.push(currentValue);
|
||||||
if (previous.includes(currentValue)) continue;
|
|
||||||
ADD.push(currentValue);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// For all the previous issues values that are not in the current array, Add them to the ADD array
|
// For all the previous issues values that are not in the current array, Add them to the ADD array
|
||||||
if (isEmpty(previous)) DELETE.push("None");
|
for (const previousValue of previous) {
|
||||||
else {
|
if (current.includes(previousValue)) continue;
|
||||||
for (const previousValue of previous) {
|
DELETE.push(previousValue);
|
||||||
if (current.includes(previousValue)) continue;
|
|
||||||
DELETE.push(previousValue);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if there are no action provided, return the arrays
|
// if there are no action provided, return the arrays
|
||||||
@ -159,8 +153,8 @@ export const getDifference = (
|
|||||||
|
|
||||||
// If there is an action provided, return the values of both arrays under that array
|
// If there is an action provided, return the values of both arrays under that array
|
||||||
if (action === EIssueGroupedAction.ADD)
|
if (action === EIssueGroupedAction.ADD)
|
||||||
return { [EIssueGroupedAction.ADD]: uniq([...ADD, ...DELETE]), [EIssueGroupedAction.DELETE]: [] };
|
return { [EIssueGroupedAction.ADD]: uniq([...ADD]), [EIssueGroupedAction.DELETE]: [] };
|
||||||
else return { [EIssueGroupedAction.DELETE]: uniq([...ADD, ...DELETE]), [EIssueGroupedAction.ADD]: [] };
|
else return { [EIssueGroupedAction.DELETE]: uniq([...DELETE]), [EIssueGroupedAction.ADD]: [] };
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,6 +45,7 @@ import {
|
|||||||
getSubGroupIssueKeyActions,
|
getSubGroupIssueKeyActions,
|
||||||
} from "./base-issues-utils";
|
} from "./base-issues-utils";
|
||||||
import { convertToISODateString } from "@/helpers/date-time.helper";
|
import { convertToISODateString } from "@/helpers/date-time.helper";
|
||||||
|
import isEmpty from "lodash/isEmpty";
|
||||||
|
|
||||||
export type TIssueDisplayFilterOptions = Exclude<TIssueGroupByOptions, null> | "target_date";
|
export type TIssueDisplayFilterOptions = Exclude<TIssueGroupByOptions, null> | "target_date";
|
||||||
|
|
||||||
@ -413,7 +414,7 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore {
|
|||||||
let subGroupCumulativeCount = 0;
|
let subGroupCumulativeCount = 0;
|
||||||
|
|
||||||
for (const groupKey of groupIssuesKeys) {
|
for (const groupKey of groupIssuesKeys) {
|
||||||
if (groupKey.includes(subGroupId)) subGroupCumulativeCount += this.groupedIssueCount[groupKey];
|
if (groupKey.includes(`_${subGroupId}`)) subGroupCumulativeCount += this.groupedIssueCount[groupKey];
|
||||||
}
|
}
|
||||||
|
|
||||||
return subGroupCumulativeCount;
|
return subGroupCumulativeCount;
|
||||||
@ -1130,7 +1131,7 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore {
|
|||||||
*/
|
*/
|
||||||
removeIssueFromList(issueId: string) {
|
removeIssueFromList(issueId: string) {
|
||||||
const issue = this.rootIssueStore.issues.getIssueById(issueId);
|
const issue = this.rootIssueStore.issues.getIssueById(issueId);
|
||||||
this.updateIssueList(issue, undefined, EIssueGroupedAction.DELETE);
|
this.updateIssueList(undefined, issue, EIssueGroupedAction.DELETE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1148,7 +1149,12 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore {
|
|||||||
issueBeforeUpdate?: TIssue,
|
issueBeforeUpdate?: TIssue,
|
||||||
action?: EIssueGroupedAction.ADD | EIssueGroupedAction.DELETE
|
action?: EIssueGroupedAction.ADD | EIssueGroupedAction.DELETE
|
||||||
) {
|
) {
|
||||||
if (!issue) return;
|
if (!issue && !issueBeforeUpdate) return;
|
||||||
|
|
||||||
|
// get Issue ID from one of the issue objects
|
||||||
|
const issueId = issue?.id ?? issueBeforeUpdate?.id;
|
||||||
|
if (!issueId) return;
|
||||||
|
|
||||||
// get issueUpdates from another method by passing down the three arguments
|
// get issueUpdates from another method by passing down the three arguments
|
||||||
// issueUpdates is nothing but an array of objects that contain the path of the issueId list that need updating and also the action that needs to be performed at the path
|
// issueUpdates is nothing but an array of objects that contain the path of the issueId list that need updating and also the action that needs to be performed at the path
|
||||||
const issueUpdates = this.getUpdateDetails(issue, issueBeforeUpdate, action);
|
const issueUpdates = this.getUpdateDetails(issue, issueBeforeUpdate, action);
|
||||||
@ -1160,7 +1166,7 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore {
|
|||||||
if (issueUpdate.action === EIssueGroupedAction.ADD) {
|
if (issueUpdate.action === EIssueGroupedAction.ADD) {
|
||||||
// add issue Id at the path
|
// add issue Id at the path
|
||||||
update(this, ["groupedIssueIds", ...issueUpdate.path], (issueIds: string[] = []) => {
|
update(this, ["groupedIssueIds", ...issueUpdate.path], (issueIds: string[] = []) => {
|
||||||
return this.issuesSortWithOrderBy(uniq(concat(issueIds, issue.id)), this.orderBy);
|
return this.issuesSortWithOrderBy(uniq(concat(issueIds, issueId)), this.orderBy);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1168,7 +1174,7 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore {
|
|||||||
if (issueUpdate.action === EIssueGroupedAction.DELETE) {
|
if (issueUpdate.action === EIssueGroupedAction.DELETE) {
|
||||||
// remove issue Id from the path
|
// remove issue Id from the path
|
||||||
update(this, ["groupedIssueIds", ...issueUpdate.path], (issueIds: string[] = []) => {
|
update(this, ["groupedIssueIds", ...issueUpdate.path], (issueIds: string[] = []) => {
|
||||||
return pull(issueIds, issue.id);
|
return pull(issueIds, issueId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1455,7 +1461,7 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore {
|
|||||||
* @returns an array of object that contains the path at which issue to be updated and the action to be performed at the path
|
* @returns an array of object that contains the path at which issue to be updated and the action to be performed at the path
|
||||||
*/
|
*/
|
||||||
getUpdateDetails = (
|
getUpdateDetails = (
|
||||||
issue: Partial<TIssue>,
|
issue?: Partial<TIssue>,
|
||||||
issueBeforeUpdate?: Partial<TIssue>,
|
issueBeforeUpdate?: Partial<TIssue>,
|
||||||
action?: EIssueGroupedAction.ADD | EIssueGroupedAction.DELETE
|
action?: EIssueGroupedAction.ADD | EIssueGroupedAction.DELETE
|
||||||
): { path: string[]; action: EIssueGroupedAction }[] => {
|
): { path: string[]; action: EIssueGroupedAction }[] => {
|
||||||
@ -1466,8 +1472,8 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore {
|
|||||||
|
|
||||||
// if grouped, the get the Difference between the two issue properties (this.issueGroupKey) on which groupBy is performed
|
// if grouped, the get the Difference between the two issue properties (this.issueGroupKey) on which groupBy is performed
|
||||||
const groupActionsArray = getDifference(
|
const groupActionsArray = getDifference(
|
||||||
this.getArrayStringArray(issue[this.issueGroupKey], this.groupBy),
|
this.getArrayStringArray(issue, issue?.[this.issueGroupKey], this.groupBy),
|
||||||
this.getArrayStringArray(issueBeforeUpdate?.[this.issueGroupKey], this.groupBy),
|
this.getArrayStringArray(issueBeforeUpdate, issueBeforeUpdate?.[this.issueGroupKey], this.groupBy),
|
||||||
action
|
action
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1483,8 +1489,8 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore {
|
|||||||
|
|
||||||
// if subGrouped, the get the Difference between the two issue properties (this.issueGroupKey) on which subGroupBy is performed
|
// if subGrouped, the get the Difference between the two issue properties (this.issueGroupKey) on which subGroupBy is performed
|
||||||
const subGroupActionsArray = getDifference(
|
const subGroupActionsArray = getDifference(
|
||||||
this.getArrayStringArray(issue[this.issueSubGroupKey], this.subGroupBy),
|
this.getArrayStringArray(issue, issue?.[this.issueSubGroupKey], this.subGroupBy),
|
||||||
this.getArrayStringArray(issueBeforeUpdate?.[this.issueSubGroupKey], this.subGroupBy),
|
this.getArrayStringArray(issueBeforeUpdate, issueBeforeUpdate?.[this.issueSubGroupKey], this.subGroupBy),
|
||||||
action
|
action
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1493,13 +1499,10 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore {
|
|||||||
...getSubGroupIssueKeyActions(
|
...getSubGroupIssueKeyActions(
|
||||||
groupActionsArray,
|
groupActionsArray,
|
||||||
subGroupActionsArray,
|
subGroupActionsArray,
|
||||||
this.getArrayStringArray(issueBeforeUpdate?.[this.issueGroupKey] ?? issue[this.issueGroupKey], this.groupBy),
|
this.getArrayStringArray(issueBeforeUpdate, issueBeforeUpdate?.[this.issueGroupKey], this.groupBy),
|
||||||
this.getArrayStringArray(issue[this.issueGroupKey], this.groupBy),
|
this.getArrayStringArray(issue, issue?.[this.issueGroupKey], this.groupBy),
|
||||||
this.getArrayStringArray(
|
this.getArrayStringArray(issueBeforeUpdate, issueBeforeUpdate?.[this.issueSubGroupKey], this.subGroupBy),
|
||||||
issueBeforeUpdate?.[this.issueSubGroupKey] ?? issue[this.issueSubGroupKey],
|
this.getArrayStringArray(issue, issue?.[this.issueSubGroupKey], this.subGroupBy)
|
||||||
this.subGroupBy
|
|
||||||
),
|
|
||||||
this.getArrayStringArray(issue[this.issueSubGroupKey], this.subGroupBy)
|
|
||||||
),
|
),
|
||||||
...orderByUpdates,
|
...orderByUpdates,
|
||||||
];
|
];
|
||||||
@ -1529,7 +1532,7 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore {
|
|||||||
|
|
||||||
// if they are grouped then identify the paths based on props on which group by is dependent on
|
// if they are grouped then identify the paths based on props on which group by is dependent on
|
||||||
const issueKeyActions: { path: string[]; action: EIssueGroupedAction.REORDER }[] = [];
|
const issueKeyActions: { path: string[]; action: EIssueGroupedAction.REORDER }[] = [];
|
||||||
const groupByValues = this.getArrayStringArray(issue[this.issueGroupKey]);
|
const groupByValues = this.getArrayStringArray(issue, issue[this.issueGroupKey]);
|
||||||
|
|
||||||
// if issues are not subGrouped then, provide path from groupByValues
|
// if issues are not subGrouped then, provide path from groupByValues
|
||||||
if (!this.issueSubGroupKey) {
|
if (!this.issueSubGroupKey) {
|
||||||
@ -1541,7 +1544,7 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if they are grouped then identify the paths based on props on which sub group by is dependent on
|
// if they are grouped then identify the paths based on props on which sub group by is dependent on
|
||||||
const subGroupByValues = this.getArrayStringArray(issue[this.issueSubGroupKey]);
|
const subGroupByValues = this.getArrayStringArray(issue, issue[this.issueSubGroupKey]);
|
||||||
|
|
||||||
// if issues are subGrouped then, provide path from subGroupByValues
|
// if issues are subGrouped then, provide path from subGroupByValues
|
||||||
for (const groupKey of groupByValues) {
|
for (const groupKey of groupByValues) {
|
||||||
@ -1560,11 +1563,14 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore {
|
|||||||
* @returns an array of issue property values
|
* @returns an array of issue property values
|
||||||
*/
|
*/
|
||||||
getArrayStringArray = (
|
getArrayStringArray = (
|
||||||
|
issueObject: Partial<TIssue> | undefined,
|
||||||
value: string | string[] | undefined | null,
|
value: string | string[] | undefined | null,
|
||||||
groupByKey?: TIssueGroupByOptions | undefined
|
groupByKey?: TIssueGroupByOptions | undefined
|
||||||
): string[] => {
|
): string[] => {
|
||||||
// if value is not defined, return empty array
|
// if issue object is undefined return empty array
|
||||||
if (!value) return [];
|
if (!issueObject) return [];
|
||||||
|
// if value is not defined, return None value in array
|
||||||
|
if (!value || isEmpty(value)) return ["None"];
|
||||||
// if array return the array
|
// if array return the array
|
||||||
if (Array.isArray(value)) return value;
|
if (Array.isArray(value)) return value;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user