| Total Complexity | 1 |
| Complexity/F | 1 |
| Lines of Code | 32 |
| Function Count | 1 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import { Injectable } from '@nestjs/common'; |
||
| 2 | import { TaskView } from 'src/Application/Task/View/TaskView'; |
||
| 3 | import { RouteNameResolver } from 'src/Infrastructure/Common/ExtendedRouting/RouteNameResolver'; |
||
| 4 | import { RowFactory } from 'src/Infrastructure/Tables/RowFactory'; |
||
| 5 | import { Table } from 'src/Infrastructure/Tables'; |
||
| 6 | |||
| 7 | @Injectable() |
||
| 8 | export class TaskTableFactory { |
||
| 9 | constructor( |
||
| 10 | private readonly resolver: RouteNameResolver, |
||
| 11 | private readonly rowFactory: RowFactory |
||
| 12 | ) {} |
||
| 13 | |||
| 14 | public create(tasks: TaskView[]): Table { |
||
| 15 | const columns = ['crm-tasks-name', 'common-actions']; |
||
| 16 | |||
| 17 | const rows = tasks.map(task => |
||
| 18 | this.rowFactory |
||
| 19 | .createBuilder() |
||
| 20 | .value(task.name) |
||
| 21 | .actions({ |
||
| 22 | edit: { |
||
| 23 | url: this.resolver.resolve('crm_tasks_edit', { id: task.id }) |
||
| 24 | } |
||
| 25 | }) |
||
| 26 | .build() |
||
| 27 | ); |
||
| 28 | |||
| 29 | return new Table(columns, rows); |
||
| 30 | } |
||
| 31 | } |
||
| 32 |