This commit is contained in:
@@ -0,0 +1,15 @@
|
|||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class AddAttachmentsToTaskComment1784900000000 implements MigrationInterface {
|
||||||
|
name = "AddAttachmentsToTaskComment1784900000000";
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "tm_task_comments" ADD "attachments" json NOT NULL DEFAULT '[]'`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE "tm_task_comments" DROP COLUMN "attachments"`);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@ import { UserDec } from "../../../common/decorators/user.decorator";
|
|||||||
import { AuthGuards } from "../../../common/decorators/auth-guard.decorator";
|
import { AuthGuards } from "../../../common/decorators/auth-guard.decorator";
|
||||||
import { ParamDto } from "../../../common/DTO/param.dto";
|
import { ParamDto } from "../../../common/DTO/param.dto";
|
||||||
import { ITokenPayload } from "../../auth/interfaces/IToken-payload";
|
import { ITokenPayload } from "../../auth/interfaces/IToken-payload";
|
||||||
|
import { User } from "../../users/entities/user.entity";
|
||||||
|
|
||||||
@AuthGuards()
|
@AuthGuards()
|
||||||
@AdminRoute()
|
@AdminRoute()
|
||||||
@@ -80,4 +81,11 @@ export class ProjectController {
|
|||||||
getProjectDetail(@Param() paramDto: ParamDto, @UserDec() user: ITokenPayload): Promise<TMProject | null> {
|
getProjectDetail(@Param() paramDto: ParamDto, @UserDec() user: ITokenPayload): Promise<TMProject | null> {
|
||||||
return this.projectService.getProjectDetail(paramDto.id, user.id, user.permissions);
|
return this.projectService.getProjectDetail(paramDto.id, user.id, user.permissions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Get(":id/users")
|
||||||
|
@ApiOperation({ summary: "Get project users" })
|
||||||
|
@ApiResponse({ status: 200, description: "Got Project Users Successfully!" })
|
||||||
|
getProjectUsers(@Param() paramDto: ParamDto): Promise<User[]> {
|
||||||
|
return this.projectService.getProjectUsers(paramDto.id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { ApiProperty } from "@nestjs/swagger";
|
import { ApiProperty } from "@nestjs/swagger";
|
||||||
import { IsString, IsNotEmpty, IsUUID } from "class-validator";
|
import { IsString, IsNotEmpty, IsUUID, IsOptional, IsArray } from "class-validator";
|
||||||
|
|
||||||
export class CreateTaskCommentDto {
|
export class CreateTaskCommentDto {
|
||||||
@ApiProperty({ description: "Comment content", example: "Please review this task before closing." })
|
@ApiProperty({ description: "Comment content", example: "Please review this task before closing." })
|
||||||
@@ -11,4 +11,15 @@ export class CreateTaskCommentDto {
|
|||||||
@IsUUID()
|
@IsUUID()
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
taskId: string;
|
taskId: string;
|
||||||
|
|
||||||
|
@ApiProperty({
|
||||||
|
description: "Attachment file URLs or paths",
|
||||||
|
type: [String],
|
||||||
|
required: false,
|
||||||
|
example: ["https://cdn.example.com/files/screenshot.png"],
|
||||||
|
})
|
||||||
|
@IsOptional()
|
||||||
|
@IsArray()
|
||||||
|
@IsString({ each: true })
|
||||||
|
attachments?: string[];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ export class TMTaskComment extends BaseEntity {
|
|||||||
@Column({ type: "text" })
|
@Column({ type: "text" })
|
||||||
content: string;
|
content: string;
|
||||||
|
|
||||||
|
@Column({ type: "json", default: [] })
|
||||||
|
attachments: string[];
|
||||||
|
|
||||||
// --- Relations ---
|
// --- Relations ---
|
||||||
|
|
||||||
@ManyToOne(() => User, {
|
@ManyToOne(() => User, {
|
||||||
@@ -30,3 +33,4 @@ export class TMTaskComment extends BaseEntity {
|
|||||||
@Column({ type: "uuid" })
|
@Column({ type: "uuid" })
|
||||||
taskId: string;
|
taskId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ export class ProjectService {
|
|||||||
users: {
|
users: {
|
||||||
id: true,
|
id: true,
|
||||||
firstName: true,
|
firstName: true,
|
||||||
lastName: true
|
lastName: true,
|
||||||
|
profilePic: true,
|
||||||
},
|
},
|
||||||
taskPhases: {
|
taskPhases: {
|
||||||
id: true,
|
id: true,
|
||||||
@@ -165,4 +166,9 @@ export class ProjectService {
|
|||||||
|
|
||||||
return projectDetail;
|
return projectDetail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getProjectUsers(projectId: string): Promise<User[]> {
|
||||||
|
const project = await this.findOneOrFail(projectId);
|
||||||
|
return project.users;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ export class TaskCommentService {
|
|||||||
|
|
||||||
const comment = this.taskCommentRepository.create({
|
const comment = this.taskCommentRepository.create({
|
||||||
...dto,
|
...dto,
|
||||||
|
attachments: dto.attachments ?? [],
|
||||||
userId,
|
userId,
|
||||||
});
|
});
|
||||||
return this.taskCommentRepository.save(comment);
|
return this.taskCommentRepository.save(comment);
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ export class TaskRepository extends Repository<TMTask> {
|
|||||||
"user.id",
|
"user.id",
|
||||||
"user.firstName",
|
"user.firstName",
|
||||||
"user.lastName",
|
"user.lastName",
|
||||||
|
"user.profilePic",
|
||||||
|
|
||||||
"ticket.id",
|
"ticket.id",
|
||||||
"ticket.subject",
|
"ticket.subject",
|
||||||
@@ -64,10 +65,11 @@ export class TaskRepository extends Repository<TMTask> {
|
|||||||
|
|
||||||
"comment.id",
|
"comment.id",
|
||||||
"comment.content",
|
"comment.content",
|
||||||
|
"comment.attachments",
|
||||||
"comment.createdAt",
|
"comment.createdAt",
|
||||||
"commentUser.firstName",
|
"commentUser.firstName",
|
||||||
"commentUser.lastName",
|
"commentUser.lastName",
|
||||||
"commentUser.profilePic"
|
"commentUser.profilePic",
|
||||||
])
|
])
|
||||||
.where("task.id = :taskId", { taskId })
|
.where("task.id = :taskId", { taskId })
|
||||||
|
|
||||||
|
|||||||
@@ -74,6 +74,6 @@ import { TaskCommentService } from "./providers/task-comment.service";
|
|||||||
TimeService,
|
TimeService,
|
||||||
TaskCommentRepository,
|
TaskCommentRepository,
|
||||||
TaskCommentService,
|
TaskCommentService,
|
||||||
]
|
],
|
||||||
})
|
})
|
||||||
export class TaskManagerModule {}
|
export class TaskManagerModule {}
|
||||||
|
|||||||
Reference in New Issue
Block a user