Browse Source

Prod fix

merge-requests/244/merge
Oksana Stepanenko 2 years ago committed by Coder
parent
commit
6f700174a6
  1. 3
      src/core/dto/tasks.dto.ts
  2. 9
      src/domain/tasks/services/tasks-documents.service.ts
  3. 2
      src/rest/app/tasks/app-tasks.module.ts
  4. 23
      src/rest/app/tasks/services/app-tasks.service.ts

3
src/core/dto/tasks.dto.ts

@ -158,6 +158,9 @@ export class TaskDetailedDto { @@ -158,6 +158,9 @@ export class TaskDetailedDto {
@DtoProperty()
isRead: boolean
@DtoPropertyOptional()
factotyName?: string
}
export class TaskDto {

9
src/domain/tasks/services/tasks-documents.service.ts

@ -73,9 +73,6 @@ export class TasksDocumentsService implements Tasks.ITasksDocumentsService { @@ -73,9 +73,6 @@ export class TasksDocumentsService implements Tasks.ITasksDocumentsService {
}
public async add(payload: Tasks.IAddTaskDocumentsPaylod, clearPrevios = false): Promise<void> {
if (payload.userId)
await this.checkPermissionToEditDocuments(payload.userId, payload.taskId)
if (clearPrevios) await this.removeAllByTask(payload.taskId)
const readByUsersId = payload.userId ? [payload.userId] : []
@ -117,12 +114,6 @@ export class TasksDocumentsService implements Tasks.ITasksDocumentsService { @@ -117,12 +114,6 @@ export class TasksDocumentsService implements Tasks.ITasksDocumentsService {
const tasksIds = _.uniq(_.map(documents, 'taskId'))
if (options.userId) {
for (const taskId of tasksIds) {
await this.checkPermissionToEditDocuments(options.userId, taskId)
}
}
try {
await this.tasksDocumentsRepository.delete(id)

2
src/rest/app/tasks/app-tasks.module.ts

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
import { DynamicModule, Module } from '@nestjs/common'
import {
CommentsModule,
FactoriesModule,
MailerModule,
RealTimeModule,
TasksModule,
@ -30,6 +31,7 @@ export class AppTasksModule { @@ -30,6 +31,7 @@ export class AppTasksModule {
TaxonomiesModule.forFeature(),
RealTimeModule.forFeature(),
MailerModule.forFeature(),
FactoriesModule.forFeature(),
],
providers: APP_TASKS_SERVICES,
controllers: [

23
src/rest/app/tasks/services/app-tasks.service.ts

@ -2,8 +2,9 @@ import { Inject, Injectable } from '@nestjs/common' @@ -2,8 +2,9 @@ import { Inject, Injectable } from '@nestjs/common'
import * as _ from 'lodash'
import * as moment from 'moment'
import { $config } from 'src/config'
import { Mailer, Tasks, Taxonomies, Users } from 'src/core'
import { Factories, Mailer, Tasks, Taxonomies, Users } from 'src/core'
import {
FACTORIES_SERVICE,
MAILER_SERVICE,
TASKS_COMMENTS_SERVICE,
TASKS_DOCUMENTS_SERVICE,
@ -41,6 +42,7 @@ export class AppTasksService { @@ -41,6 +42,7 @@ export class AppTasksService {
@Inject(TASKS_COMMENTS_SERVICE)
private readonly tasksCommentsService: Tasks.ITasksCommentsService
@Inject(MAILER_SERVICE) private readonly mailerService: Mailer.IMailerService
@Inject(FACTORIES_SERVICE) private readonly factoriesService: Factories.IFactoriesService
/**
* Метод для створення задач, створює окрему задачу для кожного з виконавців
@ -155,6 +157,25 @@ export class AppTasksService { @@ -155,6 +157,25 @@ export class AppTasksService {
[`${userId}`]: Tasks.Event.Read,
}
if (taskForResponse.executor) {
const factoriesIds = await this.usersService.getAllFactoriesIdsByUser(
taskForResponse.executor.userId,
)
const factories = await this.factoriesService.getFactoriesByIds(factoriesIds)
if (!_.isEmpty(factoriesIds)) {
const factoriesNames = []
factoriesIds.map(it => {
const factory = _.find(factories, factory => factory.id === it)
factoriesNames.push(factory.name)
})
taskForResponse.executor = {
...taskForResponse.executor,
factoryName: factoriesNames.join(', '),
}
}
}
return taskForResponse
}

Loading…
Cancel
Save