Use as file selector
bajki opened this issue · comments
Ivan commented
Hi, is it posible to make this as file selector that returns file path on select like asgardcms has media manager.
https://github.com/Idavoll/Media/blob/3.0/Assets/js/components/SingleMedia.vue
https://github.com/Idavoll/Media/blob/3.0/Assets/js/components/MultipleMedia.vue
Thanks
Bartek Miś commented
Hi @bajki,
I've just tried to achieve the same in one of the projects I have been working on and the answer is to use Vuex store. I've done it as below:
computed: {
fileSelected() {
return this.$store.state.fm.left.selected.files;
}
},
watch: {
fileSelected() {
if (this.fileSelected.length > 0) {
this.modelValue.url = `/storage/${this.fileSelected[0]}`;
this.isFilemanagerOpen = false;
}
}
}
This way, as soon as some file is selected, I'm getting the file path (and I also close the file manager that I open initially in the modal).
Hope that helps!
Best,
Bartek.