Editing of the project's Kariz page
This commit is contained in:
@@ -108,6 +108,7 @@ export class ProjectCardsExcelService {
|
||||
async import(actor: Actor, file: Express.Multer.File): Promise<ImportContactsResult> {
|
||||
const rows = await readMappedRows(file, CASE_ALIASES);
|
||||
const result: ImportContactsResult = { created: 0, skipped: 0, errors: [] };
|
||||
const affected = new Map<string, string>();
|
||||
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
const row = rows[i]!;
|
||||
@@ -122,12 +123,13 @@ export class ProjectCardsExcelService {
|
||||
}
|
||||
|
||||
try {
|
||||
const { boardId, stageId } = await this.resolveBoardAndStage(
|
||||
const { boardId, stageId, boardName } = await this.resolveBoardAndStage(
|
||||
actor.organizationId,
|
||||
row.boardName,
|
||||
row.stageName,
|
||||
isClosedStatus(row.status),
|
||||
);
|
||||
affected.set(boardId, boardName);
|
||||
const duplicate = await this.prisma.projectCard.findFirst({
|
||||
where: { organizationId: actor.organizationId, boardId, title },
|
||||
select: { id: true },
|
||||
@@ -165,6 +167,12 @@ export class ProjectCardsExcelService {
|
||||
}
|
||||
}
|
||||
|
||||
const entries = [...affected.entries()];
|
||||
if (entries[0]) {
|
||||
result.boardId = entries[0][0];
|
||||
result.boards = entries.map(([, n]) => n);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -204,19 +212,19 @@ export class ProjectCardsExcelService {
|
||||
const existing = board.stages.find(
|
||||
(s) => s.name.trim().toLowerCase() === wanted.toLowerCase(),
|
||||
);
|
||||
if (existing) return { boardId: board.id, stageId: existing.id };
|
||||
if (existing) return { boardId: board.id, stageId: existing.id, boardName: board.name };
|
||||
const maxPos = board.stages.reduce((m, s) => Math.max(m, s.position), -1);
|
||||
const stage = await this.prisma.projectBoardStage.create({
|
||||
data: { boardId: board.id, name: wanted, position: maxPos + 1 },
|
||||
});
|
||||
return { boardId: board.id, stageId: stage.id };
|
||||
return { boardId: board.id, stageId: stage.id, boardName: board.name };
|
||||
}
|
||||
|
||||
const stage = closed
|
||||
? board.stages[board.stages.length - 1]
|
||||
: board.stages[0];
|
||||
if (!stage) throw new Error('برد مرحلهای ندارد');
|
||||
return { boardId: board.id, stageId: stage.id };
|
||||
return { boardId: board.id, stageId: stage.id, boardName: board.name };
|
||||
}
|
||||
|
||||
private async findPersonId(organizationId: string, row: Record<string, string>) {
|
||||
|
||||
Reference in New Issue
Block a user