2019-11-07 10:19:05 +00:00
|
|
|
module.exports = {
|
|
|
|
name: 'attachment',
|
|
|
|
computed: {
|
2021-03-24 13:25:57 +00:00
|
|
|
attachmentPath() {
|
2019-11-07 10:19:05 +00:00
|
|
|
const filename = this.attachment.filename;
|
|
|
|
const component = this.attachment.component;
|
2022-10-04 11:41:37 +00:00
|
|
|
if (this.attachment.cid && component)
|
2019-11-07 10:19:05 +00:00
|
|
|
return `/api/${component}/assets/files/${filename}`;
|
2022-10-04 11:41:37 +00:00
|
|
|
else if (this.attachment.path)
|
|
|
|
return `/api/${this.attachment.path}?${this.getHttpParams()}`;
|
2019-11-07 10:19:05 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
getHttpParams() {
|
|
|
|
const props = this.args;
|
|
|
|
let query = '';
|
|
|
|
for (let param in props) {
|
2022-10-04 11:41:37 +00:00
|
|
|
if (props[param] && !(props[param] instanceof Object)) {
|
2020-05-22 13:20:55 +00:00
|
|
|
if (query != '') query += '&';
|
|
|
|
query += `${param}=${props[param]}`;
|
|
|
|
}
|
2019-11-07 10:19:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return query;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
attachment: {
|
|
|
|
type: Object,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
args: {
|
|
|
|
type: Object,
|
|
|
|
required: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|