Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set default disk and path on init or any oninit callback ? #117

Open
MuratDemirel opened this issue Apr 25, 2022 · 1 comment
Open

Set default disk and path on init or any oninit callback ? #117

MuratDemirel opened this issue Apr 25, 2022 · 1 comment

Comments

@MuratDemirel
Copy link

I need to set path according view. This code works, but is there any better way?

setImg(input){
    this.$bvModal.show('modal-fm')

    setTimeout(this.setPath, 1000)
    this.$store.commit('fm/setFileCallBack', url => {
        this.formData[input] = url
        this.$bvModal.hide('modal-fm')
    });
},
setPath(){
    this.$store.commit('fm/left/setSelectedDirectory', 'files/faq')
    this.$store.commit('fm/left/addToHistory', 'files/faq')
    this.$store.dispatch('fm/tree/reopenPath', 'files/faq')
    this.$store.dispatch(`fm/left/selectDirectory`, { path:'files/faq', history: true })
}

Vue@2
vue-laravel-file-manager@2.5.3

@MuratDemirel
Copy link
Author

Better than before, but defining on settings or having callbacks would great..

data(){
    return{
        foldersLoaded: false
    }
},
watch:{
    '$store.state.fm.tree.directories': function(directories){
        if(!this.foldersLoaded && directories.length){
            this.foldersLoaded = true
            this.setPath()
        }else if(this.foldersLoaded && !directories.length){
            this.foldersLoaded = false
        }
    }
},
methods:{
    setImg(input){
        this.$bvModal.show('modal-fm')

        this.$store.commit('fm/setFileCallBack', url => {
            this.formData[input] = url
            this.$bvModal.hide('modal-fm')
        });
    },
    setPath(){
        this.$store.commit('fm/left/setSelectedDirectory', 'files/faq')
        this.$store.commit('fm/left/addToHistory', 'files/faq')
        this.$store.dispatch('fm/tree/reopenPath', 'files/faq')
        this.$store.dispatch(`fm/left/selectDirectory`, { path:'files/faq', history: true })
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant