2019-04-29 02:11:57 +02:00
|
|
|
<template>
|
2019-05-02 10:55:59 +02:00
|
|
|
<x-container @remove="() => $emit('remove')" :draggable="true">
|
2020-01-29 20:37:25 +01:00
|
|
|
<template #header><fa :icon="faImage"/> {{ $t('_pages.blocks.image') }}</template>
|
2019-04-29 02:11:57 +02:00
|
|
|
<template #func>
|
|
|
|
<button @click="choose()">
|
|
|
|
<fa :icon="faFolderOpen"/>
|
|
|
|
</button>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<section class="oyyftmcf">
|
2020-01-29 20:37:25 +01:00
|
|
|
<mk-file-thumbnail class="preview" v-if="file" :file="file" :detail="true" fit="contain" @click="choose()"/>
|
2019-04-29 02:11:57 +02:00
|
|
|
</section>
|
|
|
|
</x-container>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
|
|
|
import { faPencilAlt } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
import { faImage, faFolderOpen } from '@fortawesome/free-regular-svg-icons';
|
2019-04-29 23:40:02 +02:00
|
|
|
import XContainer from '../page-editor.container.vue';
|
2020-01-29 20:37:25 +01:00
|
|
|
import MkFileThumbnail from '../../../components/drive-file-thumbnail.vue';
|
|
|
|
import { selectDriveFile } from '../../../scripts/select-drive-file';
|
2019-04-29 02:11:57 +02:00
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
components: {
|
2020-01-29 20:37:25 +01:00
|
|
|
XContainer, MkFileThumbnail
|
2019-04-29 02:11:57 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
props: {
|
|
|
|
value: {
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
file: null,
|
|
|
|
faPencilAlt, faImage, faFolderOpen
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
|
|
|
if (this.value.fileId === undefined) Vue.set(this.value, 'fileId', null);
|
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
if (this.value.fileId == null) {
|
|
|
|
this.choose();
|
|
|
|
} else {
|
|
|
|
this.$root.api('drive/files/show', {
|
|
|
|
fileId: this.value.fileId
|
|
|
|
}).then(file => {
|
|
|
|
this.file = file;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
async choose() {
|
2020-01-29 20:37:25 +01:00
|
|
|
selectDriveFile(this.$root, false).then(file => {
|
2019-04-29 02:11:57 +02:00
|
|
|
this.file = file;
|
|
|
|
this.value.fileId = file.id;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2020-01-29 20:37:25 +01:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.oyyftmcf {
|
|
|
|
> .preview {
|
|
|
|
height: 150px;
|
|
|
|
}
|
|
|
|
}
|
2019-04-29 02:11:57 +02:00
|
|
|
</style>
|