fix module Quick add (#5039)
This commit is contained in:
parent
9717497b4e
commit
f1496e3144
2 changed files with 38 additions and 1 deletions
|
|
@ -1041,6 +1041,43 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* add Modules to Array in a non optimistic way while creating issues
|
||||
* @param workspaceSlug
|
||||
* @param projectId
|
||||
* @param issueId
|
||||
* @param moduleIds array of modules to be added
|
||||
*/
|
||||
async addModulesToIssue(workspaceSlug: string, projectId: string, issueId: string, moduleIds: string[]) {
|
||||
// keep a copy of the original module ids
|
||||
const originalModuleIds = get(this.rootIssueStore.issues.issuesMap, [issueId, "module_ids"]) ?? [];
|
||||
try {
|
||||
//Perform API call
|
||||
await this.moduleService.addModulesToIssue(workspaceSlug, projectId, issueId, {
|
||||
modules: moduleIds,
|
||||
removed_modules: [],
|
||||
});
|
||||
|
||||
runInAction(() => {
|
||||
// get current Module Ids of the issue
|
||||
let currentModuleIds = [...originalModuleIds];
|
||||
|
||||
// If current Module Id is included in the modules list, then add Issue to List
|
||||
if (moduleIds.includes(this.moduleId ?? "")) this.addIssueToList(issueId);
|
||||
currentModuleIds = uniq(concat([...currentModuleIds], moduleIds));
|
||||
|
||||
// For current Issue, update module Ids by calling current store's update Issue, without making an API call
|
||||
this.updateIssue(workspaceSlug, projectId, issueId, { module_ids: currentModuleIds }, false);
|
||||
});
|
||||
|
||||
if (moduleIds.includes(this.moduleId ?? "")) {
|
||||
this.fetchParentStats(workspaceSlug, projectId);
|
||||
}
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* change modules array in issue
|
||||
* @param workspaceSlug
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ export class ModuleIssues extends BaseIssuesStore implements IModuleIssues {
|
|||
try {
|
||||
const response = await super.createIssue(workspaceSlug, projectId, data, moduleId, false);
|
||||
const moduleIds = data.module_ids && data.module_ids.length > 1 ? data.module_ids : [moduleId];
|
||||
await this.changeModulesInIssue(workspaceSlug, projectId, response.id, moduleIds, []);
|
||||
await this.addModulesToIssue(workspaceSlug, projectId, response.id, moduleIds);
|
||||
|
||||
return response;
|
||||
} catch (error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue