add functionality for addition of existing issues to modules and cycles (#2913)
Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
This commit is contained in:
parent
accdd02ce7
commit
03387848fe
35 changed files with 259 additions and 125 deletions
|
|
@ -28,6 +28,7 @@ export interface IProfileIssuesStore {
|
|||
workspaceSlug: string,
|
||||
userId: string,
|
||||
loadType: TLoader,
|
||||
_?: string,
|
||||
type?: "assigned" | "created" | "subscribed"
|
||||
) => Promise<IIssueResponse>;
|
||||
createIssue: (workspaceSlug: string, userId: string, data: Partial<IIssue>) => Promise<IIssue | undefined>;
|
||||
|
|
@ -138,6 +139,7 @@ export class ProfileIssuesStore extends IssueBaseStore implements IProfileIssues
|
|||
workspaceSlug: string,
|
||||
userId: string,
|
||||
loadType: TLoader = "init-loader",
|
||||
_?: string,
|
||||
type?: "assigned" | "created" | "subscribed"
|
||||
) => {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { IssueBaseStore } from "store/issues";
|
|||
import { IssueService } from "services/issue";
|
||||
import { CycleService } from "services/cycle.service";
|
||||
// types
|
||||
import { TIssueGroupByOptions } from "types";
|
||||
import { CycleIssueResponse, TIssueGroupByOptions } from "types";
|
||||
import { IIssue } from "types/issues";
|
||||
import { IIssueResponse, TLoader, IGroupedIssues, ISubGroupedIssues, TUnGroupedIssues, ViewFlags } from "../../types";
|
||||
import { RootStore } from "store/root";
|
||||
|
|
@ -49,7 +49,12 @@ export interface ICycleIssuesStore {
|
|||
data: IIssue,
|
||||
cycleId?: string | undefined
|
||||
) => Promise<IIssue | undefined>;
|
||||
addIssueToCycle: (workspaceSlug: string, projectId: string, cycleId: string, data: IIssue) => Promise<IIssue>;
|
||||
addIssueToCycle: (
|
||||
workspaceSlug: string,
|
||||
cycleId: string,
|
||||
issueIds: string[],
|
||||
fetchAfterAddition?: boolean
|
||||
) => Promise<IIssue>;
|
||||
removeIssueFromCycle: (
|
||||
workspaceSlug: string,
|
||||
projectId: string,
|
||||
|
|
@ -70,6 +75,9 @@ export class CycleIssuesStore extends IssueBaseStore implements ICycleIssuesStor
|
|||
cycleService;
|
||||
issueService;
|
||||
|
||||
//projectId
|
||||
currentProjectId: string | undefined;
|
||||
|
||||
//viewData
|
||||
viewFlags = {
|
||||
enableQuickAdd: true,
|
||||
|
|
@ -157,6 +165,8 @@ export class CycleIssuesStore extends IssueBaseStore implements ICycleIssuesStor
|
|||
try {
|
||||
this.loader = loadType;
|
||||
|
||||
this.currentProjectId = projectId;
|
||||
|
||||
const params = this.rootStore?.cycleIssuesFilter?.appliedFilters;
|
||||
const response = await this.cycleService.getV3CycleIssues(workspaceSlug, projectId, cycleId, params);
|
||||
|
||||
|
|
@ -185,7 +195,16 @@ export class CycleIssuesStore extends IssueBaseStore implements ICycleIssuesStor
|
|||
|
||||
try {
|
||||
const response = await this.rootStore.projectIssues.createIssue(workspaceSlug, projectId, data);
|
||||
const issueToCycle = await this.addIssueToCycle(workspaceSlug, projectId, cycleId, response);
|
||||
const issueToCycle = await this.addIssueToCycle(workspaceSlug, cycleId, [response.id], false);
|
||||
|
||||
let _issues = this.issues;
|
||||
if (!_issues) _issues = {};
|
||||
if (!_issues[cycleId]) _issues[cycleId] = {};
|
||||
_issues[cycleId] = { ..._issues[cycleId], ...{ [response.id]: response } };
|
||||
|
||||
runInAction(() => {
|
||||
this.issues = _issues;
|
||||
});
|
||||
|
||||
return issueToCycle;
|
||||
} catch (error) {
|
||||
|
|
@ -287,24 +306,19 @@ export class CycleIssuesStore extends IssueBaseStore implements ICycleIssuesStor
|
|||
}
|
||||
};
|
||||
|
||||
addIssueToCycle = async (workspaceSlug: string, projectId: string, cycleId: string, data: IIssue) => {
|
||||
addIssueToCycle = async (workspaceSlug: string, cycleId: string, issueIds: string[], fetchAfterAddition = true) => {
|
||||
if (!this.currentProjectId) return;
|
||||
|
||||
try {
|
||||
const issueToCycle = await this.issueService.addIssueToCycle(workspaceSlug, projectId, cycleId, {
|
||||
issues: [data.id],
|
||||
const issueToCycle = await this.issueService.addIssueToCycle(workspaceSlug, this.currentProjectId, cycleId, {
|
||||
issues: issueIds,
|
||||
});
|
||||
|
||||
let _issues = this.issues;
|
||||
if (!_issues) _issues = {};
|
||||
if (!_issues[cycleId]) _issues[cycleId] = {};
|
||||
_issues[cycleId] = { ..._issues[cycleId], ...{ [data.id]: data } };
|
||||
|
||||
runInAction(() => {
|
||||
this.issues = _issues;
|
||||
});
|
||||
if (fetchAfterAddition) this.fetchIssues(workspaceSlug, this.currentProjectId, "mutation", cycleId);
|
||||
|
||||
return issueToCycle;
|
||||
} catch (error) {
|
||||
this.fetchIssues(workspaceSlug, projectId, "mutation", cycleId);
|
||||
this.fetchIssues(workspaceSlug, this.currentProjectId, "mutation", cycleId);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -49,7 +49,12 @@ export interface IModuleIssuesStore {
|
|||
data: IIssue,
|
||||
moduleId?: string | undefined
|
||||
) => Promise<IIssue | undefined>;
|
||||
addIssueToModule: (workspaceSlug: string, projectId: string, moduleId: string, data: IIssue) => Promise<IIssue>;
|
||||
addIssueToModule: (
|
||||
workspaceSlug: string,
|
||||
moduleId: string,
|
||||
issueIds: string[],
|
||||
fetchAfterAddition?: boolean
|
||||
) => Promise<IIssue>;
|
||||
removeIssueFromModule: (
|
||||
workspaceSlug: string,
|
||||
projectId: string,
|
||||
|
|
@ -70,6 +75,8 @@ export class ModuleIssuesStore extends IssueBaseStore implements IModuleIssuesSt
|
|||
moduleService;
|
||||
issueService;
|
||||
|
||||
currentProjectId: string | undefined;
|
||||
|
||||
//viewData
|
||||
viewFlags = {
|
||||
enableQuickAdd: true,
|
||||
|
|
@ -154,6 +161,7 @@ export class ModuleIssuesStore extends IssueBaseStore implements IModuleIssuesSt
|
|||
) => {
|
||||
if (!moduleId) return undefined;
|
||||
|
||||
this.currentProjectId = projectId;
|
||||
try {
|
||||
this.loader = loadType;
|
||||
|
||||
|
|
@ -185,7 +193,16 @@ export class ModuleIssuesStore extends IssueBaseStore implements IModuleIssuesSt
|
|||
|
||||
try {
|
||||
const response = await this.rootStore.projectIssues.createIssue(workspaceSlug, projectId, data);
|
||||
const issueToModule = await this.addIssueToModule(workspaceSlug, projectId, moduleId, response);
|
||||
const issueToModule = await this.addIssueToModule(workspaceSlug, moduleId, [response.id], false);
|
||||
|
||||
let _issues = this.issues;
|
||||
if (!_issues) _issues = {};
|
||||
if (!_issues[moduleId]) _issues[moduleId] = {};
|
||||
_issues[moduleId] = { ..._issues[moduleId], ...{ [response.id]: response } };
|
||||
|
||||
runInAction(() => {
|
||||
this.issues = _issues;
|
||||
});
|
||||
|
||||
return issueToModule;
|
||||
} catch (error) {
|
||||
|
|
@ -289,24 +306,19 @@ export class ModuleIssuesStore extends IssueBaseStore implements IModuleIssuesSt
|
|||
}
|
||||
};
|
||||
|
||||
addIssueToModule = async (workspaceSlug: string, projectId: string, moduleId: string, data: IIssue) => {
|
||||
addIssueToModule = async (workspaceSlug: string, moduleId: string, issueIds: string[], fetchAfterAddition = true) => {
|
||||
if (!this.currentProjectId) return;
|
||||
|
||||
try {
|
||||
const issueToModule = await this.moduleService.addIssuesToModule(workspaceSlug, projectId, moduleId, {
|
||||
issues: [data.id],
|
||||
const issueToModule = await this.moduleService.addIssuesToModule(workspaceSlug, this.currentProjectId, moduleId, {
|
||||
issues: issueIds,
|
||||
});
|
||||
|
||||
let _issues = this.issues;
|
||||
if (!_issues) _issues = {};
|
||||
if (!_issues[moduleId]) _issues[moduleId] = {};
|
||||
_issues[moduleId] = { ..._issues[moduleId], ...{ [data.id]: data } };
|
||||
|
||||
runInAction(() => {
|
||||
this.issues = _issues;
|
||||
});
|
||||
if (fetchAfterAddition) this.fetchIssues(workspaceSlug, this.currentProjectId, "mutation", moduleId);
|
||||
|
||||
return issueToModule;
|
||||
} catch (error) {
|
||||
this.fetchIssues(workspaceSlug, projectId, "mutation", moduleId);
|
||||
this.fetchIssues(workspaceSlug, this.currentProjectId, "mutation", moduleId);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue