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