<template>
  <file-list :is-editable="isEditable">
    <file-list-item
      v-for="(file, index) in files"
      @remove-file="removeFile(index)"
      :key="file.id"
      :label="file.filename"
      :extension="file.extension"
      :link="file.url"
      class="q-mt-md"
    />
  </file-list>
</template>

<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator'
import { AttachmentFile } from '@/types'
import FileListItem from '@/widgets/base/components/message/FileListItem.vue'
import FileList from '@/widgets/base/components/message/FileList.vue'

@Component({
  components: { FileListItem, FileList },
})
export default class TaskFiles extends Vue {
  @Prop(Boolean)
  isEditable!: boolean

  @Prop({ type: Array, required: true })
  files!: AttachmentFile[]

  removeFile(index: number) {
    this.files.splice(index, 1)
  }
}
</script>
