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.

109 lines
2.3 KiB

3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <v-card>
  3. <v-card-title>
  4. <v-btn
  5. class="text-capitalize ms-2"
  6. :disabled="!canDelete"
  7. outlined
  8. @click.stop="dialogDelete=true"
  9. >
  10. {{ $t('generic.delete') }}
  11. </v-btn>
  12. <v-dialog v-model="dialogDelete">
  13. <form-delete
  14. :selected="selected"
  15. @cancel="dialogDelete=false"
  16. @remove="remove"
  17. />
  18. </v-dialog>
  19. </v-card-title>
  20. <comment-list
  21. v-model="selected"
  22. :items="item.items"
  23. :is-loading="isLoading"
  24. :total="item.count"
  25. @update:query="updateQuery"
  26. @click:labeling="movePage"
  27. />
  28. </v-card>
  29. </template>
  30. <script lang="ts">
  31. import Vue from 'vue'
  32. import _ from 'lodash'
  33. import CommentList from '@/components/comment/CommentList.vue'
  34. import { CommentReadDTO, CommentListDTO } from '~/services/application/comment/commentData'
  35. import { ProjectDTO } from '~/services/application/project/projectData'
  36. import FormDelete from '~/components/comment/FormDelete.vue'
  37. export default Vue.extend({
  38. components: {
  39. CommentList,
  40. FormDelete
  41. },
  42. layout: 'project',
  43. validate({ params }) {
  44. return /^\d+$/.test(params.id)
  45. },
  46. data() {
  47. return {
  48. dialogDelete: false,
  49. project: {} as ProjectDTO,
  50. item: {} as CommentListDTO,
  51. selected: [] as CommentReadDTO[],
  52. isLoading: false
  53. }
  54. },
  55. async fetch() {
  56. this.isLoading = true
  57. this.project = await this.$services.project.findById(this.projectId)
  58. this.item = await this.$services.comment.listProjectComment(this.projectId, this.$route.query)
  59. this.isLoading = false
  60. },
  61. computed: {
  62. canDelete(): boolean {
  63. return this.selected.length > 0
  64. },
  65. projectId() {
  66. return this.$route.params.id
  67. }
  68. },
  69. watch: {
  70. '$route.query': _.debounce(function() {
  71. // @ts-ignore
  72. this.$fetch()
  73. }, 1000
  74. ),
  75. },
  76. methods: {
  77. async remove() {
  78. await this.$services.comment.deleteBulk(this.projectId, this.selected)
  79. this.$fetch()
  80. this.dialogDelete = false
  81. this.selected = []
  82. },
  83. updateQuery(query: object) {
  84. this.$router.push(query)
  85. },
  86. movePage(query: object) {
  87. this.updateQuery({
  88. path: this.localePath(this.project.pageLink),
  89. query
  90. })
  91. }
  92. }
  93. })
  94. </script>
  95. <style scoped>
  96. ::v-deep .v-dialog {
  97. width: 800px;
  98. }
  99. </style>