filebrowser/assets/src/components/prompts/NewDir.vue
Henrique Dias e6efec5682 Comments and bugfixes
Former-commit-id: 3683a8730ff5d068f3c1c79bb93c3636c00d48f6 [formerly fe04704b2248be7e313fa879746cacd335fed043] [formerly ebfa6675e34ee278af94af56aa8f43d4566d6f5f [formerly 5eab62e0aa566747edeebfa55a4e39d898ff8db5]]
Former-commit-id: 9ce059f75dc890570f9a992bf514c416ebf8e2f6 [formerly 02c89f89f211c95f8879cc4559efa3f4de7e8fca]
Former-commit-id: fb88da21590be01e95a963d453b6c3c880244281
2017-07-08 11:30:22 +01:00

49 lines
1.1 KiB
Vue

<template>
<div class="prompt">
<h3>New directory</h3>
<p>Write the name of the new directory.</p>
<input autofocus type="text" @keyup.enter="submit" v-model.trim="name">
<div>
<button class="ok" @click="submit">Create</button>
<button class="cancel" @click="$store.commit('closeHovers')">Cancel</button>
</div>
</div>
</template>
<script>
import url from '@/utils/url'
import api from '@/utils/api'
export default {
name: 'new-dir',
data: function () {
return {
name: ''
}
},
methods: {
submit: function (event) {
event.preventDefault()
if (this.new === '') return
// Build the path of the new directory.
let uri = this.$route.path
if (this.$store.state.req.kind !== 'listing') {
uri = url.removeLastDir(uri) + '/'
}
uri += this.name + '/'
uri = uri.replace('//', '/')
api.post(uri)
.then(() => { this.$router.push({ path: uri }) })
.catch(error => { this.$store.commit('showError', error) })
// Close the prompt
this.$store.commit('closeHovers')
}
}
}
</script>