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.

85 lines
1.7 KiB

  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="items"
  23. :is-loading="isLoading"
  24. />
  25. </v-card>
  26. </template>
  27. <script lang="ts">
  28. import Vue from 'vue'
  29. import CommentList from '@/components/comment/CommentList.vue'
  30. import { CommentReadDTO } from '~/services/application/comment/commentData'
  31. import FormDelete from '~/components/comment/FormDelete.vue'
  32. export default Vue.extend({
  33. layout: 'project',
  34. components: {
  35. CommentList,
  36. FormDelete
  37. },
  38. async fetch() {
  39. this.isLoading = true
  40. this.items = await this.$services.comment.listProjectComment(this.projectId)
  41. this.isLoading = false
  42. },
  43. data() {
  44. return {
  45. dialogDelete: false,
  46. items: [] as CommentReadDTO[],
  47. selected: [] as CommentReadDTO[],
  48. isLoading: false
  49. }
  50. },
  51. computed: {
  52. canDelete(): boolean {
  53. return this.selected.length > 0
  54. },
  55. projectId() {
  56. return this.$route.params.id
  57. }
  58. },
  59. methods: {
  60. async remove() {
  61. await this.$services.comment.deleteBulk(this.projectId, this.selected)
  62. this.$fetch()
  63. this.dialogDelete = false
  64. this.selected = []
  65. }
  66. },
  67. validate({ params }) {
  68. return /^\d+$/.test(params.id)
  69. }
  70. })
  71. </script>
  72. <style scoped>
  73. ::v-deep .v-dialog {
  74. width: 800px;
  75. }
  76. </style>