You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
2.0 KiB

  1. import { ProjectReadItem, ProjectType, ProjectItemList } from '~/domain/models/project/project'
  2. export class ProjectDTO {
  3. id: number
  4. name: string
  5. description: string
  6. guideline: string
  7. projectType: ProjectType
  8. updatedAt: string
  9. enableRandomOrder: boolean
  10. enableShareAnnotation: boolean
  11. singleClassClassification: boolean
  12. pageLink: string
  13. tags: Object[]
  14. canDefineLabel: boolean
  15. canDefineRelation: boolean
  16. isTextProject: boolean
  17. allowOverlapping: boolean
  18. graphemeMode: boolean
  19. hasCategory: boolean
  20. hasSpan: boolean
  21. taskNames: string[]
  22. useRelation: boolean
  23. constructor(item: ProjectReadItem) {
  24. this.id = item.id
  25. this.name = item.name
  26. this.description = item.description
  27. this.guideline = item.guideline
  28. this.projectType = item.projectType
  29. this.updatedAt = item.updatedAt
  30. this.enableRandomOrder = item.randomOrder
  31. this.enableShareAnnotation = item.collaborative_annotation
  32. this.singleClassClassification = item.exclusiveCategories
  33. this.pageLink = item.annotationPageLink
  34. this.tags = item.tags
  35. this.canDefineLabel = item.canDefineLabel
  36. this.canDefineRelation = item.canDefineRelation
  37. this.isTextProject = item.isTextProject
  38. this.allowOverlapping = item.allowOverlapping
  39. this.graphemeMode = item.graphemeMode
  40. this.hasCategory = item.canDefineCategory
  41. this.hasSpan = item.canDefineSpan
  42. this.taskNames = item.taskNames
  43. this.useRelation = item.useRelation
  44. }
  45. }
  46. export type ProjectWriteDTO = Pick<ProjectDTO, 'id' | 'name' | 'description' | 'guideline' | 'projectType' | 'enableRandomOrder' | 'enableShareAnnotation' | 'singleClassClassification' | 'allowOverlapping' | 'graphemeMode' | 'tags' | 'useRelation'>
  47. export class ProjectListDTO {
  48. count: number
  49. next : string | null
  50. prev : string | null
  51. items: ProjectDTO[]
  52. constructor(item: ProjectItemList) {
  53. this.count = item.count
  54. this.next = item.next
  55. this.prev = item.prev
  56. this.items = item.items.map(_ => new ProjectDTO(_))
  57. }
  58. }