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.

69 lines
1.4 KiB

  1. export class DocumentItemList {
  2. constructor(
  3. private _count: number,
  4. private _next: string | null,
  5. private _prev: string | null,
  6. private _items: DocumentItem[]
  7. ) {}
  8. static valueOf(
  9. { count, next, previous, results }:
  10. {
  11. count : number,
  12. next : string | null,
  13. previous: string | null,
  14. results : Array<any>
  15. }
  16. ): DocumentItemList {
  17. const items = results.map(item => DocumentItem.valueOf(item))
  18. return new DocumentItemList(
  19. count,
  20. next,
  21. previous,
  22. items
  23. )
  24. }
  25. get count() {
  26. return this._count
  27. }
  28. get next() {
  29. return this._next
  30. }
  31. get prev() {
  32. return this._prev
  33. }
  34. get items(): DocumentItem[] {
  35. return this._items
  36. }
  37. }
  38. export class DocumentItem {
  39. constructor(
  40. public id: number,
  41. public text: string,
  42. public meta: string,
  43. public annotationApprover: boolean | null,
  44. public commentCount: number
  45. ) {}
  46. static valueOf(
  47. { id, text, meta, annotation_approver, comment_count }:
  48. { id: number, text: string, meta: string, annotation_approver: boolean | null, comment_count: number }
  49. ): DocumentItem {
  50. return new DocumentItem(id, text, meta, annotation_approver, comment_count)
  51. }
  52. toObject(): Object {
  53. return {
  54. id: this.id,
  55. text: this.text,
  56. meta: this.meta,
  57. annotation_approver: this.annotationApprover,
  58. comment_count: this.commentCount
  59. }
  60. }
  61. }