mirror of
https://github.com/filebrowser/filebrowser.git
synced 2025-05-08 19:22:57 +00:00

Former-commit-id: afa0c349648f9e8fe9eb2dbfd5214454f8dcc048 [formerly 21ea1d1edc1cb396c38a4e9d95778929e66c590f] [formerly d0d88d46de21a489e3e19d239e23147bbf018d16 [formerly e0f3687b264ccbeda308e04326179488a73409f2]] Former-commit-id: 24e6f33d7bcb0f9306f8d4953c7af4de39adff5f [formerly e0ec0773fff43ba2243a8687ae33b373a3fd4e1a] Former-commit-id: 5f96744de512d3cc6affa99eebb869354f62605b
54 lines
1.2 KiB
Vue
54 lines
1.2 KiB
Vue
<template>
|
|
<div class="prompt">
|
|
<h3>New file</h3>
|
|
<p>Write the name of the new file.</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('showNewFile', false)">Cancel</button>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import url from '@/utils/url'
|
|
import api from '@/utils/api'
|
|
|
|
export default {
|
|
name: 'new-file',
|
|
data: function () {
|
|
return {
|
|
name: ''
|
|
}
|
|
},
|
|
methods: {
|
|
submit: function (event) {
|
|
event.preventDefault()
|
|
if (this.new === '') return
|
|
|
|
let uri = this.$route.path
|
|
if (this.$store.state.req.kind !== 'listing') {
|
|
uri = url.removeLastDir(uri) + '/'
|
|
}
|
|
|
|
uri += this.name
|
|
uri = uri.replace('//', '/')
|
|
|
|
// buttons.setLoading('newFile')
|
|
api.put(uri)
|
|
.then(() => {
|
|
// buttons.setDone('newFile')
|
|
this.$router.push({ path: uri })
|
|
})
|
|
.catch(error => {
|
|
// buttons.setDone('newFile', false)
|
|
console.log(error)
|
|
})
|
|
|
|
this.$store.commit('showNewFile', false)
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|