2019-04-29 00:11:57 +00:00
|
|
|
<template>
|
2019-05-02 08:55:59 +00:00
|
|
|
<x-container @remove="() => $emit('remove')" :draggable="true">
|
2020-01-29 19:37:25 +00:00
|
|
|
<template #header><fa :icon="faImage"/> {{ $t('_pages.blocks.image') }}</template>
|
2019-04-29 00:11:57 +00:00
|
|
|
<template #func>
|
|
|
|
<button @click="choose()">
|
|
|
|
<fa :icon="faFolderOpen"/>
|
|
|
|
</button>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<section class="oyyftmcf">
|
2020-07-18 15:24:07 +00:00
|
|
|
<mk-file-thumbnail class="preview" v-if="file" :file="file" fit="contain" @click="choose()"/>
|
2019-04-29 00:11:57 +00: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 21:40:02 +00:00
|
|
|
import XContainer from '../page-editor.container.vue';
|
2020-01-29 19:37:25 +00:00
|
|
|
import MkFileThumbnail from '../../../components/drive-file-thumbnail.vue';
|
|
|
|
import { selectDriveFile } from '../../../scripts/select-drive-file';
|
2019-04-29 00:11:57 +00:00
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
components: {
|
2020-01-29 19:37:25 +00:00
|
|
|
XContainer, MkFileThumbnail
|
2019-04-29 00:11:57 +00: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 19:37:25 +00:00
|
|
|
selectDriveFile(this.$root, false).then(file => {
|
2019-04-29 00:11:57 +00:00
|
|
|
this.file = file;
|
|
|
|
this.value.fileId = file.id;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2020-01-29 19:37:25 +00:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.oyyftmcf {
|
|
|
|
> .preview {
|
|
|
|
height: 150px;
|
|
|
|
}
|
|
|
|
}
|
2019-04-29 00:11:57 +00:00
|
|
|
</style>
|