aboutsummaryrefslogtreecommitdiff
path: root/src/components/settings_modal/helpers/attachment_setting.js
blob: a0a12ead12b00f429e32d2b487eede7b1df480c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import Setting from './setting.js'
import { fileTypeExt } from 'src/services/file_type/file_type.service.js'
import MediaUpload from 'src/components/media_upload/media_upload.vue'
import Attachment from 'src/components/attachment/attachment.vue'

export default {
  ...Setting,
  props: {
    ...Setting.props,
    type: {
      type: Array,
      required: false,
      default: []
    }
  },
  components: {
    ...Setting.components,
    MediaUpload,
    Attachment
  },
  computed: {
    ...Setting.computed,
    attachment () {
      const path = this.realDraftMode ? this.draft : this.state
      const url = path.includes('://') ? path : this.$store.state.instance.server + path
      return {
        mimetype: fileTypeExt(url),
        url
      }
    }
  },
  methods: {
    ...Setting.methods,
    setMediaFile (fileInfo) {
      if (this.realDraftMode) {
        this.draft = fileInfo.url
      } else {
        this.configSink(this.path, fileInfo.url)
      }
    }
  }
}